| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <script lang="ts" setup>
- 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'
- import routerSearch from '@/components/RouterSearch/index.vue'
- import { useAutoLogout } from './composable/useAutoLogout'
- const route = useRoute()
- const { addListeners, removeListeners } = useAutoLogout()
- const whiteList = [
- '/login',
- '/social-login',
- '/auth-redirect',
- '/bind',
- '/register',
- '/oauthLogin/gitee',
- '/dingding',
- '/deepoil'
- ]
- watch(
- () => route.path,
- (newPath) => {
- if (whiteList.includes(newPath)) {
- console.log('进入白名单页面,移除超时检测')
- removeListeners()
- } else {
- console.log('进入受控页面,开启超时检测')
- addListeners()
- }
- },
- { immediate: true } // 初始化时立即执行一次
- )
- defineOptions({ name: 'APP' })
- 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` : ''" />
- <routerSearch />
- </ConfigGlobal>
- </template>
- <style lang="scss">
- $prefix-cls: #{$namespace}-app;
- .size {
- width: 100%;
- height: 100%;
- }
- html,
- body {
- @extend .size;
- padding: 0 !important;
- margin: 0;
- overflow: hidden;
- #app {
- @extend .size;
- }
- }
- .#{$prefix-cls}-grey-mode {
- filter: grayscale(100%);
- }
- </style>
|