From aef3e869dc2f035a8c236a4a24882a0f1f1bccbe Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 7 May 2025 18:12:58 +0800 Subject: [PATCH] no message --- .../assets/js/components/MicroApps/index.vue | 157 ++++++++++-------- resources/assets/js/store/actions.js | 14 +- 2 files changed, 96 insertions(+), 75 deletions(-) diff --git a/resources/assets/js/components/MicroApps/index.vue b/resources/assets/js/components/MicroApps/index.vue index e6e1b9516..5adc44b05 100644 --- a/resources/assets/js/components/MicroApps/index.vue +++ b/resources/assets/js/components/MicroApps/index.vue @@ -4,20 +4,20 @@ appName == e.detail.name); + const app = this.apps.find(({name}) => name == e.detail.name); if (app) { app.isLoading = false } @@ -189,7 +189,7 @@ export default { * @returns {*} */ appData(name) { - const app = this.apps.find(({appName}) => appName == name); + const app = this.apps.find(item => item.name == name); if (!app) { return {}; } @@ -205,61 +205,82 @@ export default { UserSelect, DatePicker, }, - options: { - shortcuts: $A.timeOptionShortcuts(), - } }, - initialData: { - ...app.initialData, + props: { + ...app.props, + + userId: this.userId, + userToken: this.userToken, + userInfo: this.userInfo, - systemInfo: window.systemInfo, baseUrl: $A.mainUrl(), + systemInfo: window.systemInfo, isEEUIApp: $A.isEEUIApp, isElectron: $A.isElectron, isMainElectron: $A.isMainElectron, isSubElectron: $A.isSubElectron, - languages: { - languageList, - languageName, - }, + languageList, + languageName, themeName: this.themeName, - - userInfo: this.userInfo, - userToken: this.userToken, }, - handleClose: (destroy = false) => { - this.closeMicroApp(name, destroy) - }, - - handleBack: async () => { - try { - this.$refs[`ref-${name}`][0].close() - } catch (e) { - this.closeMicroApp(name) - } - }, - - nextModalIndex: () => { - if (typeof window.modalTransferIndex === 'number') { - return window.modalTransferIndex++; - } - return 1000; - }, - - openAppChildPage: (objects) => { - this.$store.dispatch('openAppChildPage', objects); - }, - - openChildWindow: (params) => { - this.$store.dispatch('openChildWindow', params); - }, - - openWebTabWindow: (url) => { - this.$store.dispatch('openWebTabWindow', url); + methods: { + close: (destroy = false) => { + this.closeMicroApp(name, destroy) + }, + back: () => { + try { + this.$refs[`ref-${name}`][0].close() + } catch (e) { + this.closeMicroApp(name) + } + }, + nextZIndex: () => { + if (typeof window.modalTransferIndex === 'number') { + return window.modalTransferIndex++; + } + return 1000; + }, + openWindow: (params) => { + if (!$A.isJson(params)) { + params = {path: params} + } + if (params.url) { + params.path = params.url + delete params.url + } + this.$store.dispatch('openChildWindow', params); + }, + openTabWindow: (url) => { + this.$store.dispatch('openWebTabWindow', url); + }, + openAppPage: (params) => { + if (!$A.isJson(params)) { + params = {url: params} + } + this.$store.dispatch('openAppChildPage', { + pageType: 'app', + pageTitle: params.title || " ", + url: 'web.js', + params: { + url: params.url, + titleFixed: typeof params.titleFixed === 'boolean' ? params.titleFixed : false, + }, + }); + }, + extraCallA: (...args) => { + if (args.length > 0 && typeof args[0] === 'string') { + const methodName = args[0]; + const methodParams = args.slice(1); + if (typeof $A[methodName] === 'function') { + return $A[methodName](...methodParams); + } + } + return null; + }, }, } }, @@ -267,26 +288,26 @@ export default { /** * 打开微应用 * @param config - * - appName 微应用名称 - * - appUrl 微应用地址 - * - initialData 初始化数据 - * - transparent 是否透明模式 (true/false),默认 false - * - keepAlive 是否开启微应用保活 (true/false),默认 true + * - name 应用名称 + * - url 应用地址 + * - props 传递参数 + * - transparent 是否透明模式 (true/false),默认 false + * - keepAlive 是否开启微应用保活 (true/false),默认 true */ openMicroApp(config) { // 处理数据 - config.appName = config.appName || 'micro-app' - config.appUrl = config.appUrl || null - config.initialData = $A.isJson(config.initialData) ? config.initialData : {} + config.name = config.name || 'micro-app' + config.url = config.url || null + config.props = $A.isJson(config.props) ? config.props : {} config.transparent = typeof config.transparent == 'boolean' ? config.transparent : false config.keepAlive = typeof config.keepAlive == 'boolean' ? config.keepAlive : true // 判断处理 - const app = this.apps.find(({appName}) => appName == config.appName); + const app = this.apps.find(({name}) => name == config.name); if (app) { // 更新微应用 - if (app.appUrl != config.appUrl) { - microApp.unmountApp(app.appName, {destroy: true}) + if (app.url != config.url) { + microApp.unmountApp(app.name, {destroy: true}) app.isLoading = true } for (let key in config) { @@ -312,14 +333,14 @@ export default { * @param destroy */ closeMicroApp(name, destroy) { - const app = this.apps.find(({appName}) => appName == name); + const app = this.apps.find(item => item.name == name); if (!app) { return; } app.isOpen = false if (destroy) { - microApp.unmountApp(app.appName, {destroy: true}) + microApp.unmountApp(app.name, {destroy: true}) } }, diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 03a63967d..4555aa643 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -4670,10 +4670,10 @@ export default { if (/^\d+$/.test(value)) { // 打开详情页 emitter.emit('openMicroApp', { - appName: 'okr-details', - appUrl: `http://127.0.0.1:5567/apps/okr/`, - // appUrl: $A.mainUrl('apps/okr/'), - initialData: { + name: 'okr-details', + url: `http://127.0.0.1:5567/apps/okr/`, + // url: $A.mainUrl('apps/okr/'), + props: { type: 'details', id: value, }, @@ -4682,9 +4682,9 @@ export default { } else { // 打开列表、统计 emitter.emit('openMicroApp', { - appName: `okr-${value}`, - appUrl: `http://127.0.0.1:5567/apps/okr/${value}`, - // appUrl: $A.mainUrl(`apps/okr/${value}`), + name: `okr-${value}`, + url: `http://127.0.0.1:5567/apps/okr/${value}`, + // url: $A.mainUrl(`apps/okr/${value}`), }); } },