mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-21 09:56:54 +08:00
优化h5项目
This commit is contained in:
@@ -2,6 +2,7 @@ import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
import user from './module/user';
|
||||
import app from './module/app';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
@@ -16,6 +17,7 @@ export default new Vuex.Store({
|
||||
//
|
||||
},
|
||||
modules: {
|
||||
app,
|
||||
user
|
||||
}
|
||||
});
|
||||
|
||||
32
smart-admin-h5/src/store/module/app.js
Normal file
32
smart-admin-h5/src/store/module/app.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 整个应用相关的状态信息
|
||||
*
|
||||
* 比如: keepalive等
|
||||
*/
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
// 缓存路由
|
||||
keepAliveIncludes: []
|
||||
},
|
||||
|
||||
mutations: {
|
||||
// 加入keep-alive缓存
|
||||
pushKeepAliveIncludes(state, val) {
|
||||
if (state.keepAliveIncludes.length < 30) {
|
||||
const number = state.keepAliveIncludes.findIndex(e => e === val);
|
||||
if (number === -1) {
|
||||
state.keepAliveIncludes.push(val);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 删除缓存
|
||||
deleteKeepAliveIncludes(state, val) {
|
||||
const number = state.keepAliveIncludes.findIndex(e => e === val);
|
||||
if (number !== -1) {
|
||||
state.keepAliveIncludes.splice(number, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user