mirror of
https://gitee.com/y_project/RuoYi-Vue.git
synced 2026-06-20 13:39:21 +08:00
新增锁定屏幕功能
This commit is contained in:
@@ -3,6 +3,8 @@ const getters = {
|
||||
size: state => state.app.size,
|
||||
device: state => state.app.device,
|
||||
dict: state => state.dict.dict,
|
||||
isLock: state => state.lock.isLock,
|
||||
lockPath: state => state.lock.lockPath,
|
||||
visitedViews: state => state.tagsView.visitedViews,
|
||||
cachedViews: state => state.tagsView.cachedViews,
|
||||
token: state => state.user.token,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import app from './modules/app'
|
||||
import lock from './modules/lock'
|
||||
import dict from './modules/dict'
|
||||
import user from './modules/user'
|
||||
import tagsView from './modules/tagsView'
|
||||
@@ -13,6 +14,7 @@ Vue.use(Vuex)
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
app,
|
||||
lock,
|
||||
dict,
|
||||
user,
|
||||
tagsView,
|
||||
|
||||
34
ruoyi-ui/src/store/modules/lock.js
Normal file
34
ruoyi-ui/src/store/modules/lock.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const LOCK_KEY = 'screen-lock'
|
||||
const LOCK_PATH_KEY = 'screen-lock-path'
|
||||
|
||||
const lock = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
isLock: JSON.parse(localStorage.getItem(LOCK_KEY) || 'false'),
|
||||
lockPath: localStorage.getItem(LOCK_PATH_KEY) || '/index'
|
||||
},
|
||||
mutations: {
|
||||
SET_LOCK(state, status) {
|
||||
state.isLock = status
|
||||
localStorage.setItem(LOCK_KEY, JSON.stringify(status))
|
||||
},
|
||||
SET_LOCK_PATH(state, path) {
|
||||
state.lockPath = path
|
||||
localStorage.setItem(LOCK_PATH_KEY, path)
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 锁定屏幕,同时记录当前路径
|
||||
lockScreen({ commit }, currentPath) {
|
||||
commit('SET_LOCK_PATH', currentPath || '/index')
|
||||
commit('SET_LOCK', true)
|
||||
},
|
||||
// 解锁屏幕,清除路径
|
||||
unlockScreen({ commit }) {
|
||||
commit('SET_LOCK', false)
|
||||
commit('SET_LOCK_PATH', '/index')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default lock
|
||||
Reference in New Issue
Block a user