fix: 定义锁屏类型
This commit is contained in:
@@ -8,6 +8,7 @@ import useLockedStore from '@/store/modules/locked';
|
|||||||
import { getConfigKey } from '@/api/system/config';
|
import { getConfigKey } from '@/api/system/config';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
import { computed } from 'vue';
|
||||||
const lockedStore = useLockedStore();
|
const lockedStore = useLockedStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -24,7 +25,7 @@ function resetTimeout() {
|
|||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
}
|
}
|
||||||
timeoutId = setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
lockedStore.fnLock('lock', true);
|
lockedStore.fnLock('lock');
|
||||||
}, timeoutDuration);
|
}, timeoutDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ function handleUnlock() {
|
|||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
message.success(t('components.LockScreen.validSucc'), 3);
|
message.success(t('components.LockScreen.validSucc'), 3);
|
||||||
password.value = '';
|
password.value = '';
|
||||||
lockedStore.fnLock('lock', false);
|
lockedStore.fnLock('none');
|
||||||
} else {
|
} else {
|
||||||
message.error(t('components.LockScreen.validError'), 3);
|
message.error(t('components.LockScreen.validError'), 3);
|
||||||
}
|
}
|
||||||
@@ -46,10 +47,12 @@ function handleUnlock() {
|
|||||||
|
|
||||||
/**返回登录界面 */
|
/**返回登录界面 */
|
||||||
function backLogin() {
|
function backLogin() {
|
||||||
lockedStore.fnLock('lock', false);
|
lockedStore.fnLock('none');
|
||||||
userStore.fnLogOut().finally(() => router.push({ name: 'Login' }));
|
userStore.fnLogOut().finally(() => router.push({ name: 'Login' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isLocked = computed(() => lockedStore.type !== 'none');
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getConfigKey('sys.lockTime')
|
getConfigKey('sys.lockTime')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
@@ -66,8 +69,8 @@ onMounted(() => {
|
|||||||
window.addEventListener('keydown', resetTimeout);
|
window.addEventListener('keydown', resetTimeout);
|
||||||
}
|
}
|
||||||
// 本地锁定同时是登录状态
|
// 本地锁定同时是登录状态
|
||||||
if (lockedStore.isLocked && getToken()) {
|
if (lockedStore.type === 'lock' && getToken()) {
|
||||||
lockedStore.fnLock('lock', true);
|
lockedStore.fnLock('lock');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -81,7 +84,7 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="lockedStore.isLocked"
|
v-model:visible="isLocked"
|
||||||
get-container="#app"
|
get-container="#app"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
:zIndex="1008"
|
: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">
|
<div class="lock-screen_login-user">
|
||||||
<a-avatar
|
<a-avatar
|
||||||
shape="circle"
|
shape="circle"
|
||||||
@@ -132,7 +135,7 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 锁屏-OMC重启升级 -->
|
<!-- 锁屏-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" />
|
<LoadingOutlined style="font-size: 56px" />
|
||||||
<div class="text">
|
<div class="text">
|
||||||
{{ t('components.LockScreen.backReload') }}
|
{{ t('components.LockScreen.backReload') }}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function getToken(): string {
|
|||||||
/**设置cookis中Token字符串 */
|
/**设置cookis中Token字符串 */
|
||||||
export function setToken(token: string): void {
|
export function setToken(token: string): void {
|
||||||
Cookies.set(TOKEN_COOKIE, token);
|
Cookies.set(TOKEN_COOKIE, token);
|
||||||
localSet(CACHE_LOCAL_LOCK, 'false');
|
localSet(CACHE_LOCAL_LOCK, 'none');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**移除cookis中Token字符串,localStorage中锁屏字符串 */
|
/**移除cookis中Token字符串,localStorage中锁屏字符串 */
|
||||||
|
|||||||
@@ -6,18 +6,15 @@ import { defineStore } from 'pinia';
|
|||||||
|
|
||||||
/**锁屏信息类型 */
|
/**锁屏信息类型 */
|
||||||
type Locked = {
|
type Locked = {
|
||||||
/**锁定状态 */
|
|
||||||
isLocked: boolean;
|
|
||||||
/**锁屏类型 */
|
/**锁屏类型 */
|
||||||
lockType: 'lock' | 'reload';
|
type: 'none' | 'lock' | 'reload' | string;
|
||||||
/**超时锁屏时间,秒*/
|
/**lock 超时锁屏时间,秒*/
|
||||||
lockTimeout: number;
|
lockTimeout: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useLockedStore = defineStore('locked', {
|
const useLockedStore = defineStore('locked', {
|
||||||
state: (): Locked => ({
|
state: (): Locked => ({
|
||||||
isLocked: localGet(CACHE_LOCAL_LOCK) === 'true',
|
type: localGet(CACHE_LOCAL_LOCK) || 'none',
|
||||||
lockType: 'lock',
|
|
||||||
lockTimeout: 0,
|
lockTimeout: 0,
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
@@ -26,7 +23,8 @@ const useLockedStore = defineStore('locked', {
|
|||||||
async relaodWait() {
|
async relaodWait() {
|
||||||
const res = await getSysConf();
|
const res = await getSysConf();
|
||||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||||
this.fnLock('lock', false);
|
this.fnLock('none');
|
||||||
|
window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
// 延迟5秒
|
// 延迟5秒
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -35,10 +33,9 @@ const useLockedStore = defineStore('locked', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 设置锁定
|
// 设置锁定
|
||||||
async fnLock(type: 'lock' | 'reload', v: boolean) {
|
async fnLock(type: 'none' | 'lock' | 'reload') {
|
||||||
this.lockType = type;
|
this.type = type;
|
||||||
this.isLocked = v;
|
localSet(CACHE_LOCAL_LOCK, type);
|
||||||
localSet(CACHE_LOCAL_LOCK, `${v}`);
|
|
||||||
if (type === 'reload') {
|
if (type === 'reload') {
|
||||||
// 延迟5秒
|
// 延迟5秒
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -296,10 +296,9 @@ function fnFileModalOk() {
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
// OMC自升级
|
// OMC自升级
|
||||||
if (type === 'run' && from.neType.toLowerCase() === 'omc') {
|
if (type === 'run' && from.neType.toLowerCase() === 'omc') {
|
||||||
console.log(res);
|
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
fnFileModalCancel();
|
fnFileModalCancel();
|
||||||
lockedStore.fnLock('reload', true);
|
lockedStore.fnLock('reload');
|
||||||
} else {
|
} else {
|
||||||
message.error({
|
message.error({
|
||||||
content: `${fileModalState.title} ${res.msg}`,
|
content: `${fileModalState.title} ${res.msg}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user