no message

This commit is contained in:
kuaifan 2025-05-17 22:46:10 +08:00
parent b2d9568deb
commit 79defdc3f3
2 changed files with 49 additions and 59 deletions

View File

@ -327,46 +327,23 @@ export default {
/** /**
* 观察打开微应用 * 观察打开微应用
* @param config * @param config
* - name 应用名称
* - url 应用地址
* - props 传递参数
* - transparent 是否透明模式 (true/false)默认 false
* - autoDarkTheme 是否自动适配深色主题 (true/false)默认 true
* - keepAlive 是否开启微应用保活 (true/false)默认 true
* - disableScopecss 是否禁用样式隔离 (true/false)默认 false
*/ */
observeMicroApp(config) { async observeMicroApp(config) {
//
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.autoDarkTheme = typeof config.autoDarkTheme == 'boolean' ? config.autoDarkTheme : true
config.keepAlive = typeof config.keepAlive == 'boolean' ? config.keepAlive : true
config.disableScopecss = typeof config.disableScopecss == 'boolean' ? config.disableScopecss : false
//
const app = this.apps.find(({name}) => name == config.name); const app = this.apps.find(({name}) => name == config.name);
if (app) { if (app) {
// //
if (app.url != config.url) { if (app.url != config.url) {
microApp.unmountApp(app.name, {destroy: true}) await microApp.unmountApp(app.name, {destroy: true})
app.isLoading = true app.isLoading = true
} }
for (let key in config) { Object.assign(app, config)
app[key] = config[key] this.$nextTick(_ => app.isOpen = true)
}
this.$nextTick(_ => {
app.isOpen = true
})
} else { } else {
// //
config.isLoading = true config.isLoading = true
config.isOpen = false config.isOpen = false
this.apps.push(config) this.apps.push(config)
this.$nextTick(_ => { this.$nextTick(_ => config.isOpen = true)
config.isOpen = true
})
} }
}, },

View File

@ -4641,46 +4641,45 @@ export default {
/** ************************************ App Store ******************************************/ /** ************************************ App Store ******************************************/
/** *****************************************************************************************/ /** *****************************************************************************************/
/**
* 更新微应用状态已安装应用菜单项
* @param commit
* @param dispatch
*/
updateMicroAppsStatus({commit, dispatch}) {
dispatch("call", {
url: 'apps/status',
}).then(({data}) => {
commit("microApps/installed", data.installed)
commit("microApps/menu", data.menus)
})
},
/** /**
* 打开微应用 * 打开微应用
* @param state * @param state
* @param menuItem * @param data
* - name 应用名称
* - url 应用地址
* - props 传递参数
* - transparent 是否透明模式 (true/false)默认 false
* - autoDarkTheme 是否自动适配深色主题 (true/false)默认 true
* - keepAlive 是否开启微应用保活 (true/false)默认 true
* - disableScopecss 是否禁用样式隔离 (true/false)默认 false
*/ */
openMicroApp({state}, menuItem) { openMicroApp({state}, data) {
if (!menuItem || !$A.isJson(menuItem)) { if (!data || !$A.isJson(data)) {
return return
} }
const event = { if (!data.url) {
name: menuItem.app_name || menuItem.name, return
url: $A.mainUrl(menuItem.url),
} }
if (!state.microAppsInstalled.includes(event.name)) { const config = {
$A.modalWarning("应用未安装"); name: data.app_name || data.name,
url: $A.mainUrl(data.url),
props: $A.isJson(data.props) ? data.props : {},
transparent: typeof data.transparent == 'boolean' ? data.transparent : false,
autoDarkTheme: typeof data.autoDarkTheme == 'boolean' ? data.autoDarkTheme : true,
keepAlive: typeof data.keepAlive == 'boolean' ? data.keepAlive : true,
disableScopecss: typeof data.disableScopecss == 'boolean' ? data.disableScopecss : false
}
if (!config.name) {
return
}
if (!state.microAppsInstalled.includes(config.name)) {
$A.modalWarning(`应用「${config.name}」未安装`);
return; return;
} }
if (menuItem.key) { if (data.key) {
event.name += `_${menuItem.key}` config.name += `_${data.key}`
} }
for (let key in menuItem) { emitter.emit('observeMicroApp:open', config);
if (['transparent', 'autoDarkTheme', 'keepAlive', 'disableScopecss'].includes(key)) {
event[key] = menuItem[key]
}
}
emitter.emit('observeMicroApp:open', event);
}, },
/** /**
@ -4697,5 +4696,19 @@ export default {
} }
resolve(!!state.microAppsInstalled.includes(appName)) resolve(!!state.microAppsInstalled.includes(appName))
}) })
} },
/**
* 更新微应用状态已安装应用菜单项
* @param commit
* @param dispatch
*/
updateMicroAppsStatus({commit, dispatch}) {
dispatch("call", {
url: 'apps/status',
}).then(({data}) => {
commit("microApps/installed", data.installed)
commit("microApps/menu", data.menus)
})
},
} }