2024-11-07 16:35:04 +08:00
|
|
|
<template>
|
2024-11-21 11:25:50 +08:00
|
|
|
<NConfigProvider :date-locale="dateZhCN" :locale="zhCN" :theme="getDarkTheme" :theme-overrides="getThemeOverrides">
|
2024-11-07 16:35:04 +08:00
|
|
|
<AppProvider>
|
|
|
|
<RouterView v-if="!isLock" />
|
|
|
|
|
|
|
|
<transition v-if="isLock && $route.name !== 'login'" name="slide-up">
|
|
|
|
<LockScreen />
|
|
|
|
</transition>
|
|
|
|
</AppProvider>
|
2024-11-21 11:25:50 +08:00
|
|
|
<n-watermark v-if="getIsWaterMark" :content="proName" cross fullscreen :font-size="18" :line-height="16" :font-weight="500"
|
|
|
|
font-color="rgba(200, 200, 200, 0.40)" :width="284" :height="284" :x-offset="12" :y-offset="60" :rotate="-15" />
|
2024-11-07 16:35:04 +08:00
|
|
|
</NConfigProvider>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-11-21 11:25:50 +08:00
|
|
|
import { computed, onMounted, onUnmounted } from 'vue';
|
|
|
|
import { darkTheme, dateZhCN, zhCN } from 'naive-ui';
|
|
|
|
import { LockScreen } from '@/components/Lockscreen';
|
|
|
|
import { AppProvider } from '@/components/Application';
|
|
|
|
import { useLockscreenStore } from '@/store/modules/lockscreen';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
import { useDesignSettingStore } from '@/store/modules/designSetting';
|
|
|
|
import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
|
|
|
|
import { lighten } from '@/utils';
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
const route = useRoute();
|
|
|
|
const useLockscreen = useLockscreenStore();
|
|
|
|
const designStore = useDesignSettingStore();
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
const isLock = computed(() => useLockscreen.isLock);
|
|
|
|
const lockTime = computed(() => useLockscreen.lockTime);
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
const proName = import.meta.env.VITE_GLOB_APP_TITLE;
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
const { getIsWaterMark } = useProjectSetting();
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
/**
|
|
|
|
* @type import('naive-ui').GlobalThemeOverrides
|
|
|
|
*/
|
|
|
|
const getThemeOverrides = computed(() => {
|
|
|
|
const appTheme = designStore.appTheme;
|
|
|
|
const lightenStr = lighten(designStore.appTheme, 6);
|
|
|
|
return {
|
|
|
|
common: {
|
|
|
|
primaryColor: appTheme,
|
|
|
|
primaryColorSuppl: appTheme,
|
|
|
|
primaryColorHover: lightenStr,
|
|
|
|
primaryColorPressed: lightenStr,
|
|
|
|
},
|
|
|
|
LoadingBar: {
|
|
|
|
colorLoading: appTheme,
|
|
|
|
},
|
|
|
|
Layout: {
|
|
|
|
colorEmbedded: '#f5f7f9',
|
|
|
|
},
|
2024-11-07 16:35:04 +08:00
|
|
|
};
|
2024-11-21 11:25:50 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const getDarkTheme = computed(() => (designStore.darkTheme ? darkTheme : undefined));
|
|
|
|
|
|
|
|
let timer;
|
|
|
|
|
|
|
|
const timekeeping = () => {
|
|
|
|
clearInterval(timer);
|
|
|
|
if (route.name == 'login' || isLock.value) return;
|
|
|
|
// 设置不锁屏
|
|
|
|
useLockscreen.setLock(false);
|
|
|
|
// 重置锁屏时间
|
|
|
|
useLockscreen.setLockTime();
|
|
|
|
timer = setInterval(() => {
|
|
|
|
// 锁屏倒计时递减
|
|
|
|
useLockscreen.setLockTime(lockTime.value - 1);
|
|
|
|
if (lockTime.value <= 0) {
|
|
|
|
// 设置锁屏
|
|
|
|
useLockscreen.setLock(true);
|
|
|
|
return clearInterval(timer);
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
};
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
onMounted(() => {
|
|
|
|
// document.addEventListener('mousedown', timekeeping);
|
|
|
|
});
|
2024-11-07 16:35:04 +08:00
|
|
|
|
2024-11-21 11:25:50 +08:00
|
|
|
onUnmounted(() => {
|
|
|
|
// document.removeEventListener('mousedown', timekeeping);
|
|
|
|
});
|
2024-11-07 16:35:04 +08:00
|
|
|
</script>
|