From 99d4ce9d2d943f07b984e8c4b8e77379624cb7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Wed, 21 May 2025 12:40:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E4=BC=98=E5=8C=96nav=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E8=8F=9C=E5=8D=95=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/common/app.js | 4 ++-- .../common/dropdown-menu-group.js | 23 ++++++++++++++++++- common/modules/mixly-modules/deps.json | 3 +++ common/templates/html/dropdown-menu-item.html | 14 +++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 common/templates/html/dropdown-menu-item.html diff --git a/common/modules/mixly-modules/common/app.js b/common/modules/mixly-modules/common/app.js index 3106c586..92b2f60a 100644 --- a/common/modules/mixly-modules/common/app.js +++ b/common/modules/mixly-modules/common/app.js @@ -443,7 +443,7 @@ class App extends Component { this.#nav_.register({ id: 'file', - displayText: `${Msg.Lang['nav.btn.file']}(F)`, + displayText: Msg.Lang['nav.btn.file'], scopeType: Nav.Scope.RIGHT, weight: 1, menu: fileMenu @@ -451,7 +451,7 @@ class App extends Component { this.#nav_.register({ id: 'setting', - displayText: `${Msg.Lang['nav.btn.setting']}(S)`, + displayText: Msg.Lang['nav.btn.setting'], scopeType: Nav.Scope.RIGHT, weight: 2, menu: settingMenu diff --git a/common/modules/mixly-modules/common/dropdown-menu-group.js b/common/modules/mixly-modules/common/dropdown-menu-group.js index 4003496a..ac992e58 100644 --- a/common/modules/mixly-modules/common/dropdown-menu-group.js +++ b/common/modules/mixly-modules/common/dropdown-menu-group.js @@ -1,16 +1,21 @@ goog.loadJs('common', () => { +goog.require('path'); goog.require('tippy'); +goog.require('Mixly.Env'); goog.require('Mixly.Menu'); goog.require('Mixly.Registry'); +goog.require('Mixly.HTMLTemplate'); goog.require('Mixly.IdGenerator'); goog.require('Mixly.ContextMenu'); goog.require('Mixly.DropdownMenu'); goog.provide('Mixly.DropdownMenuGroup'); const { + Env, Menu, Registry, + HTMLTemplate, IdGenerator, ContextMenu, DropdownMenu @@ -18,6 +23,13 @@ const { class DropdownMenuGroup { + static { + HTMLTemplate.add( + 'html/dropdown-menu-item.html', + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/dropdown-menu-item.html'))) + ); + } + #singleton_ = null; #menuItems_ = []; #ids_ = {}; @@ -85,9 +97,12 @@ class DropdownMenuGroup { item.weight = 0; } this.remove(item.id); - item.$elem = $(``); + item.$elem = $(HTMLTemplate.get('html/dropdown-menu-item.html').render({ + text: item.displayText + })); const instance = tippy(item.$elem[0]); item.$elem.attr('data-id', instance.id); + item.$i = item.$elem.children('i'); item.instance = instance; const contextMenuId = IdGenerator.generate(); const selector = `body > .mixly-dropdown-menus > div[m-id="${contextMenuId}"]`; @@ -103,10 +118,12 @@ class DropdownMenuGroup { }, events: { show: (opt) => { + item.$i.addClass('menu-shown'); this.#menuShown_ = true; this.#singleton_.setProps({}); }, hide: (opt) => { + item.$i.removeClass('menu-shown'); if (this.#trigged_) { this.#trigged_ = false; return true; @@ -155,6 +172,10 @@ class DropdownMenuGroup { return this.#ids_[id].contextMenu; } + getInstance() { + return this.#singleton_; + } + remove(id) { let item = this.#ids_[id]; if (!item) { diff --git a/common/modules/mixly-modules/deps.json b/common/modules/mixly-modules/deps.json index cf9682c6..81508236 100644 --- a/common/modules/mixly-modules/deps.json +++ b/common/modules/mixly-modules/deps.json @@ -189,9 +189,12 @@ { "path": "/common/dropdown-menu-group.js", "require": [ + "path", "tippy", + "Mixly.Env", "Mixly.Menu", "Mixly.Registry", + "Mixly.HTMLTemplate", "Mixly.IdGenerator", "Mixly.ContextMenu", "Mixly.DropdownMenu" diff --git a/common/templates/html/dropdown-menu-item.html b/common/templates/html/dropdown-menu-item.html new file mode 100644 index 00000000..9e03d006 --- /dev/null +++ b/common/templates/html/dropdown-menu-item.html @@ -0,0 +1,14 @@ + + \ No newline at end of file