diff --git a/src/components/LockScreen/index.vue b/src/components/LockScreen/index.vue index 77dcb96d..1e97b8ee 100644 --- a/src/components/LockScreen/index.vue +++ b/src/components/LockScreen/index.vue @@ -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(() => {