feat: 添加点击消息打开微应用功能

This commit is contained in:
kuaifan 2025-12-02 06:29:45 +00:00
parent 4621222fa3
commit 4ef78d2c81
3 changed files with 53 additions and 10 deletions

View File

@ -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);
},
}
}
</script>

View File

@ -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)

View File

@ -1405,6 +1405,10 @@
}
}
.open-micro-app {
cursor: pointer;
}
.open-approve-details {
width: 280px;
display: inline-block;