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 { return {
showSpin: false, showSpin: false,
loading: false, loading: false,
appUrl: '',
appData: {}, appData: {},
} }
}, },
deactivated() {
},
mounted() { mounted() {
this.showSpin = true; this.showSpin = true;
this.appData = this.getAppData this.appData = this.getAppData
console.log(this.url)
}, },
watch: { watch: {
loading(val){ loading(val){
@ -72,17 +71,6 @@ export default {
this.showSpin = true; 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) { path(val) {
this.appData = { path: val } this.appData = { path: val }
}, },
@ -166,7 +154,7 @@ export default {
window.dispatchEvent(new Event('apps-unmount')); window.dispatchEvent(new Event('apps-unmount'));
}, },
handleError(e) { handleError(e) {
console.error("子应用加载出错了",e.detail.error) // console.error("",e.detail.error)
}, },
handleDataChange(e) { handleDataChange(e) {
// console.log(' child-vite :', e.detail.data) // console.log(' child-vite :', e.detail.data)

View File

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

View File

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