From 6e03a05e6de4dafd681bf39b62bd4c588ff5f50c Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 23 May 2025 11:26:22 +0800 Subject: [PATCH] no message --- .../assets/js/components/MicroApps/index.vue | 60 +++++++++---------- .../pages/manage/components/DialogWrapper.vue | 2 +- resources/assets/js/pages/single/apps.vue | 6 +- resources/assets/js/routes.js | 2 +- resources/assets/js/store/actions.js | 6 +- resources/assets/js/store/mutations.js | 1 - 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/resources/assets/js/components/MicroApps/index.vue b/resources/assets/js/components/MicroApps/index.vue index f2786de85..e41dcdf5c 100644 --- a/resources/assets/js/components/MicroApps/index.vue +++ b/resources/assets/js/components/MicroApps/index.vue @@ -4,18 +4,18 @@ v-for="(app, key) in apps" :key="key" v-model="app.isOpen" - :ref="`ref-${app.id}`" + :ref="`ref-${app.name}`" :size="1200" :transparent="app.transparent" :autoDarkTheme="app.autoDarkTheme" - :beforeClose="async () => { await onBeforeClose(app.id) }"> + :beforeClose="async () => { await onBeforeClose(app.name) }"> id == e.detail.name); + const app = this.apps.find(({name}) => name == e.detail.name); if (app) { app.isLoading = false } @@ -181,11 +181,11 @@ export default { /** * 应用数据 - * @param id + * @param name * @returns {*} */ - appData(id) { - const app = this.apps.find(item => item.id == id); + appData(name) { + const app = this.apps.find(item => item.name == name); if (!app) { return {}; } @@ -225,10 +225,10 @@ export default { methods: { close: (destroy = false) => { - this.closeMicroApp(id, destroy) + this.closeMicroApp(name, destroy) }, back: () => { - this.closeById(id) + this.closeByName(name) }, nextZIndex: () => { if (typeof window.modalTransferIndex === 'number') { @@ -256,12 +256,12 @@ export default { let appConfig = {} if (config.url) { appConfig = { - id: `url-${await $A.getSHA256Hash(config.url)}`, + name: `url-${await $A.getSHA256Hash(config.url)}`, url: config.url, } delete config.url } else { - const app = this.apps.find(item => item.id == id); + const app = this.apps.find(item => item.name == name); if (!app) { $A.modalError("应用不存在"); return @@ -271,14 +271,14 @@ export default { appConfig.transparent = true appConfig.keepAlive = false - const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.id != appConfig.id); + const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.name != appConfig.name); apps.length > 50 && apps.splice(0, 10) apps.push(appConfig) await $A.IDBSet("cacheMicroApps", apps); await this.$store.dispatch('openChildWindow', { name: `single-apps-${$A.randomString(6)}`, - path: `/single/apps/${appConfig.id}`, + path: `/single/apps/${appConfig.name}`, force: false, config }); @@ -329,11 +329,11 @@ export default { * @param config */ async observeMicroApp(config) { - const app = this.apps.find(({id}) => id == config.id); + const app = this.apps.find(({name}) => name == config.name); if (app) { // 更新微应用 if (app.url != config.url) { - await microApp.unmountApp(app.id, {destroy: true}) + await microApp.unmountApp(app.name, {destroy: true}) app.isLoading = true } Object.assign(app, config) @@ -348,31 +348,31 @@ export default { }, /** - * 通过ID关闭微应用 - * @param id + * 通过名称关闭微应用 + * @param name */ - closeById(id) { + closeByName(name) { try { - this.$refs[`ref-${id}`][0].onClose() + this.$refs[`ref-${name}`][0].onClose() } catch (e) { - this.closeMicroApp(id) + this.closeMicroApp(name) } }, /** * 关闭微应用 - * @param id + * @param name * @param destroy */ - closeMicroApp(id, destroy) { - const app = this.apps.find(item => item.id == id); + closeMicroApp(name, destroy) { + const app = this.apps.find(item => item.name == name); if (!app) { return; } app.isOpen = false if (destroy) { - microApp.unmountApp(app.id, {destroy: true}) + microApp.unmountApp(app.name, {destroy: true}) } }, @@ -386,14 +386,14 @@ export default { /** * 关闭之前判断 - * @param id + * @param name * @returns {Promise} */ - onBeforeClose(id) { + onBeforeClose(name) { return new Promise(resolve => { - microApp.forceSetData(id, {type: 'beforeClose'}, array => { + microApp.forceSetData(name, {type: 'beforeClose'}, array => { if (!array?.find(item => item === true)) { - if (id === 'appstore') { + if (name === 'appstore') { this.$store.dispatch("updateMicroAppsStatus"); } if ($A.isSubElectron) { @@ -414,7 +414,7 @@ export default { return new Promise(resolve => { const app = this.apps.findLast(item => item.isOpen) if (app) { - this.closeById(app.id) + this.closeByName(app.name) } else { resolve() } diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 0defdd005..99083dc1a 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -2626,7 +2626,7 @@ export default { this.$store.dispatch("openMicroApp", { id: 'okr', key: 'details', - url: 'apps/okr/', + url: 'apps/okr/#details', props: {type: 'details', id}, transparent: true, }); diff --git a/resources/assets/js/pages/single/apps.vue b/resources/assets/js/pages/single/apps.vue index ba019c42f..93dce6c14 100644 --- a/resources/assets/js/pages/single/apps.vue +++ b/resources/assets/js/pages/single/apps.vue @@ -9,13 +9,13 @@ export default { components: { MicroApps }, async mounted() { - const id = this.$route.params.appId; - if (!id) { + const {name} = this.$route.params; + if (!name) { $A.modalError("应用不存在"); return } - const app = (await $A.IDBArray("cacheMicroApps")).reverse().find(item => item.id === id); + const app = (await $A.IDBArray("cacheMicroApps")).reverse().find(item => item.name === name); if (!app) { $A.modalError("应用不存在"); return diff --git a/resources/assets/js/routes.js b/resources/assets/js/routes.js index 1244eab96..dd9220cf5 100755 --- a/resources/assets/js/routes.js +++ b/resources/assets/js/routes.js @@ -155,7 +155,7 @@ export default [ }, { name: 'single-apps', - path: '/single/apps/:appId', + path: '/single/apps/:name', component: () => import('./pages/single/apps.vue') }, { diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index ec5f19520..000c4d0cf 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -4654,7 +4654,7 @@ export default { * - keepAlive 是否开启微应用保活 (true/false),默认 true * - disableScopecss 是否禁用样式隔离 (true/false),默认 false */ - openMicroApp({state}, data) { + async openMicroApp({state}, data) { if (!data || !$A.isJson(data)) { return } @@ -4677,9 +4677,7 @@ export default { $A.modalWarning(`应用「${config.id}」未安装`); return; } - if (data.key) { - config.id += `_${data.key}` - } + config.name = `${config.id}_${await $A.getSHA256Hash(config.url)}` emitter.emit('observeMicroApp:open', config); }, diff --git a/resources/assets/js/store/mutations.js b/resources/assets/js/store/mutations.js index 2f9e4f298..c1d3e3287 100644 --- a/resources/assets/js/store/mutations.js +++ b/resources/assets/js/store/mutations.js @@ -304,7 +304,6 @@ export default { data.unshift({ id: 'appstore', menu_items: [{ - id: 'appstore', location: "application/admin", label: $A.L("应用商店"), icon: $A.mainUrl("images/application/appstore.svg"),