mirror of
https://gitcode.com/yangzongzhuan/RuoYi-Vue3.git
synced 2026-05-22 19:08:37 +00:00
新增锁定屏幕功能
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const LOCK_KEY = 'screen-lock'
|
||||
const LOCK_PATH_KEY = 'screen-lock-path'
|
||||
|
||||
export const useLockStore = defineStore('lock', {
|
||||
state: () => ({
|
||||
isLock: JSON.parse(localStorage.getItem(LOCK_KEY) || 'false'),
|
||||
lockPath: localStorage.getItem(LOCK_PATH_KEY) || '/index'
|
||||
}),
|
||||
actions: {
|
||||
// 锁定屏幕,同时记录当前路径
|
||||
lockScreen(currentPath) {
|
||||
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
|
||||
@@ -3,6 +3,7 @@ import { ElMessageBox, } from 'element-plus'
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { isHttp, isEmpty } from "@/utils/validate"
|
||||
import useLockStore from '@/store/modules/lock'
|
||||
import defAva from '@/assets/images/profile.jpg'
|
||||
|
||||
const useUserStore = defineStore(
|
||||
@@ -28,6 +29,7 @@ const useUserStore = defineStore(
|
||||
login(username, password, code, uuid).then(res => {
|
||||
setToken(res.token)
|
||||
this.token = res.token
|
||||
useLockStore().unlockScreen()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
||||
Reference in New Issue
Block a user