@lambo-design/shared 1.0.0-beta.4 → 1.0.0-beta.41

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.
Files changed (39) hide show
  1. package/config/config.js +12 -0
  2. package/config/themes/default/default.css +4 -2
  3. package/config/themes/default/default.css.map +1 -0
  4. package/config/themes/default/default.less +75 -74
  5. package/config/themes/default/var.less +2 -2
  6. package/config/themes/gold/default.css +6 -4
  7. package/config/themes/gold/default.css.map +1 -0
  8. package/config/themes/gold/default.less +75 -74
  9. package/config/themes/gold/var.less +2 -2
  10. package/config/themes/index.js +5 -1
  11. package/config/themes/lime/default.css +6 -4
  12. package/config/themes/lime/default.css.map +1 -0
  13. package/config/themes/lime/default.less +75 -74
  14. package/config/themes/lime/var.less +2 -2
  15. package/config/themes/orange/orange.css +243 -0
  16. package/config/themes/orange/orange.css.map +1 -0
  17. package/config/themes/orange/orange.less +320 -0
  18. package/config/themes/orange/var.less +314 -0
  19. package/config/themes/red/red.css +243 -0
  20. package/config/themes/red/red.css.map +1 -0
  21. package/config/themes/red/red.less +320 -0
  22. package/config/themes/red/var.less +314 -0
  23. package/config/themes/theme-default.js +4 -6
  24. package/config/themes/theme-gold.js +5 -7
  25. package/config/themes/theme-lime.js +5 -7
  26. package/config/themes/theme-orange.js +41 -0
  27. package/config/themes/theme-red.js +41 -0
  28. package/directives/index.js +23 -0
  29. package/directives/module/draggable.js +56 -0
  30. package/directives/module/permission.js +49 -0
  31. package/index.js +2 -1
  32. package/package.json +22 -20
  33. package/utils/ajax/interceptors.js +97 -90
  34. package/utils/assist.js +24 -19
  35. package/utils/menu/before-close.js +17 -0
  36. package/utils/menu/index.js +135 -0
  37. package/utils/platform.js +84 -8
  38. package/utils/theme.js +1 -1
  39. package/utils/vxetable/index.js +25 -0
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
- {
2
- "name": "@lambo-design/shared",
3
- "version": "1.0.0-beta.4",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {},
7
- "author": "lambo",
8
- "license": "ISC",
9
- "publishConfig": {
10
- "access": "public"
11
- },
12
- "dependencies": {
13
- "axios": "^0.24.0",
14
- "axios-cache-plugin": "^0.1.0",
15
- "qs": "^6.11.0",
16
- "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
17
- "classnames": "^2.3.1",
18
- "xlsx-style": "^0.8.13"
19
- }
20
- }
1
+ {
2
+ "name": "@lambo-design/shared",
3
+ "version": "1.0.0-beta.41",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "author": "lambo",
7
+ "license": "ISC",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "registry": "https://registry.npmjs.org/"
11
+ },
12
+ "dependencies": {
13
+ "axios": "^0.24.0",
14
+ "axios-cache-plugin": "^0.1.0",
15
+ "qs": "^6.11.0",
16
+ "xlsx": "http://cicd.lambo.top/package/cdn/xlsx-0.19.1.tgz",
17
+ "classnames": "^2.3.1",
18
+ "xlsx-style": "^0.8.13",
19
+ "moment": "2.29.4"
20
+ },
21
+ "scripts": {}
22
+ }
@@ -1,90 +1,97 @@
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
+ let hasDialog = false;
9
+
10
+ function requestInterceptors(config) {
11
+ const params = getUrlParams();
12
+
13
+ let token = getToken();
14
+ if (token) {
15
+ config.headers.token = token;
16
+ }
17
+
18
+ //sso_token认证
19
+ if (params.hasOwnProperty('sso_token')||sessionStorage.getItem('sso_token')) {
20
+ config.params = Object.assign({
21
+ sso_token: params.sso_token||sessionStorage.getItem('sso_token') ,
22
+ sso_id: params.sso_id
23
+ }, config.params)
24
+ }
25
+
26
+ //oauth认证
27
+ if (params.hasOwnProperty('token')) {
28
+ if (config.url.indexOf('?') === -1) {
29
+ config.url = config.url + "?token=" + params.token + "&ssoid=" + params.ssoid;
30
+ } else {
31
+ config.url = config.url + "&token=" + params.token + "&ssoid=" + params.ssoid;
32
+ }
33
+ }
34
+
35
+ if (config.method === 'post') {
36
+ // payload为自定义不使用qs.stringify序列化的标记,默认config.payload == undefined;
37
+ // true时用于匹配@requestBody定义参数的接口
38
+ // 使用方式:post(config.AAAServerContext + '/AAA/BBB/CCC', { ...paramRequestBody }, { payload: true })
39
+ if (!config.payload) {
40
+ config.data = qs.stringify(config.data)
41
+ }
42
+ } else if (config.method === 'get') {
43
+ for (let rule of cacheRules) {
44
+ if (rule.test(config.url)) {
45
+ return config;
46
+ }
47
+ }
48
+ if (config.url.indexOf('?') === -1) {
49
+ config.url = config.url + "?t=" + new Date().getTime();
50
+ } else {
51
+ config.url = config.url + "&t=" + new Date().getTime();
52
+ }
53
+ }
54
+ return config;
55
+ }
56
+
57
+ function requestError(error) {
58
+ console.error("服务器内部异常,请稍候再试",error);
59
+ return Promise.reject(error);
60
+ }
61
+
62
+ function responseInterceptors(response) {
63
+ const data = response.data;
64
+ if (data instanceof Object) {
65
+ const code = data["code"];
66
+ if (code === 10106) {
67
+ if (!hasDialog) {
68
+ clearTimeout(timer1);
69
+ timer1 = setTimeout(function () {
70
+ hasDialog = true;
71
+ if (confirm("会话已失效,是否重新登录")) {
72
+ hasDialog = false;
73
+ Bus.$emit("needLogin");
74
+ } else {
75
+ hasDialog = false;
76
+ }
77
+ }, 500)
78
+ }
79
+ }
80
+ }
81
+ return response;
82
+ }
83
+
84
+ function responseError(error) {
85
+ clearTimeout(timer2);
86
+ timer2 = setTimeout(function () {
87
+ console.error("服务器内部异常,请稍候再试");
88
+ }, 500)
89
+ return Promise.reject(error);
90
+ }
91
+
92
+ export default {
93
+ requestInterceptors,
94
+ responseInterceptors,
95
+ requestError,
96
+ responseError
97
+ }
package/utils/assist.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // deepCopy
2
2
 
3
+
3
4
  export function deepCopy(data) {
4
5
  let i;
5
6
  const t = typeOf(data);
@@ -43,29 +44,33 @@ export function typeOf(obj) {
43
44
  }
44
45
 
45
46
  export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
46
- return h('Button', {
47
- props: {
48
- type: type,
49
- size: "small",
50
- ghost: true,
51
- },
52
- directives: [{
53
- name: "permission",
54
- value: permission
55
- }],
56
- style: {
57
- margin: '0 2px'
58
- },
59
- on: {
60
- 'click': () => {
61
- operation(vm, currentRow);
47
+ return h('Button', {
48
+ props: {
49
+ type: type,
50
+ size: "small",
51
+ ghost: true,
52
+ },
53
+ directives: [(permission === '' || permission === null) ? '' : {
54
+ name: "permission",
55
+ value: permission
56
+ }],
57
+ style: {
58
+ margin: '0 2px'
59
+ },
60
+ on: {
61
+ 'click': () => {
62
+ operation(vm, currentRow);
63
+ }
62
64
  }
63
- }
64
- }, operationName);
65
+ }, operationName);
66
+
65
67
  }
66
68
 
67
69
  export function operateHref(vm, h, currentRow, operationName, operation) {
68
- return h('a', {
70
+ return h('a', {
71
+ style: {
72
+ margin: '0 4px'
73
+ },
69
74
  on: {
70
75
  'click': () => {
71
76
  operation(vm, currentRow);
@@ -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
@@ -0,0 +1,135 @@
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
+ }
12
+ /**
13
+ * 判断是否存在路由并且页面存在
14
+ * @param $router
15
+ * @param path
16
+ * @returns {*|boolean}
17
+ */
18
+ export const hasRoutePath = ($router, path) => {
19
+ let routes = $router.getRoutes();
20
+ let res = routes.filter(item => item.path === path)
21
+ return res && res.length > 0
22
+ }
23
+ /**
24
+ * 动态生成菜单
25
+ * @param permissionList
26
+ * @returns []
27
+ */
28
+ export const generatorMenuList = (permissionList,appId) => {
29
+ let menuData = [],
30
+ pageNode = {
31
+ path: "/page",
32
+ name: "page",
33
+ meta: {
34
+ hideInMenu: true,
35
+ notCache: true
36
+ },
37
+ component: "Main",
38
+ children: []
39
+ };
40
+ listToMenuTree(permissionList, menuData, pageNode, "0", [], true,appId);
41
+
42
+ /*if (pageNode.children.length > 0) {
43
+ menuData.push(pageNode);
44
+ }*/
45
+ return menuData;
46
+ };
47
+
48
+
49
+
50
+ /**
51
+ * 数组转树形结构
52
+ */
53
+ const listToMenuTree = (list, menuTree, pageNode, parentId, crumbs, root, appId) => {
54
+ if (list == null) {
55
+ return;
56
+ }
57
+ list.forEach(item => {
58
+ if (item.appId == appId) {
59
+ // 判断是否为父级菜单
60
+ if (item.pid === parentId) {
61
+ if (item.type === 1 || item.type === 2) {
62
+ let node = {
63
+ meta: {
64
+ appId: item.appId,
65
+ title: item.label,
66
+ icon: item.icon,
67
+ crumbs: [...crumbs],
68
+ activeName: item.name
69
+ },
70
+ type: item.type,
71
+ pid: item.pid,
72
+ component: item.name,
73
+ name: item.name,
74
+ uri: item.uri,
75
+ children: []
76
+ };
77
+ node.meta.crumbs.push({
78
+ icon: item.icon,
79
+ name: item.name,
80
+ title: item.label,
81
+ type: item.type
82
+ });
83
+
84
+ if (item.type === 1) {
85
+ if (root) {
86
+ node.component = "Main";
87
+ } else {
88
+ node.component = "parentView";
89
+ }
90
+ }
91
+ // 迭代 list, 找到当前菜单相符合的所有子菜单
92
+ listToMenuTree(
93
+ list,
94
+ node.children,
95
+ pageNode,
96
+ item.permissionId,
97
+ node.meta.crumbs,
98
+ false,
99
+ appId
100
+ );
101
+ // 删掉不存在 children 值的属性
102
+ if (node.children.length <= 0) {
103
+ delete node.children;
104
+ }
105
+ // 加入到树中
106
+ menuTree.push(node);
107
+ }
108
+ if (item.type === 4) {
109
+ let child = {
110
+ meta: {
111
+ title: item.label,
112
+ hideInMenu: true,
113
+ notCache: true,
114
+ crumbs: [...crumbs],
115
+ type: item.type
116
+ },
117
+ type: item.type,
118
+ pid: item.pid,
119
+ component: item.name,
120
+ name: item.name,
121
+ uri: item.uri
122
+ };
123
+ child.meta.crumbs.push({
124
+ icon: item.icon,
125
+ name: item.name,
126
+ title: item.label,
127
+ type: item.type
128
+ });
129
+ pageNode.children.push(child);
130
+ }
131
+ }
132
+ }
133
+ });
134
+ };
135
+ export default generatorMenuList;
package/utils/platform.js CHANGED
@@ -1,8 +1,9 @@
1
-
2
- export const TOKEN_KEY = 'v8-token'
1
+ export const TOKEN_KEY = 'lambo-token'
3
2
 
4
3
  export const COOKIE_KEY = 'lambo-sso-key'
5
4
 
5
+ export const SSO_TOKEN_KEY = 'lambo-sso-token'
6
+
6
7
  export function objEqual(obj1, obj2) {
7
8
  const keysArr1 = Object.keys(obj1)
8
9
  const keysArr2 = Object.keys(obj2)
@@ -152,14 +153,20 @@ export const showTitle = (item, vm) => {
152
153
  /**
153
154
  * @description 本地存储和获取标签导航列表
154
155
  */
155
- export const setTagNavListInLocalstorage = list => {
156
- localStorage.tagNaveList = JSON.stringify(list)
156
+ export const setTagNavListInLocalstorage = (list , key) => {
157
+ if (!key) {
158
+ key = 'LD-tagNavList';
159
+ }
160
+ localStorage[key] = JSON.stringify(list)
157
161
  }
158
162
  /**
159
163
  * @returns {Array} 其中的每个元素只包含路由原信息中的name, path, meta三项
160
164
  */
161
- export const getTagNavListFromLocalstorage = () => {
162
- const list = localStorage.tagNaveList
165
+ export const getTagNavListFromLocalstorage = (key) => {
166
+ if (!key) {
167
+ key = 'LD-tagNavList';
168
+ }
169
+ const list = localStorage[key]
163
170
  return list ? JSON.parse(list) : []
164
171
  }
165
172
 
@@ -265,7 +272,7 @@ export const getArrayFromFile = (file) => {
265
272
  reader.readAsText(file) // 以文本格式读取
266
273
  let arr = []
267
274
  reader.onload = function (evt) {
268
- let data = evt.target.result // 读到的数据
275
+ let data = evt.target.card // 读到的数据
269
276
  let pasteData = data.trim()
270
277
  arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
271
278
  return row.split('\t')
@@ -357,7 +364,7 @@ export const routeEqual = (route1, route2) => {
357
364
  const params2 = route2.params || {}
358
365
  const query1 = route1.query || {}
359
366
  const query2 = route2.query || {}
360
- return (route1.name === route2.name) //&& objEqual(params1, params2) && objEqual(query1, query2)
367
+ return (route1.name === route2.name) && objEqual(params1, params2) && objEqual(query1, query2)
361
368
  }
362
369
 
363
370
  /**
@@ -517,3 +524,72 @@ export function oneOf (value, validList) {
517
524
  }
518
525
  return false
519
526
  }
527
+
528
+ export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
529
+ for (const item of arr) {
530
+ if (item[filterKey] && item[filterKey] == filterValue) {
531
+ return item;
532
+ }
533
+ let result = null;
534
+ if (item[recursionKey]) {
535
+ result = recursionKeyFindItem(item[recursionKey], filterKey, filterValue, recursionKey);
536
+ if (result) {
537
+ return result;
538
+ }
539
+ }
540
+ }
541
+ return null;
542
+ };
543
+
544
+ export const filterMenuName = (menuList, name) => {
545
+ return recursionKeyFindItem(menuList, 'name', name, 'children')
546
+ };
547
+
548
+ export const filterMenuUri = (menuList, name) => {
549
+ return recursionKeyFindItem(menuList, 'uri', name, 'children')
550
+ };
551
+
552
+ export const tagExists = (taglist, name) => {
553
+ return taglist && taglist.filter(item => item.name === name).length > 0;
554
+ };
555
+
556
+ export const getPreviousTagIndex = (tagList, name) => {
557
+ let count = 0;
558
+ if (tagList && name) {
559
+ for (let i = 0 ;i < tagList.length; i++) {
560
+ let item = tagList[i];
561
+ if (item.name == name) {
562
+ count = i - 1;
563
+ if (count < 0) {
564
+ count = 0;
565
+ }
566
+ return count;
567
+ }
568
+ }
569
+ }
570
+ return count;
571
+ };
572
+
573
+ export const getDelTagIndex = (tagList, name) => {
574
+ let count = 1;
575
+ if (tagList && name) {
576
+ for (let i = 1 ;i < tagList.length; i++) {
577
+ let item = tagList[i];
578
+ if (item.name !== name) {
579
+ return count;
580
+ }
581
+ }
582
+ }
583
+ return count;
584
+ }
585
+
586
+ export const turnToPage = (vm, name ,url) =>{
587
+ if (window.top && window.top.location.href != window.location.href) {
588
+ sessionStorage.removeItem('activeName')
589
+ window.parent.location.href = url;
590
+ } else {
591
+ vm.$router.push({
592
+ name: name
593
+ })
594
+ }
595
+ }
package/utils/theme.js CHANGED
@@ -35,7 +35,7 @@ const changeByTheme = (theme) => {
35
35
  styleTag.id = "customStyle";
36
36
  document.body.appendChild(styleTag);
37
37
  }
38
- if (theme?.style) {
38
+ if (theme&&theme.style) {
39
39
  styleTag.innerHTML = theme.style;
40
40
  }
41
41
  };
@@ -0,0 +1,25 @@
1
+ export const setParentRefs = (parentVm, targetVm, refKey) => {
2
+ let hasFind = false;
3
+ if (parentVm.$refs) {
4
+ //遍历父组件的refs里注册的组件
5
+ Object.entries(parentVm.$refs).forEach(([parentKey, parentValue]) => {
6
+ //找到targetVm组件
7
+ if (parentValue === targetVm) {
8
+ hasFind = true;
9
+ //遍历targetVm组件上注册的refKey组件
10
+ Object.entries(targetVm.$refs[refKey]).forEach(([key, value])=>{
11
+ //找到refKey组件methods里面的function
12
+ if(key.charAt(0) !== '$'
13
+ && key.charAt(0) !== '_'
14
+ && typeof value == 'function'){
15
+ //将function添加到targetVm组件
16
+ parentVm.$refs[parentKey][key] = value
17
+ }
18
+ })
19
+ }
20
+ })
21
+ }
22
+ if (!hasFind && parentVm.$parent) {
23
+ setParentRefs(parentVm.$parent, targetVm, refKey)
24
+ }
25
+ }