fix: 定义锁屏类型

This commit is contained in:
TsMask
2024-01-18 10:11:15 +08:00
parent b445464192
commit 817712029b
4 changed files with 21 additions and 22 deletions

View File

@@ -8,6 +8,7 @@ import useLockedStore from '@/store/modules/locked';
import { getConfigKey } from '@/api/system/config';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { useRouter } from 'vue-router';
import { computed } from 'vue';
const lockedStore = useLockedStore();
const userStore = useUserStore();
const router = useRouter();
@@ -24,7 +25,7 @@ function resetTimeout() {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
lockedStore.fnLock('lock', true);
lockedStore.fnLock('lock');
}, timeoutDuration);
}
@@ -37,7 +38,7 @@ function handleUnlock() {
if (res.code === RESULT_CODE_SUCCESS) {
message.success(t('components.LockScreen.validSucc'), 3);
password.value = '';
lockedStore.fnLock('lock', false);
lockedStore.fnLock('none');
} else {
message.error(t('components.LockScreen.validError'), 3);
}
@@ -46,10 +47,12 @@ function handleUnlock() {
/**返回登录界面 */
function backLogin() {
lockedStore.fnLock('lock', false);
lockedStore.fnLock('none');
userStore.fnLogOut().finally(() => router.push({ name: 'Login' }));
}
const isLocked = computed(() => lockedStore.type !== 'none');
onMounted(() => {
getConfigKey('sys.lockTime')
.then(res => {
@@ -66,8 +69,8 @@ onMounted(() => {
window.addEventListener('keydown', resetTimeout);
}
// 本地锁定同时是登录状态
if (lockedStore.isLocked && getToken()) {
lockedStore.fnLock('lock', true);
if (lockedStore.type === 'lock' && getToken()) {
lockedStore.fnLock('lock');
}
});
});
@@ -81,7 +84,7 @@ onUnmounted(() => {
</script>
<template>
<a-modal
v-model:visible="lockedStore.isLocked"
v-model:visible="isLocked"
get-container="#app"
:footer="null"
:zIndex="1008"
@@ -99,7 +102,7 @@ onUnmounted(() => {
}"
>
<!-- 锁屏-登录 -->
<div class="lock-screen_login" v-if="lockedStore.lockType === 'lock'">
<div class="lock-screen_login" v-if="lockedStore.type === 'lock'">
<div class="lock-screen_login-user">
<a-avatar
shape="circle"
@@ -132,7 +135,7 @@ onUnmounted(() => {
</div>
<!-- 锁屏-OMC重启升级 -->
<div class="lock-screen_reload" v-if="lockedStore.lockType === 'reload'">
<div class="lock-screen_reload" v-if="lockedStore.type === 'reload'">
<LoadingOutlined style="font-size: 56px" />
<div class="text">
{{ t('components.LockScreen.backReload') }}