cloud-web-corejs 1.0.6 → 1.0.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -158,7 +158,8 @@
158
158
  "src/store",
159
159
  "src/resources/js",
160
160
  "src/lang/index.js",
161
- "src//layout",
161
+ "src/layout",
162
+ "src/filters",
162
163
  "permission.js",
163
164
  "src/index.js",
164
165
  "src/App.vue"
@@ -0,0 +1,69 @@
1
+ /**version-1.0*/
2
+ // import parseTime, formatTime and set to filter
3
+ export { parseTime, formatTime } from '@base/utils'
4
+
5
+ /**
6
+ * Show plural label if time is plural number
7
+ * @param {number} time
8
+ * @param {string} label
9
+ * @return {string}
10
+ */
11
+ function pluralize(time, label) {
12
+ if (time === 1) {
13
+ return time + label
14
+ }
15
+ return time + label + 's'
16
+ }
17
+
18
+ /**
19
+ * @param {number} time
20
+ */
21
+ export function timeAgo(time) {
22
+ const between = Date.now() / 1000 - Number(time)
23
+ if (between < 3600) {
24
+ return pluralize(~~(between / 60), ' minute')
25
+ } else if (between < 86400) {
26
+ return pluralize(~~(between / 3600), ' hour')
27
+ } else {
28
+ return pluralize(~~(between / 86400), ' day')
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Number formatting
34
+ * like 10000 => 10k
35
+ * @param {number} num
36
+ * @param {number} digits
37
+ */
38
+ export function numberFormatter(num, digits) {
39
+ const si = [
40
+ { value: 1E18, symbol: 'E' },
41
+ { value: 1E15, symbol: 'P' },
42
+ { value: 1E12, symbol: 'T' },
43
+ { value: 1E9, symbol: 'G' },
44
+ { value: 1E6, symbol: 'M' },
45
+ { value: 1E3, symbol: 'k' }
46
+ ]
47
+ for (let i = 0; i < si.length; i++) {
48
+ if (num >= si[i].value) {
49
+ return (num / si[i].value).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
50
+ }
51
+ }
52
+ return num.toString()
53
+ }
54
+
55
+ /**
56
+ * 10000 => "10,000"
57
+ * @param {number} num
58
+ */
59
+ export function toThousandFilter(num) {
60
+ return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
61
+ }
62
+
63
+ /**
64
+ * Upper case first char
65
+ * @param {String} string
66
+ */
67
+ export function uppercaseFirst(string) {
68
+ return string.charAt(0).toUpperCase() + string.slice(1)
69
+ }
package/src/index.js CHANGED
@@ -13,11 +13,12 @@ import router from '@/router';
13
13
  import '@/icons'; // icon
14
14
  import '@base/permission'; // permission control
15
15
 
16
- import * as filters from '@/filters'; // global filters
16
+ import * as filters from '@base/filters'; // global filters
17
17
 
18
18
  // main.js 文件添加以下代码
19
19
 
20
20
  import BaseKeepAlive from '@base/utils/keepAlive.js'
21
+
21
22
  Vue.component('BaseKeepAlive', BaseKeepAlive)
22
23
 
23
24
  import VXETable from 'vxe-table';
@@ -109,6 +110,7 @@ import oplogTable from '@base/components/oplogTable/index.vue'
109
110
  Vue.component(oplogTable.name, oplogTable);
110
111
 
111
112
  import baseInputBatch from '@base/components/baseInputBatch/index.vue'
113
+
112
114
  Vue.component(baseInputBatch.name, baseInputBatch);
113
115
 
114
116
  Vue.component('baseInputExport', () => import('@base/components/baseInputExport/index.vue'));