no message

This commit is contained in:
kuaifan 2025-05-26 20:54:06 +08:00
parent ca353d747b
commit 2af1dba8dc
4 changed files with 16 additions and 29 deletions

View File

@ -309,33 +309,11 @@ export default {
}
},
/**
* 生成微应用名称
* @param config
* @returns {Promise<string>}
*/
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

View File

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

View File

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

View File

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