@indfnd/utils 0.0.31 → 0.0.33

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,11 +1,7 @@
1
1
  {
2
2
  "name": "@indfnd/utils",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "author": "huxuetong",
5
- "repository": {
6
- "type": "git",
7
- "url": "http://git.inspur.com/imp-ec/ind-front/ind-utils.git"
8
- },
9
5
  "publishConfig": {
10
6
  "registry": "https://registry.npmjs.org/"
11
7
  },
@@ -31,16 +27,18 @@
31
27
  "type-check": "vue-tsc --noEmit -p tsconfig.json --composite false",
32
28
  "build-only": "vite build",
33
29
  "dts": "rimraf types/ && vue-tsc -p tsconfig.types.json",
34
- "release": "node build/auto-build.js && yarn release-patch && git push --follow-tags && yarn publish --access public",
30
+ "release": "node build/auto-build.js && yarn release-patch && git push --follow-tags && yarn re-publish",
35
31
  "release-major": "standard-version --release-as major",
36
32
  "release-minor": "standard-version --release-as minor",
37
- "release-patch": "standard-version --release-as patch"
33
+ "release-patch": "standard-version --release-as patch",
34
+ "re-publish": "yarn publish --access public"
38
35
  },
39
36
  "dependencies": {
40
37
  "axios": "^0.21.4",
41
38
  "dayjs": "^1.11.9",
42
39
  "lodash": "^4.17.21",
43
40
  "md5": "^2.3.0",
41
+ "nanoid": "^3.3.7",
44
42
  "qs": "^6.10.1"
45
43
  },
46
44
  "devDependencies": {
package/src/utils/date.ts CHANGED
@@ -9,7 +9,7 @@ export function str2Date(value: string): Date {
9
9
  }
10
10
 
11
11
  export function formatDate(value: string): string {
12
- if (value) {
12
+ if (value && /^[0-9]+$/.test(value)) {
13
13
  switch (value.length) {
14
14
  case 14: {
15
15
  return dayjs(value, ['YYYYMMDDHHmmss']).format('YYYY-MM-DD HH:mm:ss')
@@ -28,12 +28,12 @@ export function formatDate(value: string): string {
28
28
  }
29
29
  }
30
30
  } else {
31
- return '-'
31
+ return value || '-'
32
32
  }
33
33
  }
34
34
 
35
35
  export function formatDateChinese(value: string): string {
36
- if (value) {
36
+ if (value && /^[0-9]+$/.test(value)) {
37
37
  switch (value.length) {
38
38
  case 14: {
39
39
  return dayjs(value, ['YYYYMMDDHHmmss']).format('YYYY年MM月DD日 HH:mm:ss')
@@ -52,6 +52,6 @@ export function formatDateChinese(value: string): string {
52
52
  }
53
53
  }
54
54
  } else {
55
- return '-'
55
+ return value || '-'
56
56
  }
57
57
  }
@@ -95,5 +95,12 @@ export function responseInterceptors(response) {
95
95
  }
96
96
 
97
97
  export function inspectorError(error) {
98
+ if (error?.code === 'ECONNABORTED') {
99
+ // 超时
100
+ window.apiErrorHandler && window.apiErrorHandler('请求超时,请稍后再试')
101
+ }
102
+ if (error.response.status !== 200) {
103
+ window.apiErrorHandler && window.apiErrorHandler('请求出错了')
104
+ }
98
105
  return Promise.reject(error)
99
106
  }
package/src/utils/uuid.ts CHANGED
@@ -1,3 +1,9 @@
1
+ import { customAlphabet } from 'nanoid'
2
+
3
+ const uuid = customAlphabet('0123456789abcdef', 32)
4
+
5
+ export { uuid }
6
+
1
7
  /**
2
8
  * 生成uid
3
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"interceptors.d.ts","sourceRoot":"","sources":["../../../src/utils/request/interceptors.ts"],"names":[],"mappings":"AAuBA,wBAAgB,mBAAmB,CAAC,MAAM,KAAA,OAwCzC;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,OA6B5C;AAED,wBAAgB,cAAc,CAAC,KAAK,KAAA,kBAEnC"}
1
+ {"version":3,"file":"interceptors.d.ts","sourceRoot":"","sources":["../../../src/utils/request/interceptors.ts"],"names":[],"mappings":"AAuBA,wBAAgB,mBAAmB,CAAC,MAAM,KAAA,OAwCzC;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,OA6B5C;AAED,wBAAgB,cAAc,CAAC,KAAK,KAAA,kBASnC"}
@@ -1,3 +1,5 @@
1
+ declare const uuid: (size?: number) => string
2
+ export { uuid }
1
3
  /**
2
4
  * 生成uid
3
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,IAAI,WAMnB"}
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,IAAI,2BAAyC,CAAA;AAEnD,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf;;GAEG;AACH,wBAAgB,IAAI,WAMnB"}