n20-common-lib 2.8.30 → 2.8.32

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": "n20-common-lib",
3
- "version": "2.8.30",
3
+ "version": "2.8.32",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -774,4 +774,9 @@ $--input-max: 224px;
774
774
  .el-form-item--small .el-form-item__label {
775
775
  line-height: 1.5;
776
776
  }
777
+ }
778
+
779
+ /* 文本域 字数提示高度处理 */
780
+ .el-textarea .el-input__count {
781
+ line-height: 1;
777
782
  }
@@ -138,10 +138,10 @@
138
138
  </template>
139
139
 
140
140
  <script>
141
- import axios from '../../../utils/axios.js';
142
- import { $lc } from '../../../utils/i18n/index';
143
- import importG from '../../../utils/importGlobal.js';
144
- import child from './child.vue';
141
+ import axios from '../../../utils/axios.js'
142
+ import { $lc } from '../../../utils/i18n/index'
143
+ import importG from '../../../utils/importGlobal.js'
144
+ import child from './child.vue'
145
145
  export default {
146
146
  components: {
147
147
  child
package/src/index.js CHANGED
@@ -112,6 +112,7 @@ import _numerify from 'numerify'
112
112
  import getJsonc from './assets/getJsonc.js'
113
113
  import realUrl from './assets/realUrl.js'
114
114
  import { has as isHas, hasG as isHasG } from './directives/VHas/index.js'
115
+ import { getAnyLevel, setAnyLevel } from './utils/anyLevel.js'
115
116
  import asyncGetRelaNos from './utils/asyncGetRelaNos.js'
116
117
  import auth from './utils/auth.js'
117
118
  import axios from './utils/axios.js'
@@ -120,6 +121,7 @@ import forEachs from './utils/forEachs'
120
121
  import { refreshTab, setTabs } from './utils/handleTab.js'
121
122
  import imgLoad from './utils/imgLoad.js'
122
123
  import importG from './utils/importGlobal.js' // 联合加载组件保存位置
124
+ import { type } from './utils/judgeType.js'
123
125
  import list2tree from './utils/list2tree'
124
126
  import { msgPor, msgboxPor } from './utils/msgboxPor.js'
125
127
  import N from './utils/numberPor.js' // 扩展Number
@@ -363,6 +365,7 @@ export {
363
365
  dayjs,
364
366
  downloadBlob,
365
367
  forEachs,
368
+ getAnyLevel,
366
369
  getJsonc,
367
370
  imgLoad,
368
371
  importG,
@@ -381,7 +384,9 @@ export {
381
384
  relativeDate,
382
385
  relativeNowDate,
383
386
  repairEl,
387
+ setAnyLevel,
384
388
  // 页签/路由
385
389
  setTabs,
390
+ type,
386
391
  version
387
392
  }
@@ -2502,13 +2502,14 @@ const config = {
2502
2502
  }
2503
2503
 
2504
2504
  function init() {
2505
+ let url = window.NetSignName || `/portal/天诚安信数字证书助手-3.7.7.0.exe`
2505
2506
  try {
2506
2507
  TCA.config(config)
2507
2508
  } catch (error) {
2508
2509
  Notification({
2509
2510
  title: '提示',
2510
2511
  dangerouslyUseHTMLString: true,
2511
- message: `<div>检测到您的电脑中没有安装签名助手,为了不影响使用请使用管理员权限<a class="color-primary" href="/portal/天诚安信数字证书助手-3.7.7.0.exe" download>下载安装</a>天诚安信数字证书助手</div>`,
2512
+ message: `<div>检测到您的电脑中没有安装签名助手,为了不影响使用请使用管理员权限<a class="color-primary" href="${url}" download>下载安装</a>天诚安信数字证书助手</div>`,
2512
2513
  duration: 5000
2513
2514
  })
2514
2515
  }
@@ -2562,6 +2563,11 @@ export function getCert(dn) {
2562
2563
  // 签名方法
2563
2564
  export function getSign(plain, dn) {
2564
2565
  init()
2566
+ if (typeof plain === 'object') {
2567
+ plainText = JSON.stringify(plain)
2568
+ } else {
2569
+ plainText = plain
2570
+ }
2565
2571
  try {
2566
2572
  if (dn === undefined) {
2567
2573
  dn = getDN()
@@ -1804,6 +1804,11 @@ function getDN() {
1804
1804
 
1805
1805
  // 签名方法
1806
1806
  export function getSign(plain, dn) {
1807
+ if (typeof plain === 'object') {
1808
+ plainText = JSON.stringify(plain)
1809
+ } else {
1810
+ plainText = plain
1811
+ }
1807
1812
  try {
1808
1813
  if (dn === undefined) {
1809
1814
  dn = getDN()
@@ -0,0 +1,123 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { type } from './judgeType'
3
+
4
+ function getDefalutValue(path) {
5
+ if (path.defalutValue) {
6
+ return path.defalutValue()
7
+ }
8
+ if (path.type === 'array') {
9
+ return []
10
+ }
11
+ if (path.type === 'map') {
12
+ return new Map()
13
+ }
14
+
15
+ return {}
16
+ }
17
+
18
+ export function getAnyPath(obj, paths) {
19
+ if (type(paths) !== 'array' || !paths.length) {
20
+ return undefined
21
+ }
22
+ let parent = obj
23
+ for (let i = 0; i < paths.length; i++) {
24
+ const path = paths[i]
25
+ const t = type(parent)
26
+ if (t === 'object' || t === 'array') {
27
+ parent = parent[path.key]
28
+ } else if (t === 'map') {
29
+ parent = parent.get(path.key)
30
+ } else {
31
+ return undefined
32
+ }
33
+ }
34
+ return parent
35
+ }
36
+
37
+ export function setAnyPath(obj, paths, value) {
38
+ if (type(paths) !== 'array' || !paths.length) {
39
+ return false
40
+ }
41
+ let parent = obj
42
+
43
+ for (let i = 0; i < paths.length - 1; i++) {
44
+ const path = paths[i]
45
+ const t = type(parent)
46
+ if (t === 'object' || t === 'array') {
47
+ // undefined | null
48
+ if (parent[path.key] != null) {
49
+ parent = parent[path.key]
50
+ } else {
51
+ parent[path.key] = getDefalutValue(path)
52
+ parent = parent[path.key]
53
+ }
54
+ } else if (t === 'map') {
55
+ // undefined | null
56
+ if (parent.get(path.key) != null) {
57
+ parent = parent.get(path.key)
58
+ } else {
59
+ parent.set(path.key, getDefalutValue(path))
60
+ parent = parent.get(path.key)
61
+ }
62
+ } else {
63
+ return false
64
+ }
65
+ }
66
+
67
+ // 目标节点设置值
68
+ const t = type(parent)
69
+ const path = paths[paths.length - 1]
70
+ if (t === 'object' || t === 'array') {
71
+ parent[path.key] = value
72
+ } else if (t === 'map') {
73
+ parent.set(path.key, value)
74
+ } else {
75
+ return false
76
+ }
77
+
78
+ return true
79
+ }
80
+
81
+ function parseKeys(keys) {
82
+ if (typeof keys !== 'string' && typeof keys !== 'number') {
83
+ return []
84
+ }
85
+ // keys = 'a.0[].c:map.e'
86
+ const paths = String(keys)
87
+ .split('.')
88
+ .map((item) => {
89
+ if (item.indexOf('[]') !== -1) {
90
+ // [] 语法
91
+ return {
92
+ key: item.replace('[]', ''),
93
+ type: 'array'
94
+ }
95
+ } else if (item.indexOf(':') !== -1) {
96
+ // : 语法
97
+ const arr = item.split(':')
98
+ return {
99
+ key: arr[0],
100
+ type: arr[1]
101
+ }
102
+ } else {
103
+ // object
104
+ return {
105
+ key: item,
106
+ type: 'object'
107
+ }
108
+ }
109
+ })
110
+
111
+ return paths
112
+ }
113
+
114
+ export function getAnyLevel(obj, keys) {
115
+ return getAnyPath(obj, parseKeys(keys))
116
+ }
117
+ export function setAnyLevel(obj, keys, value) {
118
+ const paths = parseKeys(keys)
119
+ if (!paths.length) {
120
+ return false
121
+ }
122
+ return setAnyPath(obj, paths, value)
123
+ }
@@ -0,0 +1,75 @@
1
+ const toString = Object.prototype.toString
2
+
3
+ export function type(x, strict = false) {
4
+ strict = !!strict
5
+
6
+ // 修复 typeof null = object 的问题
7
+ if (x === null) {
8
+ return 'null'
9
+ }
10
+
11
+ const t = typeof x
12
+
13
+ // 严格模式下区分 NaN 和 number
14
+ if (strict && t === 'number' && isNaN(x)) {
15
+ return 'nan'
16
+ }
17
+
18
+ // number string boolean undefined symbol
19
+ if (t !== 'object') {
20
+ return t
21
+ }
22
+
23
+ let cls
24
+ let clsLow
25
+ try {
26
+ cls = toString.call(x).slice(8, -1)
27
+ clsLow = cls.toLowerCase()
28
+ } catch (e) {
29
+ // 处理 IE 下的 ActiveX 对象
30
+ return 'object'
31
+ }
32
+
33
+ if (clsLow !== 'object') {
34
+ if (strict) {
35
+ // 区分 NaN 和 new Number
36
+ if (clsLow === 'number' && isNaN(x)) {
37
+ return 'NaN'
38
+ }
39
+ // 区分 String() 和 new String()
40
+ if (clsLow === 'number' || clsLow === 'boolean' || clsLow === 'string') {
41
+ return cls
42
+ }
43
+ }
44
+ return clsLow
45
+ }
46
+
47
+ // eslint-disable-next-line eqeqeq
48
+ if (x.constructor == Object) {
49
+ return clsLow
50
+ }
51
+
52
+ // 处理 Object.create(null)
53
+ try {
54
+ // 处理早期 Firefox 浏览器的 __proto__
55
+ if (Object.getPrototypeOf(x) === null || x.__proto__ === null) {
56
+ return 'object'
57
+ }
58
+ } catch (e) {
59
+ // 处理 IE 下无 Object.getPrototypeOf 的情况
60
+ }
61
+
62
+ // 处理 function A() {}; new A
63
+ try {
64
+ const cname = x.constructor.name
65
+
66
+ if (typeof cname === 'string') {
67
+ return cname
68
+ }
69
+ } catch (e) {
70
+ // 处理无 constructor 的情况
71
+ }
72
+
73
+ // 处理 function A() {}; A.prototype.constructor = null; new A
74
+ return 'unknown'
75
+ }