App.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script setup lang="ts">
  2. import { computed } from 'vue'
  3. import { useAppStore } from '@/store/modules/app'
  4. import { ConfigGlobal } from '@/components/ConfigGlobal'
  5. import { isDark } from '@/utils/is'
  6. import { useDesign } from '@/hooks/web/useDesign'
  7. import { useCache } from '@/hooks/web/useCache'
  8. const { getPrefixCls } = useDesign()
  9. const prefixCls = getPrefixCls('app')
  10. const appStore = useAppStore()
  11. const currentSize = computed(() => appStore.getCurrentSize)
  12. const greyMode = computed(() => appStore.getGreyMode)
  13. const { wsCache } = useCache()
  14. // 根据浏览器当前主题设置系统主题色
  15. const setDefaultTheme = () => {
  16. if (wsCache.get('isDark') !== null) {
  17. appStore.setIsDark(wsCache.get('isDark'))
  18. return
  19. }
  20. const isDarkTheme = isDark()
  21. appStore.setIsDark(isDarkTheme)
  22. }
  23. setDefaultTheme()
  24. </script>
  25. <template>
  26. <ConfigGlobal :size="currentSize">
  27. <RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
  28. </ConfigGlobal>
  29. </template>
  30. <style lang="less">
  31. @prefix-cls: ~'@{namespace}-app';
  32. .size {
  33. width: 100%;
  34. height: 100%;
  35. }
  36. html,
  37. body {
  38. padding: 0 !important;
  39. margin: 0;
  40. overflow: hidden;
  41. .size;
  42. #app {
  43. .size;
  44. }
  45. }
  46. .@{prefix-cls}-grey-mode {
  47. filter: grayscale(100%);
  48. }
  49. </style>