2023-06-13 21:05:25 +08:00
|
|
|
<script lang="ts" name="APP" setup>
|
2023-02-11 00:44:00 +08:00
|
|
|
import { isDark } from '@/utils/is'
|
|
|
|
import { useAppStore } from '@/store/modules/app'
|
|
|
|
import { useDesign } from '@/hooks/web/useDesign'
|
|
|
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
2023-05-29 11:26:51 +08:00
|
|
|
import routerSearch from '@/components/RouterSearch/index.vue'
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
|
|
const { getPrefixCls } = useDesign()
|
|
|
|
const prefixCls = getPrefixCls('app')
|
|
|
|
const appStore = useAppStore()
|
|
|
|
const currentSize = computed(() => appStore.getCurrentSize)
|
|
|
|
const greyMode = computed(() => appStore.getGreyMode)
|
|
|
|
const { wsCache } = useCache()
|
|
|
|
|
|
|
|
// 根据浏览器当前主题设置系统主题色
|
|
|
|
const setDefaultTheme = () => {
|
|
|
|
let isDarkTheme = wsCache.get(CACHE_KEY.IS_DARK)
|
|
|
|
if (isDarkTheme === null) {
|
|
|
|
isDarkTheme = isDark()
|
|
|
|
}
|
|
|
|
appStore.setIsDark(isDarkTheme)
|
|
|
|
}
|
|
|
|
setDefaultTheme()
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<ConfigGlobal :size="currentSize">
|
|
|
|
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
|
2023-05-29 11:26:51 +08:00
|
|
|
<routerSearch />
|
2023-02-11 00:44:00 +08:00
|
|
|
</ConfigGlobal>
|
|
|
|
</template>
|
|
|
|
<style lang="scss">
|
|
|
|
$prefix-cls: #{$namespace}-app;
|
2023-05-29 11:26:51 +08:00
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
.size {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2023-06-13 21:05:25 +08:00
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
html,
|
|
|
|
body {
|
2023-06-21 19:26:14 +08:00
|
|
|
@extend .size;
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
padding: 0 !important;
|
|
|
|
margin: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
#app {
|
|
|
|
@extend .size;
|
|
|
|
}
|
|
|
|
}
|
2023-06-13 21:05:25 +08:00
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
.#{$prefix-cls}-grey-mode {
|
|
|
|
filter: grayscale(100%);
|
|
|
|
}
|
|
|
|
</style>
|