wms-elevue/src/App.vue
2024-12-19 10:24:08 +08:00

77 lines
2.1 KiB
Vue

<template>
<el-config-provider size="default" :zIndex="zIndex">
<AppProvider>
<RouterView v-if="!isLock" />
<transition v-if="isLock && $route.name !== LoginName" name="slide-up">
<LockScreen />
</transition>
</AppProvider>
</el-config-provider>
</template>
<script lang="ts" setup>
import { computed, onMounted, onUnmounted, ref } from 'vue';
import { ElConfigProvider, ElNotification } from 'element-plus';
import { LockScreen } from '@/components/Lockscreen';
import { AppProvider } from '@/components/Application';
import { useLockscreenStore } from '@/store/modules/lockscreen';
import { useRoute } from 'vue-router';
import { PageEnum } from '@/enums/pageEnum';
import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
import Watermark from '@/utils/wartermark';
/**
* 定义参数
*/
const route = useRoute();
const useLockscreen = useLockscreenStore();
const isLock = computed(() => useLockscreen.isLock);
const lockTime = computed(() => useLockscreen.lockTime);
const zIndex = ref(3000);
const { getIsWaterMark } = useProjectSetting();
const LoginName = PageEnum.BASE_LOGIN_NAME;
let timer;
/**
* 定义锁屏
*/
const timekeeping = () => {
clearInterval(timer);
if (route.name === LoginName || 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);
};
/**
* 钩子函数
*/
onMounted(() => {
if (getIsWaterMark.value) {
const waterText = import.meta.env.VITE_GLOB_APP_TITLE;
Watermark.set(waterText);
} else {
Watermark.del();
}
});
onUnmounted(() => {
// document.removeEventListener('mousedown', timekeeping);
});
</script>
<style lang="scss">
#nprogress .bar {
background: var(--el-color-primary);
}
</style>