From e87ac92cd12e646b2430d7eddc0a4bdc08908ea8 Mon Sep 17 00:00:00 2001 From: richjohnrambo Date: Thu, 24 Sep 2026 01:30:49 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"refactor:=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=94=81=E5=B1=8F=E5=8A=9F=E8=83=BD=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e002e45f82f47e245245f41e66932150d0503068. --- web/src/App.vue | 42 ++- web/src/components/Lockscreen/Lockscreen.vue | 315 +++++++++++++++++++ web/src/components/Lockscreen/Recharge.vue | 164 ++++++++++ web/src/components/Lockscreen/index.ts | 3 + web/src/layout/components/Header/index.vue | 9 + web/src/store/modules/index.ts | 3 + web/src/store/modules/lockscreen.ts | 31 ++ web/src/store/modules/user.ts | 2 + web/src/store/mutation-types.ts | 1 + web/src/store/types.ts | 2 + 10 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 web/src/components/Lockscreen/Lockscreen.vue create mode 100644 web/src/components/Lockscreen/Recharge.vue create mode 100644 web/src/components/Lockscreen/index.ts create mode 100644 web/src/store/modules/lockscreen.ts diff --git a/web/src/App.vue b/web/src/App.vue index aae22f8..d8e9d32 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,5 +1,6 @@ diff --git a/web/src/components/Lockscreen/Recharge.vue b/web/src/components/Lockscreen/Recharge.vue new file mode 100644 index 0000000..4eef443 --- /dev/null +++ b/web/src/components/Lockscreen/Recharge.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/web/src/components/Lockscreen/index.ts b/web/src/components/Lockscreen/index.ts new file mode 100644 index 0000000..7e086dc --- /dev/null +++ b/web/src/components/Lockscreen/index.ts @@ -0,0 +1,3 @@ +import LockScreen from './Lockscreen.vue'; + +export { LockScreen }; diff --git a/web/src/layout/components/Header/index.vue b/web/src/layout/components/Header/index.vue index 56baf12..8fd072a 100644 --- a/web/src/layout/components/Header/index.vue +++ b/web/src/layout/components/Header/index.vue @@ -216,6 +216,7 @@ } from 'naive-ui'; import { TABS_ROUTES } from '@/store/mutation-types'; import { useUserStore } from '@/store/modules/user'; + import { useLockscreenStore } from '@/store/modules/lockscreen'; import ProjectSetting from './ProjectSetting.vue'; import { AsideMenu } from '@/layout/components/Menu'; import { useProjectSetting } from '@/hooks/setting/useProjectSetting'; @@ -248,6 +249,7 @@ const i18nStore = useI18nStore(); const userStore = useUserStore(); const notificationStore = notificationStoreWidthOut(); + const useLockscreen = useLockscreenStore(); const message = useMessage(); const dialog = useDialog(); const { @@ -394,6 +396,13 @@ icon: 'BellOutlined', tips: '我的消息', }, + { + icon: 'LockOutlined', + tips: '锁屏', + eventObject: { + click: () => useLockscreen.setLock(true), + }, + }, ]; function renderCustomHeader() { diff --git a/web/src/store/modules/index.ts b/web/src/store/modules/index.ts index ff19e74..b1c9dbf 100644 --- a/web/src/store/modules/index.ts +++ b/web/src/store/modules/index.ts @@ -14,6 +14,8 @@ import user from './user'; // @ts-ignore import tabsView from './tabs-view'; // @ts-ignore +import lockscreen from './lockscreen'; +// @ts-ignore import dict from './dict'; // @ts-ignore import i18n from './i18n'; @@ -22,6 +24,7 @@ export default { asyncRoute, user, tabsView, + lockscreen, dict, i18n, }; diff --git a/web/src/store/modules/lockscreen.ts b/web/src/store/modules/lockscreen.ts new file mode 100644 index 0000000..c9bf4a2 --- /dev/null +++ b/web/src/store/modules/lockscreen.ts @@ -0,0 +1,31 @@ +import { defineStore } from 'pinia'; +import { IS_LOCKSCREEN } from '@/store/mutation-types'; +import { storage } from '@/utils/Storage'; + +// 长时间不操作默认锁屏时间 +const initTime = 60 * 60; + +const isLock = storage.get(IS_LOCKSCREEN, false); + +export type ILockscreenState = { + isLock: boolean; // 是否锁屏 + lockTime: number; +}; + +export const useLockscreenStore = defineStore({ + id: 'app-lockscreen', + state: (): ILockscreenState => ({ + isLock: isLock === true, // 是否锁屏 + lockTime: isLock == 'true' ? initTime : 0, + }), + getters: {}, + actions: { + setLock(payload) { + this.isLock = payload; + storage.set(IS_LOCKSCREEN, this.isLock); + }, + setLockTime(payload = initTime) { + this.lockTime = payload; + }, + }, +}); diff --git a/web/src/store/modules/user.ts b/web/src/store/modules/user.ts index 2797609..8742e76 100644 --- a/web/src/store/modules/user.ts +++ b/web/src/store/modules/user.ts @@ -7,6 +7,7 @@ import { CURRENT_DICT, CURRENT_LOGIN_CONFIG, CURRENT_USER, + IS_LOCKSCREEN, } from '@/store/mutation-types'; import { ResultEnum } from '@/enums/httpEnum'; import { @@ -176,6 +177,7 @@ export const useUserStore = defineStore({ const ex = 30 * 24 * 60 * 60 * 1000; storage.set(ACCESS_TOKEN, data.token, ex); storage.set(CURRENT_USER, data, ex); + storage.set(IS_LOCKSCREEN, false); this.setToken(data.token); this.setUserInfo(data); } diff --git a/web/src/store/mutation-types.ts b/web/src/store/mutation-types.ts index 81fa636..15d17a2 100644 --- a/web/src/store/mutation-types.ts +++ b/web/src/store/mutation-types.ts @@ -2,6 +2,7 @@ export const ACCESS_TOKEN = 'ACCESS-TOKEN'; // 用户token export const CURRENT_USER = 'CURRENT-USER'; // 当前用户信息 export const CURRENT_CONFIG = 'CURRENT-CONFIG'; // 当前基础配置 export const CURRENT_LOGIN_CONFIG = 'CURRENT-LOGIN-CONFIG'; // 当前登录配置 +export const IS_LOCKSCREEN = 'IS-LOCKSCREEN'; // 是否锁屏 export const TABS_ROUTES = 'TABS-ROUTES'; // 标签页 export const CURRENT_DICT = 'CURRENT-DICT'; // 当前用户字典配置 export const CurrentLocale = 'Current-Locale'; // 当前语言 diff --git a/web/src/store/types.ts b/web/src/store/types.ts index 482918f..65cef51 100644 --- a/web/src/store/types.ts +++ b/web/src/store/types.ts @@ -1,5 +1,6 @@ import { IAsyncRouteState } from '@/store/modules/asyncRoute'; import { IUserState } from '@/store/modules/user'; +import { ILockscreenState } from '@/store/modules/lockscreen'; import { ITabsViewState } from '@/store/modules/tabsView'; import { INotificationStore } from '@/store/modules/notification'; import { IDictState } from '@/store/modules/dict'; @@ -7,6 +8,7 @@ import { IDictState } from '@/store/modules/dict'; export interface IStore { asyncRoute: IAsyncRouteState; user: IUserState; + lockscreen: ILockscreenState; tabsView: ITabsViewState; dict: IDictState; notification: INotificationStore;