新增锁定屏幕功能

This commit is contained in:
RuoYi
2026-03-20 22:13:44 +08:00
parent 8fb8f0d505
commit e6f4b20a1c
7 changed files with 448 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
const LOCK_KEY = 'screen-lock'
const LOCK_PATH_KEY = 'screen-lock-path'
interface LockState {
isLock: boolean
lockPath: string
}
export const useLockStore = defineStore('lock', {
state: (): LockState => ({
isLock: JSON.parse(localStorage.getItem(LOCK_KEY) || 'false'),
lockPath: localStorage.getItem(LOCK_PATH_KEY) || '/index'
}),
actions: {
// 锁定屏幕,同时记录当前路径
lockScreen(currentPath: string) {
this.lockPath = currentPath || '/index'
localStorage.setItem(LOCK_PATH_KEY, this.lockPath)
this.isLock = true
localStorage.setItem(LOCK_KEY, 'true')
},
// 解锁屏幕,清除路径
unlockScreen() {
this.isLock = false
localStorage.setItem(LOCK_KEY, 'false')
this.lockPath = '/index'
localStorage.setItem(LOCK_PATH_KEY, '/index')
}
}
})
export default useLockStore