@jr-public/jr-upload-ui 1.1.1 → 1.1.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": "@jr-public/jr-upload-ui",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "JR upload modal components for Vue2 and Vue3",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,9 +1,9 @@
1
- // 与上传服务实际返回的 SDK 标识一致;升级时同时更换 URL,避开历史静态资源缓存。
1
+ // 仅作为脚本 URL 的缓存标识,不要求服务返回相同的 SDK 发布版本。
2
2
  export const TRANSFER_SDK_VERSION = '20261020-session-clock'
3
3
 
4
4
  const scriptLoads = new Map()
5
5
 
6
- /** 多个上传弹窗共用加载状态,脚本返回成功后仍须核对实际版本及能力。 */
6
+ /** 多个上传弹窗共用加载状态,脚本返回成功后仍须核对必要能力。 */
7
7
  function loadScript(src, ready, invalidMessage, moduleScript = false) {
8
8
  if (ready()) return Promise.resolve()
9
9
  if (scriptLoads.has(src)) return scriptLoads.get(src)
@@ -34,17 +34,17 @@ function loadScript(src, ready, invalidMessage, moduleScript = false) {
34
34
  return pending
35
35
  }
36
36
 
37
- /** 仅接受支持短时授权的当前 SDK,禁止把旧脚本当作已就绪依赖。 */
37
+ /** 按短时授权能力判断 SDK 是否可用,不限制发布版本。 */
38
38
  export async function loadUploadDependencies(baseUrl) {
39
39
  const base = String(baseUrl || '').replace(/\/+$/, '')
40
40
  if (!base) throw new Error('上传服务地址不能为空')
41
41
  await loadScript(`${base}/js/aliyun-oss-sdk-6.18.0.min.js`,
42
42
  () => Boolean(window.OSS), 'OSS 上传依赖加载失败')
43
43
  await loadScript(`${base}/js/jr-transfer-sdk.js?v=${TRANSFER_SDK_VERSION}`,
44
- () => Boolean(window.JrTransferSDK
45
- && window.JrTransferSDK.SDK_VERSION === TRANSFER_SDK_VERSION
44
+ () => Boolean(typeof window.JrTransferSDK === 'function'
45
+ && window.JrTransferSDK.prototype
46
46
  && typeof window.JrTransferSDK.prototype.exchangeBrowserTicket === 'function'),
47
- '上传 SDK 版本不匹配,请更新上传服务', true)
47
+ '上传 SDK 缺少浏览器授权能力,请更新上传服务', true)
48
48
  await loadScript(`${base}/js/jszip.min.js`,
49
49
  () => Boolean(window.JSZip), '文件压缩依赖加载失败')
50
50
  }
@@ -70,7 +70,7 @@
70
70
  ref="fileInput"
71
71
  type="file"
72
72
  :multiple="fileRestrictions.multiple"
73
- :accept="acceptedTypes"
73
+ :accept="acceptedTypes || null"
74
74
  @change="handleFileSelect"
75
75
  style="display: none;"
76
76
  :disabled="isUploadDisabled"
@@ -440,7 +440,9 @@ export default {
440
440
  },
441
441
 
442
442
  acceptedTypes() {
443
- return this.fileRestrictions.allowedExtensions.join(',')
443
+ return this.accept && this.accept.trim()
444
+ ? this.fileRestrictions.allowedExtensions.join(',')
445
+ : ''
444
446
  },
445
447
 
446
448
  allowedExtensionsText() {
@@ -538,8 +540,11 @@ export default {
538
540
  const normalizedExt = normalizeFileExtension(fileExt)
539
541
  if (!normalizedExt) return false
540
542
 
541
- return Array.isArray(allowedExtensions)
542
- && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
543
+ if (!Array.isArray(allowedExtensions)) return false
544
+
545
+ const normalizedAllowedExtensions = allowedExtensions.map(normalizeFileExtension)
546
+ return normalizedAllowedExtensions.includes(normalizedExt)
547
+ || (normalizedAllowedExtensions.includes('gef') && normalizedExt.includes('gef'))
543
548
  },
544
549
 
545
550
  /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
@@ -1660,7 +1665,7 @@ export default {
1660
1665
  getElectronFileFilters() {
1661
1666
  const filters = []
1662
1667
 
1663
- if (this.fileRestrictions.allowedExtensions.length) {
1668
+ if (this.accept && this.accept.trim() && this.fileRestrictions.allowedExtensions.length) {
1664
1669
  const extensions = this.fileRestrictions.allowedExtensions.map(ext => ext.replace('.', ''))
1665
1670
  filters.push({
1666
1671
  name: '支持的文件',
@@ -70,7 +70,7 @@
70
70
  ref="fileInput"
71
71
  type="file"
72
72
  :multiple="fileRestrictions.multiple"
73
- :accept="acceptedTypes"
73
+ :accept="acceptedTypes || null"
74
74
  @change="handleFileSelect"
75
75
  style="display: none;"
76
76
  :disabled="isUploadDisabled"
@@ -462,7 +462,9 @@ export default {
462
462
  })
463
463
 
464
464
  const acceptedTypes = computed(() => {
465
- return fileRestrictions.value.allowedExtensions.join(',')
465
+ return props.accept && props.accept.trim()
466
+ ? fileRestrictions.value.allowedExtensions.join(',')
467
+ : ''
466
468
  })
467
469
 
468
470
  const allowedExtensionsText = computed(() =>
@@ -560,8 +562,11 @@ export default {
560
562
  const normalizedExt = normalizeFileExtension(fileExt)
561
563
  if (!normalizedExt) return false
562
564
 
563
- return Array.isArray(allowedExtensions)
564
- && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
565
+ if (!Array.isArray(allowedExtensions)) return false
566
+
567
+ const normalizedAllowedExtensions = allowedExtensions.map(normalizeFileExtension)
568
+ return normalizedAllowedExtensions.includes(normalizedExt)
569
+ || (normalizedAllowedExtensions.includes('gef') && normalizedExt.includes('gef'))
565
570
  }
566
571
 
567
572
  /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
@@ -1684,7 +1689,7 @@ export default {
1684
1689
  const getElectronFileFilters = () => {
1685
1690
  const filters = []
1686
1691
 
1687
- if (fileRestrictions.value.allowedExtensions.length) {
1692
+ if (props.accept && props.accept.trim() && fileRestrictions.value.allowedExtensions.length) {
1688
1693
  const extensions = fileRestrictions.value.allowedExtensions.map(ext => ext.replace('.', ''))
1689
1694
  filters.push({
1690
1695
  name: '支持的文件',