|
|
@@ -3,16 +3,26 @@
|
|
|
<component :is="pageComponent"></component>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
- import { computed, defineAsyncComponent } from 'vue';
|
|
|
+ import { Component, ref, watch } from 'vue';
|
|
|
import { useMineDepartmentStore } from '/@/store/modules/mine';
|
|
|
+ import LeafPage from './components/LeafPage.vue';
|
|
|
+ import RootPage from './components/RootPage.vue';
|
|
|
+ import { Empty } from 'ant-design-vue';
|
|
|
|
|
|
const mineStore = useMineDepartmentStore();
|
|
|
|
|
|
- const pageComponent = computed(() => {
|
|
|
- if (mineStore.getRoot?.isLeaf) {
|
|
|
- return defineAsyncComponent(() => import('./components/LeafPage.vue'));
|
|
|
- } else {
|
|
|
- return defineAsyncComponent(() => import('./components/RootPage.vue'));
|
|
|
+ const pageComponent = ref<Component>(Empty);
|
|
|
+
|
|
|
+ watch(
|
|
|
+ () => mineStore.getDepart,
|
|
|
+ (n, o) => {
|
|
|
+ if (n?.isLeaf === o?.isLeaf) return;
|
|
|
+
|
|
|
+ if (n?.isLeaf) {
|
|
|
+ pageComponent.value = LeafPage;
|
|
|
+ } else {
|
|
|
+ pageComponent.value = RootPage;
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ );
|
|
|
</script>
|