2022-07-18 19:06:37 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed } from 'vue'
|
|
|
|
import { isDark } from '@/utils/is'
|
2022-11-22 22:03:02 +08:00
|
|
|
import { useAppStore } from '@/store/modules/app'
|
2022-07-18 19:06:37 +08:00
|
|
|
import { useDesign } from '@/hooks/web/useDesign'
|
2022-11-22 22:03:02 +08:00
|
|
|
import { ConfigGlobal } from '@/components/ConfigGlobal'
|
2022-11-23 16:34:09 +08:00
|
|
|
import { useCache } from '@/hooks/web/useCache'
|
2022-07-18 19:06:37 +08:00
|
|
|
|
|
|
|
const { getPrefixCls } = useDesign()
|
|
|
|
const prefixCls = getPrefixCls('app')
|
|
|
|
const appStore = useAppStore()
|
|
|
|
const currentSize = computed(() => appStore.getCurrentSize)
|
|
|
|
const greyMode = computed(() => appStore.getGreyMode)
|
2022-11-23 16:34:09 +08:00
|
|
|
const { wsCache } = useCache()
|
2022-07-18 19:06:37 +08:00
|
|
|
|
|
|
|
// 根据浏览器当前主题设置系统主题色
|
|
|
|
const setDefaultTheme = () => {
|
2022-11-23 16:34:09 +08:00
|
|
|
if (wsCache.get('isDark')) {
|
|
|
|
if (wsCache.get('isDark') || wsCache.get('isDark') === 'true') {
|
2022-10-28 09:28:20 +08:00
|
|
|
appStore.setIsDark(true)
|
|
|
|
} else {
|
|
|
|
appStore.setIsDark(false)
|
|
|
|
}
|
2022-07-18 19:06:37 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
const isDarkTheme = isDark()
|
|
|
|
appStore.setIsDark(isDarkTheme)
|
|
|
|
}
|
|
|
|
setDefaultTheme()
|
|
|
|
</script>
|
2022-11-23 16:34:09 +08:00
|
|
|
<template>
|
|
|
|
<ConfigGlobal :size="currentSize">
|
|
|
|
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
|
|
|
|
</ConfigGlobal>
|
|
|
|
</template>
|
2022-11-23 15:18:59 +08:00
|
|
|
<style lang="scss">
|
|
|
|
$prefix-cls: #{$namespace}-app;
|
2022-07-18 19:06:37 +08:00
|
|
|
.size {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
html,
|
|
|
|
body {
|
|
|
|
padding: 0 !important;
|
|
|
|
margin: 0;
|
|
|
|
overflow: hidden;
|
2022-11-23 15:18:59 +08:00
|
|
|
@extend .size;
|
2022-07-18 19:06:37 +08:00
|
|
|
|
|
|
|
#app {
|
2022-11-23 15:18:59 +08:00
|
|
|
@extend .size;
|
2022-07-18 19:06:37 +08:00
|
|
|
}
|
|
|
|
}
|
2022-11-23 15:18:59 +08:00
|
|
|
.#{$prefix-cls}-grey-mode {
|
2022-07-18 19:06:37 +08:00
|
|
|
filter: grayscale(100%);
|
|
|
|
}
|
|
|
|
</style>
|