mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-21 01:46:54 +08:00
优化h5项目
This commit is contained in:
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