chore(core): 调整nav右侧菜单栏

This commit is contained in:
王立帮
2025-05-18 00:57:14 +08:00
parent 59c408d926
commit ebe834976e
3 changed files with 40 additions and 19 deletions

View File

@@ -18,13 +18,13 @@ const {
class DropdownMenuGroup { class DropdownMenuGroup {
#shown_ = false;
#singleton_ = null; #singleton_ = null;
#menuItems_ = []; #menuItems_ = [];
#ids_ = {}; #ids_ = {};
#instanceIds_ = {}; #instanceIds_ = {};
#activeInstance_ = null; #activeInstance_ = null;
#hided_ = false; #instanceShown_ = false;
#menuShown_ = false;
#trigged_ = false; #trigged_ = false;
#$instancePopper_ = null; #$instancePopper_ = null;
#$instanceContent_ = null; #$instanceContent_ = null;
@@ -44,27 +44,28 @@ class DropdownMenuGroup {
delay: [200, null], delay: [200, null],
onShow: () => { onShow: () => {
if (this.#activeInstance_) { if (this.#activeInstance_) {
this.show(this.#activeInstance_.id); this.showMenu(this.#activeInstance_.id);
} }
this.#shown_ = true; this.#instanceShown_ = true;
}, },
onTrigger: (_, event) => { onTrigger: (_, event) => {
const id = $(event.currentTarget).attr('data-id'); const id = $(event.currentTarget).attr('data-id');
if (this.#shown_) { if (this.#instanceShown_) {
if (this.#activeInstance_) { if (this.#activeInstance_) {
this.#trigged_ = true; this.#trigged_ = true;
this.hide(this.#activeInstance_.id); this.hideMenu(this.#activeInstance_.id);
this.#activeInstance_ = null; this.#activeInstance_ = null;
} }
this.show(id); this.showMenu(id);
} }
this.#activeInstance_ = this.#instanceIds_[id].instance; this.#activeInstance_ = this.#instanceIds_[id].instance;
}, },
onHide: () => { onHide: () => {
if (this.#hided_) { if (this.#menuShown_) {
this.#shown_ = false; return false;
} }
return this.#hided_; this.#instanceShown_ = false;
return true;
} }
}); });
this.#$instancePopper_ = $(this.#singleton_.popper); this.#$instancePopper_ = $(this.#singleton_.popper);
@@ -102,15 +103,15 @@ class DropdownMenuGroup {
}, },
events: { events: {
show: (opt) => { show: (opt) => {
this.#hided_ = false; this.#menuShown_ = true;
this.#singleton_.setProps({}); this.#singleton_.setProps({});
}, },
hide: (opt) => { hide: (opt) => {
if (this.trigged_) { if (this.#trigged_) {
this.trigged_ = false; this.#trigged_ = false;
return true; return true;
} }
this.#hided_ = true; this.#menuShown_ = false;
this.#singleton_.hide(); this.#singleton_.hide();
} }
} }
@@ -176,12 +177,12 @@ class DropdownMenuGroup {
item = null; item = null;
} }
show(instanceId) { showMenu(instanceId) {
const item = this.#instanceIds_[instanceId]; const item = this.#instanceIds_[instanceId];
item.$menu.contextMenu(); item.$menu.contextMenu();
} }
hide(instanceId) { hideMenu(instanceId) {
const item = this.#instanceIds_[instanceId]; const item = this.#instanceIds_[instanceId];
item.$menu.contextMenu('hide'); item.$menu.contextMenu('hide');
} }

View File

@@ -23,13 +23,15 @@
"path": "/common/app.js", "path": "/common/app.js",
"require": [ "require": [
"path", "path",
"layui", "hotkeys",
"Mixly.Url", "Mixly.Url",
"Mixly.Config", "Mixly.Config",
"Mixly.Env", "Mixly.Env",
"Mixly.Msg", "Mixly.Msg",
"Mixly.Drag", "Mixly.Drag",
"Mixly.Nav", "Mixly.Nav",
"Mixly.Menu",
"Mixly.ContextMenu",
"Mixly.Workspace", "Mixly.Workspace",
"Mixly.FooterBar", "Mixly.FooterBar",
"Mixly.HTMLTemplate", "Mixly.HTMLTemplate",
@@ -187,6 +189,20 @@
"Mixly.DragV" "Mixly.DragV"
] ]
}, },
{
"path": "/common/dropdown-menu-group.js",
"require": [
"tippy",
"Mixly.Menu",
"Mixly.Registry",
"Mixly.IdGenerator",
"Mixly.ContextMenu",
"Mixly.DropdownMenu"
],
"provide": [
"Mixly.DropdownMenuGroup"
]
},
{ {
"path": "/common/dropdown-menu.js", "path": "/common/dropdown-menu.js",
"require": [ "require": [
@@ -462,6 +478,7 @@
"path": "/common/footerlayer-board-config.js", "path": "/common/footerlayer-board-config.js",
"require": [ "require": [
"path", "path",
"tippy",
"Blockly", "Blockly",
"layui", "layui",
"$.select2", "$.select2",
@@ -769,7 +786,10 @@
"Mixly.XML", "Mixly.XML",
"Mixly.Msg", "Mixly.Msg",
"Mixly.HTMLTemplate", "Mixly.HTMLTemplate",
"Mixly.Component" "Mixly.Component",
"Mixly.Menu",
"Mixly.ContextMenu",
"Mixly.DropdownMenuGroup"
], ],
"provide": [ "provide": [
"Mixly.Nav" "Mixly.Nav"

View File

@@ -1,4 +1,4 @@
<li class="layui-nav-item mixly-scrollbar" lay-unselect m-id={{d.mId}}> <li class="layui-nav-item mixly-scrollbar" lay-unselect m-id="{{d.mId}}">
<a style="white-space: nowrap;"> <a style="white-space: nowrap;">
{{d.text}} {{d.text}}
</a> </a>