@lambo-design/shared 1.0.0-beta.60 → 1.0.0-beta.61

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.json CHANGED
@@ -1,22 +1,22 @@
1
- {
2
- "name": "@lambo-design/shared",
3
- "version": "1.0.0-beta.60",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {},
7
- "author": "lambo",
8
- "license": "ISC",
9
- "publishConfig": {
10
- "access": "public",
11
- "registry": "https://registry.npmjs.org/"
12
- },
13
- "dependencies": {
14
- "axios": "^0.24.0",
15
- "axios-cache-plugin": "^0.1.0",
16
- "qs": "^6.11.0",
17
- "xlsx": "http://cicd.lambo.top/package/cdn/xlsx-0.19.1.tgz",
18
- "classnames": "^2.3.1",
19
- "xlsx-style": "^0.8.13",
20
- "moment": "2.29.4"
21
- }
22
- }
1
+ {
2
+ "name": "@lambo-design/shared",
3
+ "version": "1.0.0-beta.61",
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
+ }
package/utils/assist.js CHANGED
@@ -1,88 +1,110 @@
1
- // deepCopy
2
-
3
-
4
- export function deepCopy(data) {
5
- let i;
6
- const t = typeOf(data);
7
- let o;
8
-
9
- if (t === 'array') {
10
- o = [];
11
- } else if (t === 'object') {
12
- o = {};
13
- } else {
14
- return data;
15
- }
16
-
17
- if (t === 'array') {
18
- for (i = 0; i < data.length; i++) {
19
- o.push(deepCopy(data[i]));
20
- }
21
- } else if (t === 'object') {
22
- for (i in data) {
23
- o[i] = deepCopy(data[i]);
24
- }
25
- }
26
- return o;
27
- }
28
-
29
- export function typeOf(obj) {
30
- const toString = Object.prototype.toString;
31
- const map = {
32
- '[object Boolean]': 'boolean',
33
- '[object Number]': 'number',
34
- '[object String]': 'string',
35
- '[object Function]': 'function',
36
- '[object Array]': 'array',
37
- '[object Date]': 'date',
38
- '[object RegExp]': 'regExp',
39
- '[object Undefined]': 'undefined',
40
- '[object Null]': 'null',
41
- '[object Object]': 'object'
42
- };
43
- return map[toString.call(obj)];
44
- }
45
-
46
- export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
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
- }
64
- }
65
- }, operationName);
66
-
67
- }
68
-
69
- export function operateHref(vm, h, currentRow, operationName, operation, type, permission) {
70
- return h('a', {
71
- style: {
72
- margin: '0 4px'
73
- },
74
- directives: [(permission === '' || permission === null) ? '' : {
75
- name: "permission",
76
- value: permission
77
- }],
78
- on: {
79
- 'click': () => {
80
- operation(vm, currentRow);
81
- }
82
- }
83
- }, operationName);
84
- }
85
-
86
- export function isJson(arg) {
87
- return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase() == "[object object]" && !arg.length
88
- };
1
+ // deepCopy
2
+
3
+
4
+ export function deepCopy(data) {
5
+ let i;
6
+ const t = typeOf(data);
7
+ let o;
8
+
9
+ if (t === 'array') {
10
+ o = [];
11
+ } else if (t === 'object') {
12
+ o = {};
13
+ } else {
14
+ return data;
15
+ }
16
+
17
+ if (t === 'array') {
18
+ for (i = 0; i < data.length; i++) {
19
+ o.push(deepCopy(data[i]));
20
+ }
21
+ } else if (t === 'object') {
22
+ for (i in data) {
23
+ o[i] = deepCopy(data[i]);
24
+ }
25
+ }
26
+ return o;
27
+ }
28
+ export function deepMerge(target, ...sources) {
29
+ if (!sources.length) return target;
30
+ const source = sources.shift();
31
+
32
+ if (isObject(target) && isObject(source)) {
33
+ for (const key in source) {
34
+ if (isObject(source[key])) {
35
+ if (!target[key]) Object.assign(target, { [key]: {} });
36
+ deepMerge(target[key], source[key]);
37
+ } else {
38
+ Object.assign(target, { [key]: source[key] });
39
+ }
40
+ }
41
+ }
42
+
43
+ return deepMerge(target, ...sources);
44
+ }
45
+
46
+ export function typeOf(obj) {
47
+ const toString = Object.prototype.toString;
48
+ const map = {
49
+ '[object Boolean]': 'boolean',
50
+ '[object Number]': 'number',
51
+ '[object String]': 'string',
52
+ '[object Function]': 'function',
53
+ '[object Array]': 'array',
54
+ '[object Date]': 'date',
55
+ '[object RegExp]': 'regExp',
56
+ '[object Undefined]': 'undefined',
57
+ '[object Null]': 'null',
58
+ '[object Object]': 'object'
59
+ };
60
+ return map[toString.call(obj)];
61
+ }
62
+
63
+ export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
64
+ return h('Button', {
65
+ props: {
66
+ type: type,
67
+ size: "small",
68
+ ghost: true,
69
+ },
70
+ directives: [(permission === '' || permission === null) ? '' : {
71
+ name: "permission",
72
+ value: permission
73
+ }],
74
+ style: {
75
+ margin: '0 2px'
76
+ },
77
+ on: {
78
+ 'click': () => {
79
+ operation(vm, currentRow);
80
+ }
81
+ }
82
+ }, operationName);
83
+
84
+ }
85
+
86
+ export function operateHref(vm, h, currentRow, operationName, operation, type, permission) {
87
+ return h('a', {
88
+ style: {
89
+ margin: '0 4px'
90
+ },
91
+ directives: [(permission === '' || permission === null) ? '' : {
92
+ name: "permission",
93
+ value: permission
94
+ }],
95
+ on: {
96
+ 'click': () => {
97
+ operation(vm, currentRow);
98
+ }
99
+ }
100
+ }, operationName);
101
+ }
102
+
103
+ export function isJson(arg) {
104
+ return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase() == "[object object]" && !arg.length
105
+ };
106
+
107
+
108
+ export function isObject(item) {
109
+ return (item && typeof item === 'object' && !Array.isArray(item));
110
+ }
File without changes
File without changes