indexAsync.vue
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-09-04 14:38:02
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-09-04 18:11:57
* @FilePath: \Apper-Admin-master\src\layouts\indexAsync.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 💥 这里是异步加载 LayoutComponents -->
<template>
<el-watermark id="watermark" :font="font" :content="watermark ? ['Happy Working'] : ''">
<suspense>
<template #default>
<component :is="LayoutComponents[layout]" />
</template>
<template #fallback>
<Loading />
</template>
</suspense>
<ThemeDrawer />
</el-watermark>
</template>
<script setup lang="ts" name="layoutAsync">
import { computed, defineAsyncComponent, reactive, watch, type Component } from "vue";
import { LayoutType } from "@/stores/interface";
import { useGlobalStore } from "@/stores/modules/global";
import Loading from "@/components/Loading/index.vue";
import ThemeDrawer from "./components/ThemeDrawer/index.vue";
const LayoutComponents: Record<LayoutType, Component> = {
vertical: defineAsyncComponent(() => import("./LayoutVertical/index.vue")),
classic: defineAsyncComponent(() => import("./LayoutClassic/index.vue")),
transverse: defineAsyncComponent(() => import("./LayoutTransverse/index.vue")),
columns: defineAsyncComponent(() => import("./LayoutColumns/index.vue"))
};
const globalStore = useGlobalStore();
const isDark = computed(() => globalStore.isDark);
const layout = computed(() => globalStore.layout);
const watermark = computed(() => globalStore.watermark);
const font = reactive({ color: "rgba(0, 0, 0, .15)" });
watch(isDark, () => (font.color = isDark.value ? "rgba(255, 255, 255, .15)" : "rgba(0, 0, 0, .15)"), {
immediate: true
});
</script>
<style scoped lang="scss">
.layout {
min-width: 600px;
}
</style>