@lambo-design/shared 1.0.0-beta.5 → 1.0.0-beta.7
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/config/config.js +11 -0
- package/package.json +1 -1
- package/utils/ajax/interceptors.js +90 -90
- package/utils/menu/before-close.js +17 -0
- package/utils/menu/index.js +11 -0
- package/utils/platform.js +46 -1
- package/utils/theme.js +1 -1
- package/utils/vxetable/index.js +14 -0
package/config/config.js
CHANGED
|
@@ -6,6 +6,17 @@ let config = {
|
|
|
6
6
|
ssoLoginUrl: "/wdk?action=access.login&method=logout",
|
|
7
7
|
homeName: 'home',
|
|
8
8
|
homePageUrl: '/home',
|
|
9
|
+
homeRouter: {
|
|
10
|
+
"name": 'home',
|
|
11
|
+
"params": {},
|
|
12
|
+
"query": {},
|
|
13
|
+
"meta": {
|
|
14
|
+
"hideInMenu": true,
|
|
15
|
+
"title": "首页",
|
|
16
|
+
"icon": "md-home",
|
|
17
|
+
"appId": "home"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
9
20
|
upmsServerContext: '/upms-server',
|
|
10
21
|
ossServerContext: '/upms-server',
|
|
11
22
|
didaHost: "/dida-runtime-micro",
|
package/package.json
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import qs from 'qs'
|
|
2
|
-
import cacheRules from "./cacheconf";
|
|
3
|
-
import {getToken,getUrlParams} from '../platform'
|
|
4
|
-
import Bus from '../bus';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let timer1, timer2;
|
|
8
|
-
|
|
9
|
-
function requestInterceptors(config) {
|
|
10
|
-
const params = getUrlParams();
|
|
11
|
-
|
|
12
|
-
let token = getToken();
|
|
13
|
-
if (token) {
|
|
14
|
-
config.headers.token = token;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//sso_token认证
|
|
18
|
-
if (params.hasOwnProperty('sso_token')||sessionStorage.getItem('sso_token')) {
|
|
19
|
-
config.params = Object.assign({
|
|
20
|
-
sso_token: params.sso_token||sessionStorage.getItem('sso_token') ,
|
|
21
|
-
sso_id: params.sso_id
|
|
22
|
-
}, config.params)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
//oauth认证
|
|
26
|
-
if (params.hasOwnProperty('token')) {
|
|
27
|
-
if (config.url.indexOf('?') === -1) {
|
|
28
|
-
config.url = config.url + "?token=" + params.token + "&ssoid=" + params.ssoid;
|
|
29
|
-
} else {
|
|
30
|
-
config.url = config.url + "&token=" + params.token + "&ssoid=" + params.ssoid;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (config.method === 'post') {
|
|
35
|
-
// payload为自定义不使用qs.stringify序列化的标记,默认config.payload == undefined;
|
|
36
|
-
// 为true时用于匹配@requestBody定义参数的接口
|
|
37
|
-
// 使用方式:post(config.AAAServerContext + '/AAA/BBB/CCC', { ...paramRequestBody }, { payload: true })
|
|
38
|
-
if (!config.payload) {
|
|
39
|
-
config.data = qs.stringify(config.data)
|
|
40
|
-
}
|
|
41
|
-
} else if (config.method === 'get') {
|
|
42
|
-
for (let rule of cacheRules) {
|
|
43
|
-
if (rule.test(config.url)) {
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (config.url.indexOf('?') === -1) {
|
|
48
|
-
config.url = config.url + "?t=" + new Date().getTime();
|
|
49
|
-
} else {
|
|
50
|
-
config.url = config.url + "&t=" + new Date().getTime();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return config;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function requestError(error) {
|
|
57
|
-
console.error("服务器内部异常,请稍候再试",error);
|
|
58
|
-
return Promise.reject(error);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function responseInterceptors(response) {
|
|
62
|
-
const data = response.data;
|
|
63
|
-
if (data instanceof Object) {
|
|
64
|
-
const code = data["code"];
|
|
65
|
-
if (code === 10106) {
|
|
66
|
-
clearTimeout(timer1);
|
|
67
|
-
timer1 = setTimeout(function () {
|
|
68
|
-
if (confirm("会话已失效,是否重新登录")) {
|
|
69
|
-
Bus.$emit("needLogin");
|
|
70
|
-
}
|
|
71
|
-
}, 500)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return response;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function responseError(error) {
|
|
78
|
-
clearTimeout(timer2);
|
|
79
|
-
timer2 = setTimeout(function () {
|
|
80
|
-
console.error("服务器内部异常,请稍候再试");
|
|
81
|
-
}, 500)
|
|
82
|
-
return Promise.reject(error);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default {
|
|
86
|
-
requestInterceptors,
|
|
87
|
-
responseInterceptors,
|
|
88
|
-
requestError,
|
|
89
|
-
responseError
|
|
90
|
-
}
|
|
1
|
+
import qs from 'qs'
|
|
2
|
+
import cacheRules from "./cacheconf";
|
|
3
|
+
import {getToken,getUrlParams} from '../platform'
|
|
4
|
+
import Bus from '../bus';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let timer1, timer2;
|
|
8
|
+
|
|
9
|
+
function requestInterceptors(config) {
|
|
10
|
+
const params = getUrlParams();
|
|
11
|
+
|
|
12
|
+
let token = getToken();
|
|
13
|
+
if (token) {
|
|
14
|
+
config.headers.token = token;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//sso_token认证
|
|
18
|
+
if (params.hasOwnProperty('sso_token')||sessionStorage.getItem('sso_token')) {
|
|
19
|
+
config.params = Object.assign({
|
|
20
|
+
sso_token: params.sso_token||sessionStorage.getItem('sso_token') ,
|
|
21
|
+
sso_id: params.sso_id
|
|
22
|
+
}, config.params)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//oauth认证
|
|
26
|
+
if (params.hasOwnProperty('token')) {
|
|
27
|
+
if (config.url.indexOf('?') === -1) {
|
|
28
|
+
config.url = config.url + "?token=" + params.token + "&ssoid=" + params.ssoid;
|
|
29
|
+
} else {
|
|
30
|
+
config.url = config.url + "&token=" + params.token + "&ssoid=" + params.ssoid;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (config.method === 'post') {
|
|
35
|
+
// payload为自定义不使用qs.stringify序列化的标记,默认config.payload == undefined;
|
|
36
|
+
// 为true时用于匹配@requestBody定义参数的接口
|
|
37
|
+
// 使用方式:post(config.AAAServerContext + '/AAA/BBB/CCC', { ...paramRequestBody }, { payload: true })
|
|
38
|
+
if (!config.payload) {
|
|
39
|
+
config.data = qs.stringify(config.data)
|
|
40
|
+
}
|
|
41
|
+
} else if (config.method === 'get') {
|
|
42
|
+
for (let rule of cacheRules) {
|
|
43
|
+
if (rule.test(config.url)) {
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (config.url.indexOf('?') === -1) {
|
|
48
|
+
config.url = config.url + "?t=" + new Date().getTime();
|
|
49
|
+
} else {
|
|
50
|
+
config.url = config.url + "&t=" + new Date().getTime();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return config;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function requestError(error) {
|
|
57
|
+
console.error("服务器内部异常,请稍候再试",error);
|
|
58
|
+
return Promise.reject(error);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function responseInterceptors(response) {
|
|
62
|
+
const data = response.data;
|
|
63
|
+
if (data instanceof Object) {
|
|
64
|
+
const code = data["code"];
|
|
65
|
+
if (code === 10106) {
|
|
66
|
+
clearTimeout(timer1);
|
|
67
|
+
timer1 = setTimeout(function () {
|
|
68
|
+
if (confirm("会话已失效,是否重新登录")) {
|
|
69
|
+
Bus.$emit("needLogin");
|
|
70
|
+
}
|
|
71
|
+
}, 500)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return response;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function responseError(error) {
|
|
78
|
+
clearTimeout(timer2);
|
|
79
|
+
timer2 = setTimeout(function () {
|
|
80
|
+
console.error("服务器内部异常,请稍候再试");
|
|
81
|
+
}, 500)
|
|
82
|
+
return Promise.reject(error);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
requestInterceptors,
|
|
87
|
+
responseInterceptors,
|
|
88
|
+
requestError,
|
|
89
|
+
responseError
|
|
90
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Modal } from '@lambo-design/core'
|
|
2
|
+
|
|
3
|
+
const beforeClose = {
|
|
4
|
+
before_close_normal: (resolve) => {
|
|
5
|
+
Modal.confirm({
|
|
6
|
+
title: '确定要关闭这一页吗?',
|
|
7
|
+
onOk: () => {
|
|
8
|
+
resolve(true)
|
|
9
|
+
},
|
|
10
|
+
onCancel: () => {
|
|
11
|
+
resolve(false)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default beforeClose
|
package/utils/menu/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否存在路由
|
|
3
|
+
* @param $router
|
|
4
|
+
* @param name
|
|
5
|
+
* @returns {*|boolean}
|
|
6
|
+
*/
|
|
7
|
+
export const hasRoute = ($router, name) => {
|
|
8
|
+
let routes = $router.getRoutes();
|
|
9
|
+
let res = routes.filter(item => item.name === name)
|
|
10
|
+
return res && res.length > 0
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
13
|
* 动态生成菜单
|
|
3
14
|
* @param permissionList
|
package/utils/platform.js
CHANGED
|
@@ -265,7 +265,7 @@ export const getArrayFromFile = (file) => {
|
|
|
265
265
|
reader.readAsText(file) // 以文本格式读取
|
|
266
266
|
let arr = []
|
|
267
267
|
reader.onload = function (evt) {
|
|
268
|
-
let data = evt.target.
|
|
268
|
+
let data = evt.target.card // 读到的数据
|
|
269
269
|
let pasteData = data.trim()
|
|
270
270
|
arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
|
|
271
271
|
return row.split('\t')
|
|
@@ -517,3 +517,48 @@ export function oneOf (value, validList) {
|
|
|
517
517
|
}
|
|
518
518
|
return false
|
|
519
519
|
}
|
|
520
|
+
|
|
521
|
+
export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
|
|
522
|
+
for (const item of arr) {
|
|
523
|
+
if (item[filterKey] && item[filterKey] == filterValue) {
|
|
524
|
+
return item;
|
|
525
|
+
}
|
|
526
|
+
let result = null;
|
|
527
|
+
if (item[recursionKey]) {
|
|
528
|
+
result = recursionKeyFindItem(item[recursionKey], filterKey, filterValue, recursionKey);
|
|
529
|
+
if (result) {
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
export const filterMenuName = (menuList, name) => {
|
|
538
|
+
return recursionKeyFindItem(menuList, 'name', name, 'children')
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
export const filterMenuUri = (menuList, name) => {
|
|
542
|
+
return recursionKeyFindItem(menuList, 'uri', name, 'children')
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
export const tagExists = (taglist, name) => {
|
|
546
|
+
return taglist && taglist.filter(item => item.name === name).length > 0;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
export const getPreviousTagIndex = (tagList, name) => {
|
|
550
|
+
let count = 0;
|
|
551
|
+
if (tagList && name) {
|
|
552
|
+
for (let i = 0 ;i < tagList.length; i++) {
|
|
553
|
+
let item = tagList[i];
|
|
554
|
+
if (item.name == name) {
|
|
555
|
+
count = i - 1;
|
|
556
|
+
if (count < 0) {
|
|
557
|
+
count = 0;
|
|
558
|
+
}
|
|
559
|
+
return count;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return count;
|
|
564
|
+
}
|
package/utils/theme.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const setParentRefs = (parentVm, targetVm, refKey) => {
|
|
2
|
+
let hasFind = false;
|
|
3
|
+
if (parentVm.$refs) {
|
|
4
|
+
Object.entries(parentVm.$refs).forEach(([key, value]) => {
|
|
5
|
+
if (value === targetVm) {
|
|
6
|
+
hasFind = true;
|
|
7
|
+
parentVm.$refs[key] = targetVm.$refs[refKey]
|
|
8
|
+
}
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
if (!hasFind && parentVm.$parent) {
|
|
12
|
+
setParentRefs(parentVm.$parent, targetVm, refKey)
|
|
13
|
+
}
|
|
14
|
+
}
|