n20-common-lib 2.22.83 → 2.22.85

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.22.83",
3
+ "version": "2.22.85",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -54,6 +54,7 @@
54
54
  "axios": "*",
55
55
  "dayjs": "*",
56
56
  "decimal.js": "^10.5.0",
57
+ "dom-zindex": "^1.0.6",
57
58
  "js-cookie": "^3.0.1",
58
59
  "jsencrypt": "^3.3.2",
59
60
  "jsonwebtoken": "^8.5.1",
@@ -182,9 +182,7 @@ th.vxe-header--column {
182
182
  font-weight: $--font-weight-primary;
183
183
  }
184
184
 
185
- .vxe-table--tooltip-wrapper {
186
- z-index: 9999 !important;
187
- }
185
+ // tooltip 使用公共层级动态分配,避免固定值遮挡后打开的弹窗。
188
186
 
189
187
  .cell-default-set-- .vxe-table--body-wrapper .vxe-body--row .vxe-body--column .vxe-cell .vxe-cell--label:empty::before {
190
188
  content: '--';
@@ -7,6 +7,7 @@ import { formatExchangeRate } from '../../utils/decimal'
7
7
  import { $lc } from '../../utils/i18n/index.js'
8
8
  import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
9
9
  import { getColumnField, getRowValue, getVxeCore, setVxeVersion } from './compat.js'
10
+ import installPopupZIndexBridge from '../../utils/popupZIndex'
10
11
 
11
12
 
12
13
  function getInstalledVxeVersion(vxe) {
@@ -153,6 +154,8 @@ if (vxeFormats && typeof vxeFormats.mixin === 'function') {
153
154
  }
154
155
 
155
156
  function install(Vue) {
157
+ // 原生 vxe-table 也接入 Element 弹层的公共层级。
158
+ installPopupZIndexBridge()
156
159
  Vue.use(vxeTable)
157
160
  }
158
161
 
@@ -142,6 +142,7 @@ import empty from '../Empty'
142
142
  import tableSetSize from '../TableSetSize/index.vue'
143
143
  import { $lc } from '../../utils/i18n/index.js'
144
144
  import { getColumnField, getEventField, isVxe320OrNewer, normalizeArray } from './compat.js'
145
+ import installPopupZIndexBridge from '../../utils/popupZIndex'
145
146
 
146
147
  /** 将 Element 表格风格的 show-overflow-tooltip 转为 vxe-column 的 show-overflow */
147
148
  function hasOverflowTooltipKey(item) {
@@ -209,6 +210,10 @@ const renderer = {
209
210
  }
210
211
  export default {
211
212
  name: 'TablePro',
213
+ beforeCreate() {
214
+ // 按需引用时,在子表格创建 tooltip 前完成旧版层级适配。
215
+ installPopupZIndexBridge()
216
+ },
212
217
  components: {
213
218
  tableSetSize,
214
219
  empty,
package/src/i18n.json CHANGED
@@ -6145,6 +6145,13 @@
6145
6145
  "vi": "Chứng chỉ đã hết hạn",
6146
6146
  "ja": "証明書の有効期限が切れています"
6147
6147
  },
6148
+ "证书已过期": {
6149
+ "en": "Certificate expired",
6150
+ "es": "Certificado caducado",
6151
+ "th": "ใบรับรองหมดอายุ",
6152
+ "vi": "Chứng chỉ đã hết hạn",
6153
+ "ja": "証明書の有効期限が切れています"
6154
+ },
6148
6155
  "证书已废止": {
6149
6156
  "en": "The certificate has been revoked",
6150
6157
  "es": "El certificado ha sido revocado",
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 对 NSGetCertsListInfo 中已满足业务条件的证书过滤过期项,再按到期时间倒序排列。
3
+ * 保留原始索引,后续签名继续使用 SDK 返回列表中的证书位置。
4
+ */
5
+ export function getValidCerts(matchedCerts) {
6
+ const now = Date.now()
7
+ return matchedCerts
8
+ .map(item => ({
9
+ ...item,
10
+ // SDK 已解码 validEnd,补齐 GMT 前的空格后按时间戳比较。
11
+ validEndTime: new Date(item.cert.validEnd?.replace(/GMT$/, ' GMT')).getTime()
12
+ }))
13
+ // 保留对缺失或无效日期的原有兼容行为,仅剔除明确过期的证书。
14
+ .filter(({ validEndTime }) => !(validEndTime <= now))
15
+ .sort((a, b) => {
16
+ // 无效日期放到最后;相同到期时间沿用原始列表顺序。
17
+ const aTime = Number.isNaN(a.validEndTime) ? -Infinity : a.validEndTime
18
+ const bTime = Number.isNaN(b.validEndTime) ? -Infinity : b.validEndTime
19
+ return bTime - aTime || a.index - b.index
20
+ })
21
+ }
@@ -2,6 +2,7 @@ import { $lc } from '../../utils/i18n/index.js'
2
2
  // Attached方式签名
3
3
  import { Message, Notification } from 'element-ui'
4
4
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
5
+ import { getValidCerts } from './dn.js'
5
6
 
6
7
 
7
8
  const {
@@ -163,24 +164,31 @@ function parseCA(dn) {
163
164
  * 验证Dn是否存在于Dn列表中
164
165
  * @param {Array} dnList 获取到的Dn列表
165
166
  * @param {string} dn 要验证的Dn
166
- * @returns {number} - 如果找到匹配的 DN,则返回其在 dnList 中的索引;如果未找到,则返回 -1
167
+ * @returns {number} - 返回可用证书的原始索引;未匹配或全部过期时返回 -1
167
168
  */
168
169
  function verifyDn(dnList, dn) {
169
170
  let userDnAttrsArr = dn.split(',').map((c) => c.trim())
170
171
 
171
- let index = -1
172
- dnList.find((C, i) => {
173
- let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
174
- if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
175
- index = i
176
- return true
177
- }
178
- })
179
- if (index === -1) {
180
- let dnList = dnList?.map((res) => res.certDN)?.join(',')
181
- Message.error(`${$lc('证书Dn不匹配:')}${dnList}${$lc('里面无法匹配===>')}${dn}`)
182
- return index
172
+ // 沿用本分支现有 DN 属性匹配条件,同时保留每张证书的原始索引。
173
+ const matchedCerts = dnList
174
+ .map((cert, index) => ({ cert, index }))
175
+ .filter(({ cert }) => {
176
+ let dnAttrsArr = cert.certDN.split(',').map((c) => c.trim())
177
+ return dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))
178
+ })
179
+ if (matchedCerts.length === 0) {
180
+ const certDns = dnList.map((res) => res.certDN).join(',')
181
+ Message.error(`${$lc('证书Dn不匹配:')}${certDns}${$lc('里面无法匹配===>')}${dn}`)
182
+ return -1
183
+ }
184
+
185
+ // 业务匹配后过滤过期项,优先使用 validEnd 最晚的证书。
186
+ const validCerts = getValidCerts(matchedCerts)
187
+ if (validCerts.length === 0) {
188
+ Message.error($lc('证书已过期'))
189
+ return -1
183
190
  }
191
+ const index = validCerts[0].index
184
192
  if (index !== -1) {
185
193
  // GMT时间字符串
186
194
  const gmtTimeString = dnList[index].validEnd?.replace(/GMT$/, ' GMT')
@@ -2,6 +2,7 @@ import { $lc } from '../../../utils/i18n/index.js'
2
2
  // Attached方式签名
3
3
  import { Message, MessageBox,Notification } from 'element-ui'
4
4
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
5
+ import { getValidCerts } from '../dn.js'
5
6
 
6
7
 
7
8
  const {
@@ -149,7 +150,8 @@ export function getCertInfo(dn) {
149
150
  reject()
150
151
  }
151
152
 
152
- certInfo = verifyDn(dnList, dn)
153
+ // 仅 NSGetCertsListInfo 的证书数据执行过期过滤和到期排序。
154
+ certInfo = verifyCertsList(dnList, dn)
153
155
  resolve(certInfo)
154
156
  })
155
157
  })
@@ -231,6 +233,43 @@ async function performSignSkf(plainText, value) {
231
233
  })
232
234
  }
233
235
 
236
+ /**
237
+ * 按原有 DN、证书类型和用途筛选,过滤过期项后优先使用有效期最长的 SM2。
238
+ * SKF 接口继续使用原 verifyDn,不参与本次有效期处理。
239
+ */
240
+ function verifyCertsList(dnList, dn) {
241
+ const userDnAttrsArr = dn.split(',').map((c) => c.trim())
242
+ const matchedCerts = dnList
243
+ .map((cert, index) => ({ cert, index }))
244
+ .filter(({ cert }) => {
245
+ const dnAttrsArr = cert.certDN.split(',').map((c) => c.trim())
246
+ return dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))
247
+ })
248
+ .filter(
249
+ ({ cert }) => (cert.CertType === 'SM2' && cert.KeyUsage === 'signature') || cert.CertType === 'RSA'
250
+ )
251
+ if (matchedCerts.length === 0) {
252
+ const certDns = dnList.map((cert) => cert.certDN).join(',')
253
+ Message.error(`${$lc('证书Dn不匹配:')}${certDns}${$lc('里面无法匹配===>')}${dn}`)
254
+ return -1
255
+ }
256
+
257
+ const validCerts = getValidCerts(matchedCerts)
258
+ if (validCerts.length === 0) {
259
+ Message.error($lc('证书已过期'))
260
+ return -1
261
+ }
262
+
263
+ // 列表已按到期时间倒序;优先取有效 SM2,SM2 均过期或不存在时再取 RSA。
264
+ const selectedCert = validCerts.find(({ cert }) => cert.CertType === 'SM2') || validCerts[0]
265
+ // 同步选中证书的原始索引、DN 和算法,供后续签名使用。
266
+ const { cert, index } = selectedCert
267
+ certIndex = index
268
+ certDN = cert.certDN
269
+ certType = cert.CertType === 'SM2' ? 'SM3' : 'SHA1'
270
+ return index
271
+ }
272
+
234
273
  /**
235
274
  * 验证Dn是否存在于Dn列表中
236
275
  * @param {Array} dnList 获取到的Dn列表
@@ -0,0 +1,78 @@
1
+ import Vue from 'vue'
2
+ import vxeTable from 'vxe-table'
3
+ import DomZIndex from 'dom-zindex'
4
+ import PopupManager from 'element-ui/lib/utils/popup/popup-manager'
5
+ import SourcePopupManager from 'element-ui/src/utils/popup/popup-manager'
6
+
7
+ const BRIDGE_FLAG = '__n20PopupZIndexBridge__'
8
+
9
+ function syncLegacyZIndex() {
10
+ const core = vxeTable.VXETable || vxeTable
11
+ const config = core.config
12
+ const zIndex = config && typeof config === 'object' ? Number(config.zIndex) : 0
13
+ if (zIndex > DomZIndex.getCurrent()) DomZIndex.setCurrent(zIndex)
14
+ }
15
+
16
+ function bridgePopupManager(manager) {
17
+ if (manager[BRIDGE_FLAG]) return
18
+
19
+ const descriptor = Object.getOwnPropertyDescriptor(manager, 'zIndex')
20
+ // Element 保存下一次可用值,dom-zindex 保存最后一次已分配值。
21
+ syncLegacyZIndex()
22
+ DomZIndex.setCurrent(Math.max(DomZIndex.getCurrent(), manager.zIndex - 1))
23
+ Object.defineProperty(manager, 'zIndex', {
24
+ configurable: true,
25
+ get() {
26
+ syncLegacyZIndex()
27
+ // 兼容先安装表格、后安装 Element,并保留业务自定义的初始层级。
28
+ const configuredZIndex = Number((Vue.prototype.$ELEMENT || {}).zIndex) || 2000
29
+ return Math.max(descriptor.get.call(manager), DomZIndex.getCurrent() + 1, configuredZIndex)
30
+ },
31
+ set(value) {
32
+ const nextZIndex = Number(value)
33
+ if (!Number.isFinite(nextZIndex)) return
34
+
35
+ const currentZIndex = Math.max(DomZIndex.getCurrent(), nextZIndex - 1)
36
+ DomZIndex.setCurrent(currentZIndex)
37
+ descriptor.set.call(manager, currentZIndex + 1)
38
+ }
39
+ })
40
+ Object.defineProperty(manager, BRIDGE_FLAG, { value: true })
41
+ }
42
+
43
+ function bridgeLegacyTooltip(component) {
44
+ const options = component && (component.options || component)
45
+ const methods = options && options.methods
46
+ if (!methods || !methods.updateZindex || methods.updateZindex[BRIDGE_FLAG]) return
47
+
48
+ const updateZindex = methods.updateZindex
49
+ const updatePlacement = methods.updatePlacement
50
+ // vxe 3.6 的 tooltip 不使用 dom-zindex,每次显示都要从共享层级重新分配。
51
+ methods.updateZindex = function () {
52
+ updateZindex.call(this)
53
+ syncLegacyZIndex()
54
+ this.tipZindex = DomZIndex.getNext()
55
+ }
56
+ Object.defineProperty(methods.updateZindex, BRIDGE_FLAG, { value: true })
57
+ methods.updatePlacement = function (...args) {
58
+ if (this.visible && this.tipStore && this.tipStore.style) {
59
+ // 兼容业务缓存的旧主题 CSS(9999 !important),使用动态内联层级覆盖。
60
+ this.tipStore.style.zIndex = `${this.zIndex || this.tipZindex} !important`
61
+ }
62
+ return updatePlacement.apply(this, args)
63
+ }
64
+ }
65
+
66
+ /** 同步 Element 与表格 tooltip 的层级,兼容旧版 vxe 及升级后的 vxe 3.20。 */
67
+ export default function installPopupZIndexBridge() {
68
+ if (typeof document === 'undefined') return
69
+
70
+ bridgePopupManager(PopupManager)
71
+ bridgePopupManager(SourcePopupManager)
72
+ // 旧版导出 Tooltip;新版由 vxe-pc-ui 提供,直接复用上面的计数器桥接。
73
+ if (vxeTable.Tooltip) {
74
+ bridgeLegacyTooltip(vxeTable.Tooltip)
75
+ // Vue.use(vxeTable) 已执行时,注册的构造器也需要同步,支持按需引用 TablePro。
76
+ bridgeLegacyTooltip(Vue.options.components.VxeTooltip)
77
+ }
78
+ }