mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
no message
This commit is contained in:
parent
f53a5ea6c1
commit
1c5b856800
@ -2065,3 +2065,5 @@ AI开启新会话失败
|
||||
|
||||
按工作流
|
||||
按状态
|
||||
|
||||
应用加载失败
|
||||
|
||||
@ -21,18 +21,24 @@
|
||||
modal-class="micro-app-modal"
|
||||
drawer-class="micro-app-drawer"
|
||||
placement="right"
|
||||
:beforeClose="onBeforeClose"
|
||||
:size="1200">
|
||||
<micro-app
|
||||
v-if="appConfig.isOpen"
|
||||
:name="appConfig.appName"
|
||||
:url="appConfig.appUrl"
|
||||
:keep-alive="appConfig.keepAlive"
|
||||
:data="appData"
|
||||
@created="created"
|
||||
@beforemount="beforemount"
|
||||
@mounted="mounted"
|
||||
@unmount="unmount"
|
||||
@error="error"/>
|
||||
<template>
|
||||
<micro-app
|
||||
v-if="appConfig.isOpen"
|
||||
:name="appConfig.appName"
|
||||
:url="appConfig.appUrl"
|
||||
:keep-alive="appConfig.keepAlive"
|
||||
:data="appData"
|
||||
@created="created"
|
||||
@beforemount="beforemount"
|
||||
@mounted="mounted"
|
||||
@unmount="unmount"
|
||||
@error="error"/>
|
||||
<div v-if="loadIng > 0" class="micro-app-loading">
|
||||
<Loading/>
|
||||
</div>
|
||||
</template>
|
||||
</DrawerOverlay>
|
||||
</template>
|
||||
|
||||
@ -48,6 +54,17 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.micro-app-loading {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
@ -72,6 +89,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
loadIng: 0,
|
||||
appConfig: {},
|
||||
}
|
||||
},
|
||||
@ -90,10 +108,8 @@ export default {
|
||||
},
|
||||
|
||||
watch: {
|
||||
userToken(val) {
|
||||
if (!val) {
|
||||
microApp.unmountAllApps({destroy: true})
|
||||
}
|
||||
userToken(token) {
|
||||
!token && microApp.unmountAllApps({destroy: true})
|
||||
},
|
||||
},
|
||||
|
||||
@ -104,8 +120,6 @@ export default {
|
||||
]),
|
||||
|
||||
appData() {
|
||||
const {initialData, appName} = this.appConfig;
|
||||
|
||||
return {
|
||||
instance: {
|
||||
Vue,
|
||||
@ -121,7 +135,7 @@ export default {
|
||||
},
|
||||
|
||||
initialData: {
|
||||
...initialData,
|
||||
...this.appConfig.initialData,
|
||||
|
||||
systemInfo: window.systemInfo,
|
||||
baseUrl: $A.mainUrl(),
|
||||
@ -142,10 +156,7 @@ export default {
|
||||
},
|
||||
|
||||
handleClose: (destroy = false) => {
|
||||
this.appConfig.appName === appName && (this.appConfig.isOpen = false);
|
||||
if (destroy) {
|
||||
microApp.unmountApp(appName, {destroy: true})
|
||||
}
|
||||
this.closeMicroApp(destroy)
|
||||
},
|
||||
|
||||
nextModalIndex: () => {
|
||||
@ -172,22 +183,16 @@ export default {
|
||||
methods: {
|
||||
// 元素被创建
|
||||
created(e) {
|
||||
const item = appMaps.get(e.detail.name)
|
||||
if (item?.isLoading) {
|
||||
this.$store.dispatch('showSpinner');
|
||||
}
|
||||
this.stateChange(e)
|
||||
},
|
||||
|
||||
// 即将渲染
|
||||
beforemount(e) {
|
||||
const item = appMaps.get(e.detail.name)
|
||||
if (item?.isLoading) {
|
||||
this.$store.dispatch('hiddenSpinner');
|
||||
}
|
||||
beforemount() {
|
||||
},
|
||||
|
||||
// 已经渲染完成
|
||||
mounted() {
|
||||
mounted(e) {
|
||||
this.stateChange(e, true)
|
||||
},
|
||||
|
||||
// 已经卸载
|
||||
@ -195,16 +200,45 @@ export default {
|
||||
},
|
||||
|
||||
// 加载出错
|
||||
error() {
|
||||
error(e) {
|
||||
this.stateChange(e, true)
|
||||
$A.modalError({
|
||||
language: false,
|
||||
title: this.$L('应用加载失败'),
|
||||
content: e.detail.error,
|
||||
onOk: () => {
|
||||
this.closeMicroApp(true)
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 加载状态变化
|
||||
stateChange(e, end = false) {
|
||||
const appConfig = appMaps.get(e.detail.name)
|
||||
if (appConfig?.isLoading) {
|
||||
if (end) {
|
||||
if (appConfig.transparent) {
|
||||
this.$store.dispatch('hiddenSpinner');
|
||||
} else {
|
||||
this.loadIng--;
|
||||
}
|
||||
} else {
|
||||
if (appConfig.transparent) {
|
||||
this.$store.dispatch('showSpinner');
|
||||
} else {
|
||||
this.loadIng++;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 打开微应用
|
||||
* @param config
|
||||
* @param appConfig
|
||||
*/
|
||||
openMicroApp(config) {
|
||||
openMicroApp(appConfig) {
|
||||
// 处理数据
|
||||
config = Object.assign({
|
||||
appConfig = Object.assign({
|
||||
appName: 'micro-app', // 微应用唯一标识名称
|
||||
appUrl: null, // 微应用的入口URL地址
|
||||
initialData: {}, // 初始化时传递给微应用的数据对象
|
||||
@ -214,26 +248,47 @@ export default {
|
||||
|
||||
isLoading: true, // 私有参数,是否显示加载状态(true/false)
|
||||
isOpen: false, // 私有参数,是否打开微应用(true/false)
|
||||
}, config);
|
||||
}, appConfig);
|
||||
|
||||
// 判断卸载上次
|
||||
const lastApp = appMaps.get(config.appName)
|
||||
if (lastApp) {
|
||||
if (lastApp.displayMode != config.displayMode || lastApp.appUrl != config.appUrl) {
|
||||
microApp.unmountApp(config.appName, {destroy: true})
|
||||
// 判断处理
|
||||
const lastConfig = appMaps.get(appConfig.appName)
|
||||
if (lastConfig) {
|
||||
if (lastConfig.displayMode != appConfig.displayMode || lastConfig.appUrl != appConfig.appUrl) {
|
||||
microApp.unmountApp(appConfig.appName, {destroy: true})
|
||||
} else {
|
||||
config.isLoading = false;
|
||||
appConfig.isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
appMaps.set(config.appName, this.appConfig = config);
|
||||
appMaps.set(appConfig.appName, this.appConfig = appConfig);
|
||||
|
||||
// 打开微应用
|
||||
this.$nextTick(_ => {
|
||||
this.appConfig.isOpen = true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 关闭微应用
|
||||
* @param destroy
|
||||
*/
|
||||
closeMicroApp(destroy) {
|
||||
this.appConfig.isOpen = false
|
||||
if (destroy) {
|
||||
microApp.unmountApp(this.appConfig.appName, {destroy: true})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 关闭之前判断
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
onBeforeClose() {
|
||||
return new Promise(resolve => {
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user