From 2af1dba8dcc01b695e3f6fe1e52afebecf334a2c Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 26 May 2025 20:54:06 +0800 Subject: [PATCH] no message --- .../assets/js/components/MicroApps/index.vue | 22 ------------------- .../pages/manage/components/DialogWrapper.vue | 2 +- resources/assets/js/store/actions.js | 11 +++++----- resources/assets/js/store/mutations.js | 10 +++++++++ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/resources/assets/js/components/MicroApps/index.vue b/resources/assets/js/components/MicroApps/index.vue index 8dc92337a..8146a6e40 100644 --- a/resources/assets/js/components/MicroApps/index.vue +++ b/resources/assets/js/components/MicroApps/index.vue @@ -309,33 +309,11 @@ export default { } }, - /** - * 生成微应用名称 - * @param config - * @returns {Promise} - */ - async generateAppName(config) { - let name = config.id || 'micro-app' - if (!this.apps.find(item => item.name == name)) { - return name - } - const additional = `${config.url}` - .replace(/^https?:\/\//, '') - .replace(/[^a-zA-Z0-9]/g, '_') - name = `${config.id}_${additional.substring(0, 8)}` - if (!this.apps.find(item => item.name == name)) { - return name - } - return `${config.id}_${additional}` - }, - /** * 观察打开微应用 * @param config */ async observeMicroApp(config) { - config.name = await this.generateAppName(config) - if (config.url_type === 'inline_blank') { await this.inlineBlank(config) return diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index c7d4af57b..c4250c5ba 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -2627,7 +2627,7 @@ export default { } this.$store.dispatch("openMicroApp", { id: 'okr', - key: 'details', + name: 'okr_details', url: 'apps/okr/#details', props: {type: 'details', id}, transparent: true, diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 619495f84..90afe85a5 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -4653,8 +4653,9 @@ export default { * 打开微应用 * @param state * @param data - * - id 应用ID - * - url 应用地址 + * - id 应用ID(必须) + * - name 应用名称(必须) + * - url 应用地址(必须) * - url_type 地址类型 * - transparent 是否透明模式 (true/false),默认 false * - disable_scope_css 是否禁用样式隔离 (true/false),默认 false @@ -4666,11 +4667,12 @@ export default { if (!data || !$A.isJson(data)) { return } - if (!data.url) { + if (!data.id || !data.name || !data.url) { return } const config = { id: data.id, + name: data.name, url: $A.mainUrl(data.url), url_type: data.url_type || 'inline', transparent: typeof data.transparent == 'boolean' ? data.transparent : false, @@ -4679,9 +4681,6 @@ export default { keep_alive: typeof data.keep_alive == 'boolean' ? data.keep_alive : true, props: $A.isJson(data.props) ? data.props : {}, } - if (!config.id) { - return - } if (!state.microAppsIds.includes(config.id)) { $A.modalWarning(`应用「${config.id}」未安装`); return; diff --git a/resources/assets/js/store/mutations.js b/resources/assets/js/store/mutations.js index 7a733b91f..768993e70 100644 --- a/resources/assets/js/store/mutations.js +++ b/resources/assets/js/store/mutations.js @@ -320,6 +320,16 @@ export default { menus.push(...item.menu_items.map(m => Object.assign(m, {id: item.id}))); } }) + menus.forEach(item => { + let name = item.id + if (menus.filter(m => m.id === item.id).length > 1) { + name += "_" + `${item.url}`.replace(/^https?:\/\/.*?\//, '').replace(/[^a-zA-Z0-9]/g, '_'); + } + if (menus.find(m => m.name === name)) { + name += "_" + $A.randomString(8) + } + item.name = name; + }) $A.IDBSave("microAppsIds", state.microAppsIds = ids); $A.IDBSave("microAppsMenus", state.microAppsMenus = menus); },