xianniu-ui 0.9.0 → 0.9.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -65,6 +65,7 @@ export default {
65
65
  },
66
66
  },
67
67
  filters: {
68
+ // 处理精度
68
69
  doPrecision(value, precision, isRoundUp) {
69
70
  const exponentialForm = Number(`${value}e${precision}`);
70
71
  const rounded = isRoundUp
@@ -72,6 +73,7 @@ export default {
72
73
  : Math.floor(exponentialForm);
73
74
  return Number(`${rounded}e-${precision}`).toFixed(precision);
74
75
  },
76
+ // 处理格式
75
77
  doFormat(value, hasSeparator, separator) {
76
78
  if (!hasSeparator) {
77
79
  return value;
@@ -99,6 +101,7 @@ export default {
99
101
  ? `${sign}${formateValue.value}.${decimalValue}`
100
102
  : `${sign}${formateValue.value}`;
101
103
  },
104
+ // 转换为大写
102
105
  doCapital(value) {
103
106
  return numberCapital(value);
104
107
  },
@@ -121,6 +124,7 @@ export default {
121
124
  },
122
125
  },
123
126
  computed: {
127
+ // 计算合法精度
124
128
  legalPrecision() {
125
129
  return this.precision > 0 ? this.precision : 0;
126
130
  },
@@ -135,7 +139,7 @@ export default {
135
139
  this.isMounted = true;
136
140
  },
137
141
  methods: {
138
- // MARK: private methods
142
+ // 动画显示数值变化
139
143
  $_doAnimateDisplay(fromValue = 0, toValue = 0) {
140
144
  /* istanbul ignore next */
141
145
  const step = (percent) => {
@@ -17,6 +17,7 @@
17
17
  "gulp": "^4.0.2",
18
18
  "gulp-autoprefixer": "^8.0.0",
19
19
  "gulp-cssmin": "^0.2.0",
20
- "gulp-sass": "^5.1.0"
20
+ "gulp-sass": "^5.1.0",
21
+ "sass": "^1.26.2"
21
22
  }
22
23
  }
package/public/index.html CHANGED
@@ -1,18 +1,18 @@
1
- <!DOCTYPE html>
2
- <html lang="">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
- <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
- <title><%= htmlWebpackPlugin.options.title %></title>
9
- <link rel="stylesheet" href="//shadow.elemecdn.com/npm/highlight.js@9.3.0/styles/color-brewer.css">
10
- </head>
11
- <body>
12
- <noscript>
13
- <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
14
- </noscript>
15
- <div id="appDoc"></div>
16
- <!-- built files will be auto injected -->
17
- </body>
18
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
+ <title><%= htmlWebpackPlugin.options.title %></title>
9
+ <link rel="stylesheet" href="//shadow.elemecdn.com/npm/highlight.js@9.3.0/styles/color-brewer.css">
10
+ </head>
11
+ <body>
12
+ <noscript>
13
+ <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
14
+ </noscript>
15
+ <div id="appDoc"></div>
16
+ <!-- built files will be auto injected -->
17
+ </body>
18
+ </html>
@@ -1,28 +1,28 @@
1
- {
2
- "name": "xianniu-utils",
3
- "version": "0.1.1",
4
- "lockfileVersion": 2,
5
- "requires": true,
6
- "packages": {
7
- "node_modules/dayjs": {
8
- "version": "1.11.7",
9
- "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
10
- "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
11
- },
12
- "node_modules/decimal.js": {
13
- "version": "10.4.3",
14
- "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
15
- "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
16
- },
17
- "node_modules/good-storage": {
18
- "version": "1.1.1",
19
- "resolved": "https://registry.npmjs.org/good-storage/-/good-storage-1.1.1.tgz",
20
- "integrity": "sha512-+0UEpRT03fJgEJoeTVVz41ISC5+jaQrDIWatQ4BoDQfOiBBsjNanymi9sAtLFdEAADQN0FYR8mGpeqxSCe8oXQ=="
21
- },
22
- "node_modules/lodash": {
23
- "version": "4.17.21",
24
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
25
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
26
- }
27
- }
28
- }
1
+ {
2
+ "name": "xianniu-utils",
3
+ "version": "0.1.3",
4
+ "lockfileVersion": 2,
5
+ "requires": true,
6
+ "packages": {
7
+ "node_modules/dayjs": {
8
+ "version": "1.11.7",
9
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
10
+ "integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
11
+ },
12
+ "node_modules/decimal.js": {
13
+ "version": "10.4.3",
14
+ "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
15
+ "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
16
+ },
17
+ "node_modules/good-storage": {
18
+ "version": "1.1.1",
19
+ "resolved": "https://registry.npmjs.org/good-storage/-/good-storage-1.1.1.tgz",
20
+ "integrity": "sha512-+0UEpRT03fJgEJoeTVVz41ISC5+jaQrDIWatQ4BoDQfOiBBsjNanymi9sAtLFdEAADQN0FYR8mGpeqxSCe8oXQ=="
21
+ },
22
+ "node_modules/lodash": {
23
+ "version": "4.17.21",
24
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
25
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
26
+ }
27
+ }
28
+ }
@@ -1,14 +1,14 @@
1
- {
2
- "name": "xianniu-utils",
3
- "version": "0.1.3",
4
- "description": "一些工具",
5
- "main": "index.js",
6
- "author": "liuzengwei",
7
- "license": "MIT",
8
- "dependencies": {
9
- "dayjs": "^1.10.7",
10
- "decimal.js": "^10.4.2",
11
- "good-storage": "^1.1.1",
12
- "lodash": "^4.17.21"
13
- }
14
- }
1
+ {
2
+ "name": "xianniu-utils",
3
+ "version": "0.1.3",
4
+ "description": "一些工具",
5
+ "main": "index.js",
6
+ "author": "liuzengwei",
7
+ "license": "MIT",
8
+ "dependencies": {
9
+ "dayjs": "^1.10.7",
10
+ "decimal.js": "^10.4.2",
11
+ "good-storage": "^1.1.1",
12
+ "lodash": "^4.17.21"
13
+ }
14
+ }
@@ -133,34 +133,39 @@ const getFileNameFromUrl = function(url){
133
133
  /**
134
134
  * 根据某个key 对数组去重合并
135
135
  * @param {array} arr 需要合并的数组
136
- * @param {string} key 传入要合并的key
136
+ * @param {string} key 传入要合并的key ,如果是多个key,传入数组
137
137
  * @return {array} result
138
138
  */
139
139
  const arrMerge = (arr = [], key = '') => {
140
- if (!key) {
141
- throw new Error('error arguments: key is required')
140
+ // 处理单个字符串的key,转换为数组形式
141
+ const keys = Array.isArray(key) ? key : [key]
142
+
143
+ if (!keys.length || (keys.length === 1 && keys[0] === '')) {
144
+ throw new Error('错误参数: key是必需的')
142
145
  }
143
- if (!arr.length) return
144
- var map = {}; var result = []
145
-
146
- for (var i = 0; i < arr.length; i++) {
147
- var ai = arr[i]
148
- if (!map[ai[key]]) {
149
- result.push({
150
- [key]: ai[key],
151
- children: [ai]
146
+ if (!arr.length) return []
147
+
148
+ // 生成复合键的工具函数
149
+ const getKey = (item) => keys.map(k => item[k]).join('|')
150
+ const result = []
151
+ const map = {}
152
+
153
+ for (const item of arr) {
154
+ const compositeKey = getKey(item)
155
+
156
+ if (!map[compositeKey]) {
157
+ const resultItem = { children: [item] }
158
+ keys.forEach(k => {
159
+ resultItem[k] = item[k]
152
160
  })
153
- map[ai[key]] = ai
161
+
162
+ result.push(resultItem)
163
+ map[compositeKey] = resultItem
154
164
  } else {
155
- for (var j = 0; j < result.length; j++) {
156
- var dj = result[j]
157
- if (dj[key] === ai[key]) {
158
- dj.children.push(ai)
159
- break
160
- }
161
- }
165
+ map[compositeKey].children.push(item)
162
166
  }
163
167
  }
168
+
164
169
  return result
165
170
  }
166
171
  // 判空