perf: 微应用优化

This commit is contained in:
weifashi 2023-12-15 11:20:51 +08:00
parent 2813f4c062
commit a55e0a457d
3 changed files with 7 additions and 32 deletions

View File

@ -56,15 +56,14 @@ export default {
return {
showSpin: false,
loading: false,
appUrl: '',
appData: {},
}
},
deactivated() {
},
mounted() {
this.showSpin = true;
this.appData = this.getAppData
console.log(this.url)
},
watch: {
loading(val){
@ -72,17 +71,6 @@ export default {
this.showSpin = true;
}
},
url(val) {
this.loading = true;
this.$nextTick(() => {
this.loading = false;
let url = $A.apiUrl(val)
if (url.indexOf('http') == -1) {
url = window.location.origin + url
}
this.appUrl = import.meta.env.VITE_OKR_WEB_URL || url
})
},
path(val) {
this.appData = { path: val }
},
@ -166,7 +154,7 @@ export default {
window.dispatchEvent(new Event('apps-unmount'));
},
handleError(e) {
console.error("子应用加载出错了",e.detail.error)
// console.error("",e.detail.error)
},
handleDataChange(e) {
// console.log(' child-vite :', e.detail.data)

View File

@ -1,9 +1,5 @@
import microApp from '@micro-zoe/micro-app'
const getUrl = (url) => {
return import.meta.env.VITE_OKR_WEB_URL || $A.apiUrl(url);
}
export default function() {
let urls = "";
let route = "/";
@ -24,24 +20,15 @@ export default function() {
return code
}
}
// 微应用名称
modules["micro-app"] = [obj]
modules["okr-details"] = [obj]
// 微应用
microApp.start({
plugins: {
modules: modules
}
})
//预加载
microApp.preFetch([
{
name: 'micro-app',
url: getUrl("../apps/okr"),
disableSandbox: true
}
])
}
}

View File

@ -580,7 +580,7 @@ export default {
$A.modalError({
content: msg,
onOk: _ => {
this.$refs.code.focus()
this.$refs.code?.focus()
}
})
}