From 05a3c3d6724571c18c1837fd650a842bff171f22 Mon Sep 17 00:00:00 2001 From: luoyifan Date: Mon, 26 May 2025 19:21:12 +0800 Subject: [PATCH] WorldModel open --- src/views/ModelMain.vue | 45 +++++++++++++++++++++++---------------------- src/views/ModelMainInit.ts | 9 +++++---- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/views/ModelMain.vue b/src/views/ModelMain.vue index 8f542be..0bfeb06 100644 --- a/src/views/ModelMain.vue +++ b/src/views/ModelMain.vue @@ -118,34 +118,35 @@ export default { ModelMainInit() }, mounted() { - ModelMainMounted() + ModelMainMounted().then(() => { - // 注册 widget 快捷键 - const allWidget = getAllWidget() + // 注册 widget 快捷键 + const allWidget = getAllWidget() - allWidget.forEach((widget) => { - if (widget?.shortcut && widget?.name && widget?.side) { - const shortKey = normalizeShortKey(widget.shortcut) - widget.shortcut = shortKey - if (shortKey) { - system.hotkeys(shortKey, (event) => { - if (widget.side === 'left') { - this.sectionLeftName = widget.name - this.hideLeft = false + allWidget.forEach((widget) => { + if (widget?.shortcut && widget?.name && widget?.side) { + const shortKey = normalizeShortKey(widget.shortcut) + widget.shortcut = shortKey + if (shortKey) { + system.hotkeys(shortKey, (event) => { + if (widget.side === 'left') { + this.sectionLeftName = widget.name + this.hideLeft = false - } else if (widget.side === 'right') { - this.sectionRightName = widget.name - this.hideRight = false + } else if (widget.side === 'right') { + this.sectionRightName = widget.name + this.hideRight = false - } else if (widget.side === 'bottom') { - this.sectionBottomName = widget.name - this.hideBottom = false - } + } else if (widget.side === 'bottom') { + this.sectionBottomName = widget.name + this.hideBottom = false + } - event.preventDefault() - }) + event.preventDefault() + }) + } } - } + }) }) }, unmounted() { diff --git a/src/views/ModelMainInit.ts b/src/views/ModelMainInit.ts index be317b4..8b629e5 100644 --- a/src/views/ModelMainInit.ts +++ b/src/views/ModelMainInit.ts @@ -37,13 +37,10 @@ export function ModelMainInit() { const worldModel = new WorldModel() window['worldModel'] = worldModel - - worldModel.init().then(() => { - worldModel.open() - }) } export function ModelMainMounted() { + forEachMenu((menu) => { if (typeof menu.click === 'function') { @@ -58,6 +55,10 @@ export function ModelMainMounted() { } } }) + + return worldModel.init().then(() => { + worldModel.open() + }) } export function ModelMainUnmounted() {