diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index e7da4b850..aff175e94 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -3639,17 +3639,24 @@ export default { return } - // 打开审批详情 - let approveElement = target; - while (approveElement) { - if (approveElement.classList.contains('dialog-scroller')) { + // 打开微应用 / 审批详情 + let clickElement = target; + while (clickElement) { + if (!clickElement.classList) { break; } - if (approveElement.classList.contains('open-approve-details')) { - emitter.emit('approveDetails', approveElement.getAttribute("data-id")); + if (clickElement.classList.contains('dialog-head')) { + break; + } + if (clickElement.classList.contains('open-micro-app')) { + this.handleOpenMicroApp(clickElement); return; } - approveElement = approveElement.parentElement; + if (clickElement.classList.contains('open-approve-details')) { + emitter.emit('approveDetails', clickElement.getAttribute("data-id")); + return; + } + clickElement = clickElement.parentElement; } switch (target.nodeName) { @@ -4420,7 +4427,35 @@ export default { this.sendMsg(msgText, sendType); } }); - } + }, + + handleOpenMicroApp(element) { + const dataset = element && element.dataset ? element.dataset : {}; + const normalizeKey = key => { + const name = key.replace(/^app/, ''); + return name.replace(/^[A-Z]/, m => m.toLowerCase()).replace(/([A-Z])/g, '_$1').toLowerCase(); + }; + let config = $A.jsonParse(dataset.appConfig); + Object.entries(dataset).forEach(([key, value]) => { + if (!key.startsWith('app') || key === 'appConfig') { + return; + } + if (value === '' || typeof value === 'undefined') { + return; + } + const normalizedKey = normalizeKey(key); + if (normalizedKey === 'props') { + config.props = Object.assign(config.props || {}, $A.jsonParse(value)); + return; + } + if (value === 'true' || value === 'false') { + config[normalizedKey] = /true/i.test(value); + } else { + config[normalizedKey] = value; + } + }); + this.$store.dispatch("openMicroApp", config); + }, } } diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index b1a04f6df..2a55881a8 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -5109,8 +5109,12 @@ export default { props: $A.isJson(data.props) ? data.props : {}, } if (!state.microAppsIds.includes(config.id)) { - $A.modalWarning(`应用「${config.id}」未安装`); - return; + const matchedId = state.microAppsIds.find(item => typeof item === 'string' && item.endsWith(config.id)) + if (!matchedId) { + $A.modalWarning(`应用「${config.id}」未安装`); + return; + } + config.id = matchedId; } config.url = config.url .replace(/\{user_id}/g, state.userId) diff --git a/resources/assets/sass/pages/components/dialog-wrapper.scss b/resources/assets/sass/pages/components/dialog-wrapper.scss index 3029df198..468e8ef40 100644 --- a/resources/assets/sass/pages/components/dialog-wrapper.scss +++ b/resources/assets/sass/pages/components/dialog-wrapper.scss @@ -1405,6 +1405,10 @@ } } + .open-micro-app { + cursor: pointer; + } + .open-approve-details { width: 280px; display: inline-block;