Merge remote-tracking branch 'origin/main' into lichang

This commit is contained in:
TsMask
2024-10-17 18:27:09 +08:00

View File

@@ -2,17 +2,16 @@
import { import {
defineAsyncComponent, defineAsyncComponent,
onMounted, onMounted,
ref,
shallowRef, shallowRef,
type Component, type Component,
} from 'vue'; } from 'vue';
import { getConfigKey, changeValue } from '@/api/system/config'; import { getConfigKey, changeValue } from '@/api/system/config';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const currentComponent = shallowRef<Component | null>( const currentComponent = shallowRef<Component | null>(null);
defineAsyncComponent(
() => import('@/views/configManage/neOverview/index.vue') const spinning = ref<boolean>(true);
)
);
/**匹配views里面所有的.vue或.tsx文件 */ /**匹配views里面所有的.vue或.tsx文件 */
const views = import.meta.glob('../views/**/*.{vue,tsx}') as Record< const views = import.meta.glob('../views/**/*.{vue,tsx}') as Record<
@@ -36,24 +35,43 @@ function findView(dirName: string): () => Promise<Component> {
return views[dir]; return views[dir];
} }
} }
return () => import('@/views/error/404.vue'); return () => import('@/views/configManage/neOverview/index.vue');
} }
onMounted(() => { onMounted(() => {
//获取当前系统设置的首页路径 //获取当前系统设置的首页路径
getConfigKey('sys.homePage').then(res => { getConfigKey('sys.homePage').then(res => {
spinning.value = false;
if (res.code === RESULT_CODE_SUCCESS && res.data) { if (res.code === RESULT_CODE_SUCCESS && res.data) {
console.log(spinning);
if (res.data) { if (res.data) {
const asyncComponent = findView(`${res.data}`); const asyncComponent = findView(`${res.data}`);
currentComponent.value = defineAsyncComponent(asyncComponent); currentComponent.value = defineAsyncComponent(asyncComponent);
} }
} else {
currentComponent.value = defineAsyncComponent(
() => import('@/views/configManage/neOverview/index.vue')
);
} }
}); });
}); });
</script> </script>
<template> <template>
<component :is="currentComponent" /> <a-spin
size="large"
:spinning="spinning"
style="
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
min-height: 362px;
"
>
<component :is="currentComponent" />
</a-spin>
</template> </template>
<style lang="less" scoped></style> <style lang="less" scoped></style>