gohttpdUi/src/App.vue

64 lines
1.2 KiB
Vue
Raw Normal View History

2021-12-08 10:47:33 +08:00
<script setup lang="ts">
import { computed } from 'vue'
2021-12-31 17:19:53 +08:00
import { useAppStore } from '@/store/modules/app'
import { ConfigGlobal } from '@/components/ConfigGlobal'
2021-12-31 17:19:53 +08:00
import { isDark } from '@/utils/is'
import { useDesign } from '@/hooks/web/useDesign'
2023-08-05 08:42:14 +08:00
import { useStorage } from '@/hooks/web/useStorage'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('app')
2021-12-31 17:19:53 +08:00
const appStore = useAppStore()
2022-01-18 16:22:47 +08:00
const currentSize = computed(() => appStore.getCurrentSize)
const greyMode = computed(() => appStore.getGreyMode)
2023-08-05 08:42:14 +08:00
const { getStorage } = useStorage()
2022-05-10 16:11:48 +08:00
// 根据浏览器当前主题设置系统主题色
const setDefaultTheme = () => {
2023-08-05 08:42:14 +08:00
if (getStorage('isDark') !== null) {
appStore.setIsDark(getStorage('isDark'))
2022-05-10 16:11:48 +08:00
return
}
2021-12-31 17:19:53 +08:00
const isDarkTheme = isDark()
appStore.setIsDark(isDarkTheme)
}
2022-01-03 18:01:43 +08:00
setDefaultTheme()
2021-12-08 10:47:33 +08:00
</script>
<template>
2022-01-18 16:22:47 +08:00
<ConfigGlobal :size="currentSize">
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
</ConfigGlobal>
</template>
2021-12-31 17:19:53 +08:00
<style lang="less">
@prefix-cls: ~'@{namespace}-app';
2022-01-18 16:22:47 +08:00
2021-12-31 17:19:53 +08:00
.size {
width: 100%;
height: 100%;
}
html,
body {
2022-01-21 16:17:40 +08:00
padding: 0 !important;
2021-12-31 17:19:53 +08:00
margin: 0;
2022-01-13 17:26:06 +08:00
overflow: hidden;
2021-12-31 17:19:53 +08:00
.size;
#app {
.size;
}
}
2022-01-18 16:22:47 +08:00
.@{prefix-cls}-grey-mode {
2022-01-18 16:22:47 +08:00
filter: grayscale(100%);
}
2021-12-31 17:19:53 +08:00
</style>