index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!-- 💥 这里是一次性加载 LayoutComponents -->
  2. <template>
  3. <el-watermark id="watermark" :font="font" :content="watermark ? ['Geeker Admin', 'Happy Working'] : ''">
  4. <component :is="LayoutComponents[layout]" />
  5. <ThemeDrawer />
  6. </el-watermark>
  7. </template>
  8. <script setup lang="ts" name="layout">
  9. import { computed, reactive, watch, type Component } from "vue";
  10. import { LayoutType } from "@/stores/interface";
  11. import { useGlobalStore } from "@/stores/modules/global";
  12. import ThemeDrawer from "./components/ThemeDrawer/index.vue";
  13. import LayoutVertical from "./LayoutVertical/index.vue";
  14. import LayoutClassic from "./LayoutClassic/index.vue";
  15. import LayoutTransverse from "./LayoutTransverse/index.vue";
  16. import LayoutColumns from "./LayoutColumns/index.vue";
  17. const LayoutComponents: Record<LayoutType, Component> = {
  18. vertical: LayoutVertical,
  19. classic: LayoutClassic,
  20. transverse: LayoutTransverse,
  21. columns: LayoutColumns
  22. };
  23. const globalStore = useGlobalStore();
  24. const isDark = computed(() => globalStore.isDark);
  25. const layout = computed(() => globalStore.layout);
  26. const watermark = computed(() => globalStore.watermark);
  27. const font = reactive({ color: "rgba(0, 0, 0, .15)" });
  28. watch(isDark, () => (font.color = isDark.value ? "rgba(255, 255, 255, .15)" : "rgba(0, 0, 0, .15)"), {
  29. immediate: true
  30. });
  31. </script>
  32. <style scoped lang="scss">
  33. .layout {
  34. min-width: 600px;
  35. }
  36. </style>