mooho-base-admin-plus 2.0.28 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/mooho-base-admin-plus.min.esm.js +63 -85
- package/package/mooho-base-admin-plus.min.js +48 -48
- package/package.json +1 -1
- package/public/setting.js +1 -1
- package/src/api/customModel.js +0 -1
- package/src/components/view/view-table.vue +4 -3
- package/src/index.js +2 -2
- package/src/pages/template/viewPage.vue +1 -1
- package/src/router/dynamic.js +2 -4
- package/src/router/index.js +6 -2
- package/src/router/routes.js +89 -0
- package/src/store/modules/admin/modules/account.js +5 -9
- package/src/store/modules/admin/modules/page.js +37 -60
package/package.json
CHANGED
package/public/setting.js
CHANGED
package/src/api/customModel.js
CHANGED
package/src/index.js
CHANGED
|
@@ -159,7 +159,7 @@ Object.keys(files).forEach(key => {
|
|
|
159
159
|
pages[key.replace(/(\.\/pages\/)/g, '')] = files[key].default;
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
const created = async (app, pages, routes
|
|
162
|
+
const created = async (app, pages, routes) => {
|
|
163
163
|
if (window) {
|
|
164
164
|
// 将根实例存全局,可在特殊场景下调用
|
|
165
165
|
window.$app = getCurrentInstance();
|
|
@@ -169,7 +169,7 @@ const created = async (app, pages, routes, layout = basicLayout) => {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// 初始化路由
|
|
172
|
-
initRouter(pages,
|
|
172
|
+
initRouter(pages, routes);
|
|
173
173
|
// 加载多语言
|
|
174
174
|
store.dispatch('admin/i18n/load', app);
|
|
175
175
|
// 设置顶栏菜单
|
package/src/router/dynamic.js
CHANGED
|
@@ -36,7 +36,7 @@ export default {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
root.children.push({
|
|
40
40
|
path,
|
|
41
41
|
name,
|
|
42
42
|
meta: {
|
|
@@ -50,9 +50,7 @@ export default {
|
|
|
50
50
|
resolve(pages[item.templateUrl]);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
root.children.push(child);
|
|
53
|
+
});
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
|
package/src/router/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import util from '../libs/util';
|
|
|
4
4
|
import Setting from '../setting';
|
|
5
5
|
import store from '../store/index';
|
|
6
6
|
import dynamic from './dynamic';
|
|
7
|
+
import { setting } from '..';
|
|
7
8
|
|
|
8
9
|
const base = import.meta.env.VITE_APP_BASE_PATH;
|
|
9
10
|
|
|
@@ -16,7 +17,7 @@ const router = createRouter({
|
|
|
16
17
|
let inited = false;
|
|
17
18
|
|
|
18
19
|
// 创建路由
|
|
19
|
-
const initRouter = (pages,
|
|
20
|
+
const initRouter = (pages, routes) => {
|
|
20
21
|
// 添加静态路由
|
|
21
22
|
routes.forEach(route => {
|
|
22
23
|
router.addRoute(route);
|
|
@@ -40,6 +41,9 @@ const initRouter = (pages, layout, routes) => {
|
|
|
40
41
|
|
|
41
42
|
// 处理路由 得到每一级的路由设置
|
|
42
43
|
store.commit('admin/page/init', router.getRoutes());
|
|
44
|
+
// 持久化数据加载上次退出时的多页列表
|
|
45
|
+
store.dispatch('admin/page/openedLoad', { loadOpenedTabs: true }, { root: true });
|
|
46
|
+
|
|
43
47
|
inited = true;
|
|
44
48
|
next({
|
|
45
49
|
...to,
|
|
@@ -73,7 +77,7 @@ const initRouter = (pages, layout, routes) => {
|
|
|
73
77
|
router.afterEach(to => {
|
|
74
78
|
if (Setting.showProgressBar) ViewUIPlus.LoadingBar.finish();
|
|
75
79
|
// 多页控制 打开新的页面
|
|
76
|
-
if (
|
|
80
|
+
if (setting.layout.tabs) {
|
|
77
81
|
store.dispatch('admin/page/open', to);
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { pages, basicLayout } from '../../src';
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 在主框架之外显示
|
|
6
|
+
*/
|
|
7
|
+
const frameOut = [
|
|
8
|
+
// 登录
|
|
9
|
+
{
|
|
10
|
+
path: '/login',
|
|
11
|
+
name: 'login',
|
|
12
|
+
meta: {
|
|
13
|
+
title: 'Front_Label_Login'
|
|
14
|
+
},
|
|
15
|
+
component: () => {
|
|
16
|
+
return new Promise(resolve => {
|
|
17
|
+
resolve(pages['account/login.vue']);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 在主框架内显示
|
|
25
|
+
*/
|
|
26
|
+
const frameIn = [
|
|
27
|
+
{
|
|
28
|
+
path: '/',
|
|
29
|
+
name: 'root',
|
|
30
|
+
redirect: {
|
|
31
|
+
name: 'login'
|
|
32
|
+
},
|
|
33
|
+
component: basicLayout,
|
|
34
|
+
children: [
|
|
35
|
+
{
|
|
36
|
+
path: 'index',
|
|
37
|
+
name: 'index',
|
|
38
|
+
redirect: {
|
|
39
|
+
name: 'home'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
// 首页
|
|
43
|
+
{
|
|
44
|
+
path: '/home',
|
|
45
|
+
name: 'home',
|
|
46
|
+
meta: {
|
|
47
|
+
title: 'Front_Label_Home',
|
|
48
|
+
description: 'Home',
|
|
49
|
+
closable: false
|
|
50
|
+
},
|
|
51
|
+
component: () => {
|
|
52
|
+
return new Promise(resolve => {
|
|
53
|
+
resolve(pages['common/home.vue']);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// 刷新页面 必须保留
|
|
58
|
+
{
|
|
59
|
+
path: 'refresh',
|
|
60
|
+
name: 'refresh',
|
|
61
|
+
hidden: true,
|
|
62
|
+
component: {
|
|
63
|
+
beforeRouteEnter(to, from, next) {
|
|
64
|
+
next(instance => instance.$router.replace(from.fullPath));
|
|
65
|
+
},
|
|
66
|
+
render: () => h()
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// 页面重定向 必须保留
|
|
70
|
+
{
|
|
71
|
+
path: 'redirect/:route*',
|
|
72
|
+
name: 'redirect',
|
|
73
|
+
hidden: true,
|
|
74
|
+
component: {
|
|
75
|
+
beforeRouteEnter(to, from, next) {
|
|
76
|
+
next(instance => instance.$router.replace(JSON.parse(from.params.route)));
|
|
77
|
+
},
|
|
78
|
+
render: () => h()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
// 导出需要显示菜单的
|
|
86
|
+
export const frameInRoutes = frameIn;
|
|
87
|
+
|
|
88
|
+
// 重新组织后导出
|
|
89
|
+
export default [...frameOut, ...frameIn];
|
|
@@ -81,15 +81,11 @@ export default {
|
|
|
81
81
|
* @param {Object} dispatch vuex dispatch
|
|
82
82
|
* @param {Object} loadOpenedTabs 是否加载页签信息
|
|
83
83
|
*/
|
|
84
|
-
load({ dispatch }, { loadOpenedTabs = true } = {}) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await dispatch('admin/page/openedLoad', { loadOpenedTabs }, { root: true });
|
|
90
|
-
// end
|
|
91
|
-
resolve();
|
|
92
|
-
});
|
|
84
|
+
async load({ dispatch }, { loadOpenedTabs = true } = {}) {
|
|
85
|
+
// 加载用户登录信息
|
|
86
|
+
await dispatch('admin/user/load', null, { root: true });
|
|
87
|
+
// 持久化数据加载上次退出时的多页列表
|
|
88
|
+
//await dispatch('admin/page/openedLoad', { loadOpenedTabs }, { root: true });
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
};
|
|
@@ -83,6 +83,7 @@ export default {
|
|
|
83
83
|
}
|
|
84
84
|
return state;
|
|
85
85
|
});
|
|
86
|
+
|
|
86
87
|
// 根据 opened 数据生成缓存设置
|
|
87
88
|
commit('keepAliveRefresh');
|
|
88
89
|
// end
|
|
@@ -113,13 +114,14 @@ export default {
|
|
|
113
114
|
* @description 更新页面列表上的某一项
|
|
114
115
|
* @param {Object} param { index, params, query, fullPath } 路由信息
|
|
115
116
|
*/
|
|
116
|
-
openedUpdate({ state, dispatch }, { index, params, query, fullPath, meta, keepMeta = false }) {
|
|
117
|
+
openedUpdate({ state, dispatch }, { index, params, query, fullPath, pageName, meta, keepMeta = false }) {
|
|
117
118
|
return new Promise(async resolve => {
|
|
118
119
|
// 更新页面列表某一项
|
|
119
120
|
let page = state.opened[index];
|
|
120
121
|
page.params = params || page.params;
|
|
121
122
|
page.query = query || page.query;
|
|
122
123
|
page.fullPath = fullPath || page.fullPath;
|
|
124
|
+
page.pageName = pageName || page.pageName;
|
|
123
125
|
page.meta = meta || page.meta;
|
|
124
126
|
page.keepMeta = keepMeta;
|
|
125
127
|
state.opened.splice(index, 1, page);
|
|
@@ -133,7 +135,7 @@ export default {
|
|
|
133
135
|
* @description 更新页面当前项
|
|
134
136
|
* @param {Object} param { params, query, fullPath } 路由信息
|
|
135
137
|
*/
|
|
136
|
-
currentUpdate({ state, dispatch }, { params, query, fullPath, meta, keepMeta = false }) {
|
|
138
|
+
currentUpdate({ state, dispatch }, { params, query, fullPath, pageName, meta, keepMeta = false }) {
|
|
137
139
|
return new Promise(async resolve => {
|
|
138
140
|
setTimeout(async () => {
|
|
139
141
|
// 更新当前项
|
|
@@ -142,6 +144,7 @@ export default {
|
|
|
142
144
|
page.params = params || page.params;
|
|
143
145
|
page.query = query || page.query;
|
|
144
146
|
page.fullPath = fullPath || page.fullPath;
|
|
147
|
+
page.pageName = pageName || page.pageName;
|
|
145
148
|
page.meta = meta || page.meta;
|
|
146
149
|
page.keepMeta = keepMeta;
|
|
147
150
|
state.opened.splice(index, 1, page);
|
|
@@ -156,18 +159,19 @@ export default {
|
|
|
156
159
|
* @description 新增一个 tag (打开一个页面)
|
|
157
160
|
* @param {Object} param new tag info
|
|
158
161
|
*/
|
|
159
|
-
add({ state, commit, dispatch }, { tag, params, query, fullPath }) {
|
|
162
|
+
add({ state, commit, dispatch }, { tag, params, query, fullPath, pageName }) {
|
|
160
163
|
return new Promise(async resolve => {
|
|
161
164
|
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
|
|
162
165
|
let newTag = tag;
|
|
163
166
|
newTag.params = params || newTag.params;
|
|
164
167
|
newTag.query = query || newTag.query;
|
|
165
168
|
newTag.fullPath = fullPath || newTag.fullPath;
|
|
169
|
+
newTag.pageName = pageName || newTag.pageName;
|
|
166
170
|
// 添加进当前显示的页面数组
|
|
167
171
|
state.opened.push(newTag);
|
|
168
172
|
// 如果这个页面需要缓存 将其添加到缓存设置
|
|
169
173
|
if (isKeepAlive(newTag)) {
|
|
170
|
-
commit('
|
|
174
|
+
commit('keepAliveRefresh');
|
|
171
175
|
}
|
|
172
176
|
// 持久化
|
|
173
177
|
await dispatch('opened2db');
|
|
@@ -179,7 +183,8 @@ export default {
|
|
|
179
183
|
* @description 打开一个新的页面
|
|
180
184
|
* @param {Object} param 从路由钩子的 to 对象上获取 { name, params, query, fullPath } 路由信息
|
|
181
185
|
*/
|
|
182
|
-
open({ state, commit, dispatch }, { name, params, query, fullPath }) {
|
|
186
|
+
open({ state, commit, dispatch }, { name, params, query, path, fullPath }) {
|
|
187
|
+
const pageName = router.getRoutes().find(item => item.path == path).components.default.name;
|
|
183
188
|
return new Promise(async resolve => {
|
|
184
189
|
setTimeout(async () => {
|
|
185
190
|
// 已经打开的页面
|
|
@@ -197,7 +202,8 @@ export default {
|
|
|
197
202
|
index: pageOpenedIndex,
|
|
198
203
|
params,
|
|
199
204
|
query,
|
|
200
|
-
fullPath
|
|
205
|
+
fullPath,
|
|
206
|
+
pageName
|
|
201
207
|
});
|
|
202
208
|
} else {
|
|
203
209
|
// 页面以前没有打开过
|
|
@@ -208,7 +214,8 @@ export default {
|
|
|
208
214
|
tag: Object.assign({}, page),
|
|
209
215
|
params,
|
|
210
216
|
query,
|
|
211
|
-
fullPath
|
|
217
|
+
fullPath,
|
|
218
|
+
pageName
|
|
212
219
|
});
|
|
213
220
|
}
|
|
214
221
|
}
|
|
@@ -252,11 +259,13 @@ export default {
|
|
|
252
259
|
// 找到这个页面在已经打开的数据里是第几个
|
|
253
260
|
const index = state.opened.findIndex(page => page.fullPath === tagName);
|
|
254
261
|
if (index >= 0) {
|
|
255
|
-
// 如果这个页面是缓存的页面 将其在缓存设置中删除
|
|
256
|
-
commit('keepAliveRemove', state.opened[index].name);
|
|
257
262
|
// 更新数据 删除关闭的页面
|
|
258
263
|
state.opened.splice(index, 1);
|
|
259
264
|
}
|
|
265
|
+
|
|
266
|
+
// 根据 opened 数据生成缓存设置
|
|
267
|
+
commit('keepAliveRefresh');
|
|
268
|
+
|
|
260
269
|
// 持久化
|
|
261
270
|
await dispatch('opened2db');
|
|
262
271
|
// 最后需要判断是否需要跳到首页
|
|
@@ -288,8 +297,10 @@ export default {
|
|
|
288
297
|
});
|
|
289
298
|
if (currentIndex > 0) {
|
|
290
299
|
// 删除打开的页面 并在缓存设置中删除
|
|
291
|
-
state.opened.splice(1, currentIndex - 1)
|
|
300
|
+
state.opened.splice(1, currentIndex - 1);
|
|
292
301
|
}
|
|
302
|
+
// 根据 opened 数据生成缓存设置
|
|
303
|
+
commit('keepAliveRefresh');
|
|
293
304
|
state.current = pageAim;
|
|
294
305
|
if (router.currentRoute.value.fullPath !== pageAim) {
|
|
295
306
|
router.push(pageAim);
|
|
@@ -314,7 +325,9 @@ export default {
|
|
|
314
325
|
}
|
|
315
326
|
});
|
|
316
327
|
// 删除打开的页面 并在缓存设置中删除
|
|
317
|
-
state.opened.splice(currentIndex + 1)
|
|
328
|
+
state.opened.splice(currentIndex + 1);
|
|
329
|
+
// 根据 opened 数据生成缓存设置
|
|
330
|
+
commit('keepAliveRefresh');
|
|
318
331
|
// 设置当前的页面
|
|
319
332
|
state.current = pageAim;
|
|
320
333
|
if (router.currentRoute.value.fullPath !== pageAim) {
|
|
@@ -341,11 +354,13 @@ export default {
|
|
|
341
354
|
});
|
|
342
355
|
// 删除打开的页面数据 并更新缓存设置
|
|
343
356
|
if (currentIndex === 0) {
|
|
344
|
-
state.opened.splice(1)
|
|
357
|
+
state.opened.splice(1);
|
|
345
358
|
} else {
|
|
346
|
-
state.opened.splice(currentIndex + 1)
|
|
347
|
-
state.opened.splice(1, currentIndex - 1)
|
|
359
|
+
state.opened.splice(currentIndex + 1);
|
|
360
|
+
state.opened.splice(1, currentIndex - 1);
|
|
348
361
|
}
|
|
362
|
+
// 根据 opened 数据生成缓存设置
|
|
363
|
+
commit('keepAliveRefresh');
|
|
349
364
|
// 设置新的页面
|
|
350
365
|
state.current = pageAim;
|
|
351
366
|
if (router.currentRoute.value.fullPath !== pageAim) {
|
|
@@ -364,7 +379,9 @@ export default {
|
|
|
364
379
|
closeAll({ state, commit, dispatch }) {
|
|
365
380
|
return new Promise(async resolve => {
|
|
366
381
|
// 删除打开的页面 并在缓存设置中删除
|
|
367
|
-
state.opened.splice(1)
|
|
382
|
+
state.opened.splice(1);
|
|
383
|
+
// 根据 opened 数据生成缓存设置
|
|
384
|
+
commit('keepAliveRefresh');
|
|
368
385
|
// 持久化
|
|
369
386
|
await dispatch('opened2db');
|
|
370
387
|
// 关闭所有的标签页后需要判断一次现在是不是在首页
|
|
@@ -400,38 +417,7 @@ export default {
|
|
|
400
417
|
* @param {Object} state vuex state
|
|
401
418
|
*/
|
|
402
419
|
keepAliveRefresh(state) {
|
|
403
|
-
state.keepAlive = state.opened.filter(item => isKeepAlive(item)).map(e => e.
|
|
404
|
-
},
|
|
405
|
-
/**
|
|
406
|
-
* @description 删除一个页面的缓存设置
|
|
407
|
-
* @param {Object} state vuex state
|
|
408
|
-
* @param {String} name name
|
|
409
|
-
*/
|
|
410
|
-
keepAliveRemove(state, name) {
|
|
411
|
-
const list = [...state.keepAlive];
|
|
412
|
-
const index = list.findIndex(item => item === name);
|
|
413
|
-
|
|
414
|
-
if (index !== -1) {
|
|
415
|
-
list.splice(index, 1);
|
|
416
|
-
state.keepAlive = list;
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
/**
|
|
420
|
-
* @description 增加一个页面的缓存设置
|
|
421
|
-
* @param {Object} state vuex state
|
|
422
|
-
* @param {String} name name
|
|
423
|
-
*/
|
|
424
|
-
keepAlivePush(state, name) {
|
|
425
|
-
const keep = [...state.keepAlive];
|
|
426
|
-
keep.push(name);
|
|
427
|
-
state.keepAlive = keep;
|
|
428
|
-
},
|
|
429
|
-
/**
|
|
430
|
-
* @description 清空页面缓存设置
|
|
431
|
-
* @param {Object} state vuex state
|
|
432
|
-
*/
|
|
433
|
-
keepAliveClean(state) {
|
|
434
|
-
state.keepAlive = [];
|
|
420
|
+
state.keepAlive = state.opened.filter(item => isKeepAlive(item)).map(e => e.pageName);
|
|
435
421
|
},
|
|
436
422
|
/**
|
|
437
423
|
* @class current
|
|
@@ -450,19 +436,10 @@ export default {
|
|
|
450
436
|
*/
|
|
451
437
|
init(state, routes) {
|
|
452
438
|
const pool = [];
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
} else {
|
|
458
|
-
if (!route.hidden) {
|
|
459
|
-
const { meta, name, path } = route;
|
|
460
|
-
pool.push({ meta, name, path });
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
push(routes);
|
|
439
|
+
routes.forEach(route => {
|
|
440
|
+
const { meta, name, path } = route;
|
|
441
|
+
pool.push({ meta, name, path });
|
|
442
|
+
});
|
|
466
443
|
state.pool = pool;
|
|
467
444
|
}
|
|
468
445
|
}
|