@jr-public/jr-upload-ui 1.0.6 → 1.1.1

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/README.md CHANGED
@@ -34,10 +34,54 @@ export default {
34
34
 
35
35
  组件依赖的静态资源路径仍需由前端传入,例如:
36
36
 
37
+ ```vue
38
+ <JrUploadModal :config="config" bucket-name="example-bucket" upload-path="business/files" />
39
+ ```
40
+
41
+ `config.baseUrl` 指向上传服务;授权回调配置见下文。
42
+
43
+ ## 浏览器临时授权
44
+
45
+ Vue2、Vue3 使用相同配置。业务后端签发一次性票据,前端无需上传平台 Token:
46
+
47
+ ```js
48
+ const config = {
49
+ baseUrl: 'https://upload.example.com/publicUpload',
50
+ getUploadTicket: async ({ bucketName, uploadPath }) => {
51
+ const response = await request({
52
+ url: '/cjl/fileAccess/upload-ticket',
53
+ method: 'post',
54
+ data: { scene: 'xxj-source', bucketName, uploadPath }
55
+ })
56
+ return response.data
57
+ }
58
+ }
59
+ ```
60
+
61
+ 组件仍通过 `bucketName`、`uploadPath` 指定原业务桶和目录;授权失败时停止操作。
62
+ 每次打开弹框重新申请票据,短时会话仅保存在内存。临时授权使用受限 STS
63
+ 直传;启用压缩时在浏览器完成,不支持服务端代理上传和 MD5 去重。
64
+ 旧 `config.token` 接入方式保留兼容,新接入使用 `getUploadTicket`。
65
+
66
+ 下载、远程预览可从相应 Vue 入口导入 `getAuthorizedFileUrl`:
67
+
37
68
  ```js
38
- <JrUploadModal :config="{ baseUrl: 'https://xxx.com/upload-ui', token: 'xxx', uploadPath: '/path' }" />
69
+ import { getAuthorizedFileUrl } from '@jr-public/jr-upload-ui/vue2'
70
+
71
+ const url = await getAuthorizedFileUrl(window.JrTransferSDK, {
72
+ baseUrl: config.baseUrl,
73
+ getFileTicket: scope => request({
74
+ url: '/cjl/fileAccess/preview-ticket',
75
+ method: 'post',
76
+ data: { scene: 'xxj-source', ...scope }
77
+ }).then(response => response.data)
78
+ }, { operation: 'PREVIEW', bucketName: 'example-bucket', objectKey: 'business/file.pdf' })
39
79
  ```
40
80
 
81
+ `getFileTicket` 根据操作选择 `download-ticket` 或 `preview-ticket`。
82
+ 该方法需要先加载上传服务的 `jr-transfer-sdk.js`,返回仅绑定当前文件的短时地址。
83
+ 上传列表中对本地文件的预览仍使用浏览器本地对象,无需申请远程授权。
84
+
41
85
  ## 发布
42
86
 
43
87
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jr-public/jr-upload-ui",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "JR upload modal components for Vue2 and Vue3",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -13,6 +13,7 @@
13
13
  "./vue3": "./packages/vue3/src/index.js"
14
14
  },
15
15
  "scripts": {
16
+ "test": "node --test tests/*.test.cjs",
16
17
  "pack": "npm pack",
17
18
  "prepublishOnly": "npm pack",
18
19
  "publish:public": "npm publish --access public"
@@ -0,0 +1,57 @@
1
+ // 两个 Vue 版本共用票据校验,授权失败时不得退回长期 Token。
2
+ function normalizedDirectory(value) {
3
+ return String(value || '').trim().replace(/^\/+|\/+$/g, '')
4
+ }
5
+
6
+ function validateTicket(grant, scope) {
7
+ const now = Date.now()
8
+ if (!grant || !/^[A-Za-z0-9_-]{43}$/.test(grant.ticket || '')
9
+ || grant.operation !== scope.operation
10
+ || !grant.bucketName || (scope.bucketName && grant.bucketName !== scope.bucketName)
11
+ || !Number.isFinite(grant.expiresAt) || grant.expiresAt <= now || grant.expiresAt > now + 120000
12
+ || (scope.operation === 'UPLOAD' && grant.uploadPath !== scope.uploadPath)
13
+ || (scope.operation !== 'UPLOAD' && grant.objectKey !== scope.objectKey)) {
14
+ throw new Error('文件票据无效、已过期或与申请范围不一致')
15
+ }
16
+ }
17
+
18
+ export async function createUploadSdk(Sdk, config, scope) {
19
+ const shortLived = typeof config.getUploadTicket === 'function' || Boolean(config.browserTicket)
20
+ if (!shortLived) return new Sdk({ baseUrl: config.baseUrl, apiToken: config.token })
21
+ const requested = {
22
+ operation: 'UPLOAD',
23
+ bucketName: String(scope.bucketName || '').trim(),
24
+ uploadPath: normalizedDirectory(scope.uploadPath)
25
+ }
26
+ const grant = typeof config.getUploadTicket === 'function'
27
+ ? await config.getUploadTicket(requested)
28
+ : Object.assign({}, requested, { ticket: config.browserTicket, expiresAt: config.expiresAt })
29
+ validateTicket(grant, requested)
30
+ const sdk = new Sdk({ baseUrl: config.baseUrl, browserTicket: grant.ticket })
31
+ const session = await sdk.exchangeBrowserTicket(grant.ticket)
32
+ if (session.operation !== 'UPLOAD' || session.uploadPath !== requested.uploadPath
33
+ || session.bucketName !== grant.bucketName) {
34
+ throw new Error('上传会话与申请范围不一致')
35
+ }
36
+ sdk.browserExpiresAt = session.expiresAt
37
+ return sdk
38
+ }
39
+
40
+ /** 下载、预览按单个对象申请票据;返回短时地址,供调用页面按原交互打开。 */
41
+ export async function getAuthorizedFileUrl(Sdk, config, scope) {
42
+ if (!['DOWNLOAD', 'PREVIEW'].includes(scope.operation) || typeof config.getFileTicket !== 'function') {
43
+ throw new Error('请配置下载或预览授权回调')
44
+ }
45
+ const requested = {
46
+ operation: scope.operation, bucketName: scope.bucketName, objectKey: scope.objectKey
47
+ }
48
+ const grant = await config.getFileTicket(requested)
49
+ validateTicket(grant, requested)
50
+ const sdk = new Sdk({ baseUrl: config.baseUrl, browserTicket: grant.ticket })
51
+ const session = await sdk.exchangeBrowserTicket(grant.ticket)
52
+ if (session.operation !== requested.operation || session.objectKey !== requested.objectKey
53
+ || session.bucketName !== grant.bucketName) {
54
+ throw new Error('文件会话与申请范围不一致')
55
+ }
56
+ return sdk.getBrowserFileUrl()
57
+ }
@@ -0,0 +1,50 @@
1
+ // 与上传服务实际返回的 SDK 标识一致;升级时同时更换 URL,避开历史静态资源缓存。
2
+ export const TRANSFER_SDK_VERSION = '20261020-session-clock'
3
+
4
+ const scriptLoads = new Map()
5
+
6
+ /** 多个上传弹窗共用加载状态,脚本返回成功后仍须核对实际版本及能力。 */
7
+ function loadScript(src, ready, invalidMessage, moduleScript = false) {
8
+ if (ready()) return Promise.resolve()
9
+ if (scriptLoads.has(src)) return scriptLoads.get(src)
10
+
11
+ const pending = new Promise((resolve, reject) => {
12
+ const script = document.createElement('script')
13
+ // SDK 使用模块作用域,避免页面已加载的旧版同名全局类阻止新版脚本执行。
14
+ if (moduleScript) script.type = 'module'
15
+ const timer = setTimeout(() => finish(new Error('上传依赖加载超时,请稍后重试')), 15000)
16
+ const finish = error => {
17
+ clearTimeout(timer)
18
+ script.onload = null
19
+ script.onerror = null
20
+ if (error) {
21
+ script.remove()
22
+ reject(error)
23
+ } else {
24
+ resolve()
25
+ }
26
+ }
27
+ script.src = src
28
+ script.onload = () => finish(ready() ? null : new Error(invalidMessage))
29
+ script.onerror = () => finish(new Error('上传依赖加载失败,请检查上传服务'))
30
+ document.head.appendChild(script)
31
+ })
32
+ scriptLoads.set(src, pending)
33
+ pending.then(() => scriptLoads.delete(src), () => scriptLoads.delete(src))
34
+ return pending
35
+ }
36
+
37
+ /** 仅接受支持短时授权的当前 SDK,禁止把旧脚本当作已就绪依赖。 */
38
+ export async function loadUploadDependencies(baseUrl) {
39
+ const base = String(baseUrl || '').replace(/\/+$/, '')
40
+ if (!base) throw new Error('上传服务地址不能为空')
41
+ await loadScript(`${base}/js/aliyun-oss-sdk-6.18.0.min.js`,
42
+ () => Boolean(window.OSS), 'OSS 上传依赖加载失败')
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
46
+ && typeof window.JrTransferSDK.prototype.exchangeBrowserTicket === 'function'),
47
+ '上传 SDK 版本不匹配,请更新上传服务', true)
48
+ await loadScript(`${base}/js/jszip.min.js`,
49
+ () => Boolean(window.JSZip), '文件压缩依赖加载失败')
50
+ }
@@ -90,9 +90,9 @@
90
90
  {{ waitingForValidation ? '正在验证文件...' : (validationMessage || '文件上传要求') }}
91
91
  </div>
92
92
  <ul class="restrictions-list" v-if="!validationMessage && !waitingForValidation">
93
- <li v-if="fileRestrictions.showFileTypeInfo && fileRestrictions.allowedExtensions" style="display: list-item;">
93
+ <li v-if="fileRestrictions.showFileTypeInfo && fileRestrictions.allowedExtensions.length" style="display: list-item;">
94
94
  支持格式:
95
- <div class="format-tags">
95
+ <div class="format-tags" :title="allowedExtensionsText" :aria-label="allowedExtensionsText" tabindex="0" @click.stop>
96
96
  <span
97
97
  v-for="ext in fileRestrictions.allowedExtensions"
98
98
  :key="ext"
@@ -258,9 +258,18 @@
258
258
  </template>
259
259
 
260
260
  <script>
261
+ import { createUploadSdk } from '../../shared/browser-access'
262
+ import { loadUploadDependencies } from '../../shared/sdk-loader'
261
263
  // 组件统一允许的单文件最大值,maxSize 对外单位保持为 KB
262
264
  const MAX_UPLOAD_SIZE_KB = 10 * 1024 * 1024
263
265
 
266
+ // 统一处理前导点、空格和大小写,确保 accept 配置与真实文件后缀可直接比较。
267
+ const normalizeFileExtension = (value) =>
268
+ String(value || '').trim().toLowerCase().replace(/^\.+/, '')
269
+
270
+ const normalizeFileExtensions = (values) => Array.from(new Set(values
271
+ .map(normalizeFileExtension).filter(Boolean).map(ext => '.' + ext)))
272
+
264
273
  export default {
265
274
  name: 'JrUploadModal',
266
275
 
@@ -306,7 +315,7 @@ export default {
306
315
  onClose: { type: Function, default: null },
307
316
 
308
317
  // 文件限制
309
- accept: { type: String, default: '' },
318
+ accept: { type: String, default: '' }, // 未传时读取上传服务允许类型
310
319
  maxSize: { type: Number, default: MAX_UPLOAD_SIZE_KB }, // KB,默认最大10GB
311
320
  maxCount: { type: Number, default: 10 },
312
321
  multiple: { type: Boolean, default: true },
@@ -362,6 +371,7 @@ export default {
362
371
 
363
372
  // SDK实例和配置
364
373
  sdkInstance: null,
374
+ serverAllowedExtensions: [],
365
375
  isElectronEnv: false,
366
376
  electronFileMap: new Map(),
367
377
  waitingForValidation: false,
@@ -386,18 +396,9 @@ export default {
386
396
 
387
397
  computed: {
388
398
  fileRestrictions() {
389
- const allowedExtensions = this.accept ? this.accept.split(',').map(ext => {
390
- const trimmed = ext.trim()
391
- return trimmed.startsWith('.') ? trimmed : '.' + trimmed
392
- }) : null
393
-
394
- if (allowedExtensions) {
395
- ['.aqtf', '.hftf', '.gef', '.tb_dg_gef', '.nsxtf', '.sxt2', '.gbq7', '.jmbs'].forEach(ext => {
396
- if (!allowedExtensions.some(item => item.toLowerCase() === ext)) {
397
- allowedExtensions.push(ext)
398
- }
399
- })
400
- }
399
+ const allowedExtensions = this.accept && this.accept.trim()
400
+ ? normalizeFileExtensions(this.accept.split(','))
401
+ : this.serverAllowedExtensions
401
402
 
402
403
  return {
403
404
  allowedExtensions,
@@ -414,7 +415,7 @@ export default {
414
415
  isUploadDisabled() {
415
416
  // 参考原始 stsUpload.html 的逻辑:只在真正达到文件数量限制时才禁用
416
417
  // 验证期间不禁用选择文件按钮,与原始页面行为保持一致
417
- if (this.disabled) {
418
+ if (this.disabled || !this.fileRestrictions.allowedExtensions.length) {
418
419
  return true
419
420
  }
420
421
 
@@ -428,7 +429,7 @@ export default {
428
429
 
429
430
  uploadButtonText() {
430
431
  if (this.isUploading) return '上传中...'
431
- if (this.isUploadDisabled && this.fileRestrictions.maxFileCount && this.fileRestrictions.maxFileCount > 0) {
432
+ if (this.fileRestrictions.maxFileCount > 0 && this.filesToUpload.length >= this.fileRestrictions.maxFileCount) {
432
433
  return `已达到限制 (${this.fileRestrictions.maxFileCount}个文件)`
433
434
  }
434
435
  return '选择文件'
@@ -439,10 +440,13 @@ export default {
439
440
  },
440
441
 
441
442
  acceptedTypes() {
442
- if (!this.fileRestrictions.allowedExtensions) return '*'
443
443
  return this.fileRestrictions.allowedExtensions.join(',')
444
444
  },
445
445
 
446
+ allowedExtensionsText() {
447
+ return this.fileRestrictions.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、')
448
+ },
449
+
446
450
  showRestrictions() {
447
451
  // 总是显示限制说明区域,但具体显示内容由各个参数控制
448
452
  // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
@@ -451,9 +455,15 @@ export default {
451
455
  },
452
456
 
453
457
  watch: {
458
+ accept() {
459
+ if (this.sdkInstance) {
460
+ this.loadFileTypeRestrictions().catch(error => this.showError(error.message))
461
+ }
462
+ },
463
+
454
464
  visible(newVal) {
455
465
  if (newVal) {
456
- this.initializeComponent()
466
+ this.initializeComponent().catch(error => this.showError(error.message))
457
467
  // append-to-body: 弹框显示时将根元素移动到document.body
458
468
  if (this.appendToBody) {
459
469
  this.$nextTick(() => {
@@ -522,20 +532,32 @@ export default {
522
532
 
523
533
  methods: {
524
534
  /**
525
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
535
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
526
536
  */
527
537
  isAllowedFileExtension(fileExt, allowedExtensions) {
528
- const normalizedExt = (fileExt || '').toLowerCase()
538
+ const normalizedExt = normalizeFileExtension(fileExt)
529
539
  if (!normalizedExt) return false
530
540
 
531
- if (['.aqtf', '.hftf', '.gef', '.tb_dg_gef', '.nsxtf', '.sxt2', '.gbq7', '.jmbs'].includes(normalizedExt)
532
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
533
- return true
534
- }
535
-
536
- return allowedExtensions.some(ext => ext.toLowerCase() === normalizedExt)
541
+ return Array.isArray(allowedExtensions)
542
+ && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
537
543
  },
538
544
 
545
+ /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
546
+ async loadFileTypeRestrictions() {
547
+ this.serverAllowedExtensions = []
548
+ if (this.accept && this.accept.trim()) {
549
+ if (!normalizeFileExtensions(this.accept.split(',')).length) {
550
+ throw new Error('未配置有效的允许上传类型')
551
+ }
552
+ return
553
+ }
554
+ const config = await this.sdkInstance.getFileExtensionConfig()
555
+ const extensions = config && Array.isArray(config.whitelist)
556
+ ? normalizeFileExtensions(config.whitelist) : []
557
+ if (!extensions.length) throw new Error('未获取到有效的允许上传类型')
558
+ this.serverAllowedExtensions = extensions
559
+ },
560
+
539
561
  async initializeComponent() {
540
562
  this.isElectronEnv = this.detectElectronEnvironment()
541
563
 
@@ -577,76 +599,45 @@ export default {
577
599
 
578
600
  // 初始化Transfer SDK
579
601
  if (window.JrTransferSDK) {
580
- this.sdkInstance = new window.JrTransferSDK({
581
- baseUrl: this.config.baseUrl,
582
- apiToken: this.config.token,
583
- })
584
-
585
- this.$emit('sdk-initialized', {
586
- success: true,
587
- timestamp: Date.now()
602
+ this.sdkInstance = await createUploadSdk(window.JrTransferSDK, this.config, {
603
+ bucketName: this.bucketName,
604
+ uploadPath: this.uploadPath || this.config.uploadPath
588
605
  })
589
606
 
590
- console.log('✅ Transfer SDK初始化成功')
591
607
  } else {
592
608
  throw new Error('JrTransferSDK未加载')
593
609
  }
594
610
 
611
+ await this.loadFileTypeRestrictions()
612
+
595
613
  // 如果启用了压缩,加载压缩配置
596
614
  if (this.enableCompression) {
597
615
  await this.loadCompressionConfig()
598
616
  }
617
+ this.$emit('sdk-initialized', {
618
+ success: true,
619
+ timestamp: Date.now()
620
+ })
599
621
  } catch (error) {
622
+ this.sdkInstance = null
600
623
  console.error('❌ SDK初始化失败:', error)
601
624
  this.$emit('sdk-initialized', {
602
625
  success: false,
603
626
  error: error.message,
604
627
  timestamp: Date.now()
605
628
  })
629
+ throw error
606
630
  }
607
631
  },
608
632
 
609
633
  async loadExternalDependencies() {
610
- const baseUrl = this.config.baseUrl
611
- const dependencies = [
612
- `${baseUrl}/js/aliyun-oss-sdk-6.18.0.min.js`,
613
- `${baseUrl}/js/jr-transfer-sdk.js?v=20260814-10gb`,
614
- `${baseUrl}/js/jszip.min.js`
615
- ]
616
-
617
- // 检查是否已加载
618
- if (window.JrTransferSDK && window.JrTransferSDK.SDK_VERSION === '20260814-10gb' && window.OSS && window.JSZip) {
619
- return Promise.resolve()
620
- }
621
-
622
- // 动态加载脚本
623
- const loadScript = (src) => {
624
- return new Promise((resolve, reject) => {
625
- if (document.querySelector(`script[src="${src}"]`)) {
626
- resolve()
627
- return
628
- }
629
-
630
- const script = document.createElement('script')
631
- script.src = src
632
- script.onload = resolve
633
- script.onerror = reject
634
- document.head.appendChild(script)
635
- })
636
- }
637
-
638
- try {
639
- for (const dep of dependencies) {
640
- await loadScript(dep)
641
- }
642
- console.log('✅ 外部依赖加载完成')
643
- } catch (error) {
644
- console.error('❌ 外部依赖加载失败:', error)
645
- throw error
646
- }
634
+ await loadUploadDependencies(this.config.baseUrl)
647
635
  },
648
636
 
649
637
  cleanup() {
638
+ this.sdkInstance = null
639
+ this.serverAllowedExtensions = []
640
+ this.compressionConfig.loaded = false
650
641
  if (this.autoCloseTimer) {
651
642
  clearTimeout(this.autoCloseTimer)
652
643
  this.autoCloseTimer = null
@@ -690,29 +681,21 @@ export default {
690
681
  }
691
682
 
692
683
  try {
693
- const baseUrl = this.config.baseUrl
694
- let apiUrl = `${baseUrl}/api/sts/compression-config?token=${encodeURIComponent(this.config.token)}`
695
-
696
- // 如果提供了bucketName,添加到请求参数中
697
- if (this.bucketName && this.bucketName.trim() !== '') {
698
- apiUrl += `&bucketName=${encodeURIComponent(this.bucketName.trim())}`
699
- }
700
-
701
- console.log('📡 请求压缩配置:', apiUrl)
702
-
703
- const response = await fetch(apiUrl)
704
-
705
- if (!response.ok) {
706
- throw new Error(`HTTP ${response.status}: ${response.statusText}`)
707
- }
708
-
709
- const result = await response.json()
710
-
711
- if (!result.success) {
712
- throw new Error(result.message || '获取压缩配置失败')
684
+ let config
685
+ if (this.sdkInstance && this.sdkInstance.browserAccessMode) {
686
+ config = await this.sdkInstance.getUploadCompressionConfig()
687
+ } else {
688
+ const baseUrl = this.config.baseUrl
689
+ let apiUrl = `${baseUrl}/api/sts/compression-config?token=${encodeURIComponent(this.config.token)}`
690
+ if (this.bucketName && this.bucketName.trim() !== '') {
691
+ apiUrl += `&bucketName=${encodeURIComponent(this.bucketName.trim())}`
692
+ }
693
+ const response = await fetch(apiUrl)
694
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`)
695
+ const result = await response.json()
696
+ if (!result.success) throw new Error(result.message || '获取压缩配置失败')
697
+ config = result.config
713
698
  }
714
-
715
- const config = result.config
716
699
  this.compressionConfig.level = config.level || 'balanced'
717
700
  this.compressionConfig.mode = config.mode || 'smart'
718
701
  this.compressionConfig.threshold = config.threshold || 10 * 1024 * 1024
@@ -725,6 +708,7 @@ export default {
725
708
  return this.compressionConfig
726
709
 
727
710
  } catch (error) {
711
+ if (typeof this.config.getUploadTicket === 'function' || this.config.browserTicket) throw error
728
712
  console.error('❌ 获取压缩配置失败,使用默认配置:', error)
729
713
  // 使用默认配置
730
714
  this.compressionConfig.enabled = this.enableCompression
@@ -774,6 +758,8 @@ export default {
774
758
  if (!this.enableCompression) {
775
759
  return 'none'
776
760
  }
761
+ // 受限 STS 使用浏览器直传,压缩在当前页面完成。
762
+ if (this.sdkInstance && this.sdkInstance.browserAccessMode) return 'frontend'
777
763
 
778
764
  await this.loadCompressionConfig()
779
765
 
@@ -1346,7 +1332,7 @@ export default {
1346
1332
  try {
1347
1333
  // 构建文件过滤器(与原始页面逻辑一致)
1348
1334
  const filters = []
1349
- if (this.fileRestrictions.showFileTypeInfo && this.fileRestrictions.allowedExtensions) {
1335
+ if (this.fileRestrictions.allowedExtensions.length) {
1350
1336
  const extensions = this.fileRestrictions.allowedExtensions.map(ext =>
1351
1337
  ext.startsWith('.') ? ext.slice(1) : ext
1352
1338
  )
@@ -1614,6 +1600,49 @@ export default {
1614
1600
  'sxt2': 'application/octet-stream',
1615
1601
  'gbq7': 'application/octet-stream',
1616
1602
  'jmbs': 'application/octet-stream',
1603
+ 'ujyzbx': 'application/octet-stream',
1604
+ 'zkzf': 'application/octet-stream',
1605
+ 'nzktf': 'application/octet-stream',
1606
+ 'zgzs': 'application/octet-stream',
1607
+ 'zgzf': 'application/octet-stream',
1608
+ 'zgsf': 'application/octet-stream',
1609
+ 'zgtf': 'application/octet-stream',
1610
+ 'zgcs': 'application/octet-stream',
1611
+ 'zgcf': 'application/octet-stream',
1612
+ 'tbsx': 'application/octet-stream',
1613
+ 'sgef': 'application/octet-stream',
1614
+ 'czr': 'application/octet-stream',
1615
+ 'zytf': 'application/octet-stream',
1616
+ 'nzjy': 'application/octet-stream',
1617
+ 'zsf': 'application/octet-stream',
1618
+ 'gscs': 'application/octet-stream',
1619
+ 'gscf': 'application/octet-stream',
1620
+ 'zbxs': 'application/octet-stream',
1621
+ 'zbwj': 'application/octet-stream',
1622
+ 'zyzf': 'application/octet-stream',
1623
+ 'gszs': 'application/octet-stream',
1624
+ 'gszf': 'application/octet-stream',
1625
+ 'zbjy': 'application/octet-stream',
1626
+ 'zbsx': 'application/octet-stream',
1627
+ 'gctb': 'application/octet-stream',
1628
+ 'fwtb': 'application/octet-stream',
1629
+ 'nzytf': 'application/octet-stream',
1630
+ 'mtbjy': 'application/octet-stream',
1631
+ 'gstf': 'application/octet-stream',
1632
+ 'dxtf': 'application/octet-stream',
1633
+ 'gssf': 'application/octet-stream',
1634
+ 'qbcg': 'application/octet-stream',
1635
+ 'jtb4': 'application/octet-stream',
1636
+ 'jzb4': 'application/octet-stream',
1637
+ 'xml': 'application/xml',
1638
+ 'ydbx': 'application/octet-stream',
1639
+ 'ydjc': 'application/octet-stream',
1640
+ 'sxzb': 'application/octet-stream',
1641
+ 'sxtb': 'application/octet-stream',
1642
+ 'sxxj': 'application/octet-stream',
1643
+ 'hebzbx': 'application/octet-stream',
1644
+ 'hebkzjx': 'application/octet-stream',
1645
+ 'hebtbx': 'application/octet-stream',
1617
1646
  'ppt': 'application/vnd.ms-powerpoint',
1618
1647
  'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
1619
1648
  'txt': 'text/plain',
@@ -1631,7 +1660,7 @@ export default {
1631
1660
  getElectronFileFilters() {
1632
1661
  const filters = []
1633
1662
 
1634
- if (this.fileRestrictions.allowedExtensions) {
1663
+ if (this.fileRestrictions.allowedExtensions.length) {
1635
1664
  const extensions = this.fileRestrictions.allowedExtensions.map(ext => ext.replace('.', ''))
1636
1665
  filters.push({
1637
1666
  name: '支持的文件',
@@ -1639,10 +1668,12 @@ export default {
1639
1668
  })
1640
1669
  }
1641
1670
 
1642
- filters.push({
1643
- name: '所有文件',
1644
- extensions: ['*']
1645
- })
1671
+ if (!filters.length) {
1672
+ filters.push({
1673
+ name: '所有文件',
1674
+ extensions: ['*']
1675
+ })
1676
+ }
1646
1677
 
1647
1678
  return filters
1648
1679
  },
@@ -2031,6 +2062,10 @@ export default {
2031
2062
  })
2032
2063
 
2033
2064
  try {
2065
+ if (typeof this.config.getUploadTicket === 'function'
2066
+ && this.sdkInstance.browserExpiresAt <= Date.now() + 30000) {
2067
+ await this.initializeSDK()
2068
+ }
2034
2069
  // 决定压缩策略
2035
2070
  const compressionStrategy = await this.determineCompressionStrategy(fileObj.file)
2036
2071
  let fileToUpload = fileObj.file
@@ -2492,6 +2527,7 @@ export default {
2492
2527
  /* 模拟iframe的body区域 */
2493
2528
  .modal-content {
2494
2529
  flex: 1;
2530
+ min-height: 0;
2495
2531
  overflow: hidden;
2496
2532
  position: relative;
2497
2533
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2511,6 +2547,7 @@ export default {
2511
2547
 
2512
2548
  /* 标题栏 */
2513
2549
  .modal-header {
2550
+ flex-shrink: 0;
2514
2551
  height: 50px !important;
2515
2552
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2516
2553
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2627,12 +2664,16 @@ export default {
2627
2664
 
2628
2665
  .content-grid {
2629
2666
  display: grid;
2630
- grid-template-columns: 350px 1fr;
2667
+ grid-template-columns: 350px minmax(0, 1fr);
2631
2668
  height: 100%;
2669
+ min-height: 0;
2632
2670
  position: relative;
2633
2671
  }
2634
2672
 
2635
2673
  .upload-panel {
2674
+ box-sizing: border-box;
2675
+ min-width: 0;
2676
+ min-height: 0;
2636
2677
  padding: 30px;
2637
2678
  background:
2638
2679
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2641,13 +2682,14 @@ export default {
2641
2682
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2642
2683
  display: flex;
2643
2684
  flex-direction: column;
2644
- justify-content: center;
2685
+ justify-content: flex-start;
2645
2686
  align-items: center;
2646
2687
  text-align: center;
2647
2688
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2648
2689
  cursor: pointer;
2649
2690
  position: relative;
2650
- overflow: hidden;
2691
+ overflow-x: hidden;
2692
+ overflow-y: auto;
2651
2693
  }
2652
2694
 
2653
2695
  .upload-panel::before {
@@ -2709,7 +2751,9 @@ export default {
2709
2751
  border-radius: 0;
2710
2752
  padding: 0;
2711
2753
  width: 100%;
2712
- height: 100%;
2754
+ height: auto;
2755
+ margin-block: auto;
2756
+ flex-shrink: 0;
2713
2757
  display: flex;
2714
2758
  flex-direction: column;
2715
2759
  justify-content: center;
@@ -2994,10 +3038,14 @@ export default {
2994
3038
  }
2995
3039
 
2996
3040
  .format-tags {
2997
- display: flex;
2998
- flex-wrap: wrap;
2999
- gap: 2px;
3041
+ display: -webkit-box;
3042
+ -webkit-box-orient: vertical;
3043
+ -webkit-line-clamp: 2;
3044
+ line-height: 20px;
3045
+ max-height: 40px;
3046
+ overflow: hidden;
3000
3047
  margin-top: 2px;
3048
+ cursor: help;
3001
3049
  }
3002
3050
 
3003
3051
  .format-tag {
@@ -3018,6 +3066,9 @@ export default {
3018
3066
  }
3019
3067
 
3020
3068
  .files-panel {
3069
+ box-sizing: border-box;
3070
+ min-width: 0;
3071
+ min-height: 0;
3021
3072
  padding: 30px;
3022
3073
  background:
3023
3074
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3561,4 +3612,53 @@ export default {
3561
3612
  grid-template-columns: 280px 1fr;
3562
3613
  }
3563
3614
  }
3615
+
3616
+ @media (max-width: 640px) {
3617
+ .jr-upload-modal-overlay.with-overlay .modal-content {
3618
+ padding: 0;
3619
+ }
3620
+
3621
+ .jr-upload-modal-overlay.with-overlay .main-container {
3622
+ width: 100%;
3623
+ height: 100% !important;
3624
+ border-radius: 0;
3625
+ }
3626
+
3627
+ .content-grid {
3628
+ grid-template-columns: minmax(0, 1fr);
3629
+ grid-template-rows: minmax(0, auto) minmax(160px, 1fr);
3630
+ }
3631
+
3632
+ .upload-panel {
3633
+ padding: 12px;
3634
+ border-right: 0;
3635
+ border-bottom: 1px solid rgba(200, 200, 200, 0.8);
3636
+ }
3637
+
3638
+ .upload-area {
3639
+ display: grid;
3640
+ grid-template-columns: 104px minmax(0, 1fr);
3641
+ gap: 12px;
3642
+ }
3643
+
3644
+ .upload-visual {
3645
+ display: none;
3646
+ }
3647
+
3648
+ .upload-button {
3649
+ width: 100%;
3650
+ padding: 10px 12px;
3651
+ overflow-wrap: anywhere;
3652
+ margin: 0;
3653
+ }
3654
+
3655
+ .upload-restrictions {
3656
+ min-width: 0;
3657
+ margin: 0;
3658
+ }
3659
+
3660
+ .files-panel {
3661
+ padding: 12px;
3662
+ }
3663
+ }
3564
3664
  </style>
@@ -1,4 +1,5 @@
1
1
  import JrUploadModal from './JrUploadModal.vue'
2
2
 
3
3
  export { JrUploadModal }
4
+ export { getAuthorizedFileUrl } from '../../shared/browser-access'
4
5
  export default JrUploadModal
@@ -90,9 +90,9 @@
90
90
  {{ waitingForValidation ? '正在验证文件...' : (validationMessage || '文件上传要求') }}
91
91
  </div>
92
92
  <ul class="restrictions-list" v-if="!validationMessage && !waitingForValidation">
93
- <li v-if="fileRestrictions.showFileTypeInfo && fileRestrictions.allowedExtensions" style="display: list-item;">
93
+ <li v-if="fileRestrictions.showFileTypeInfo && fileRestrictions.allowedExtensions.length" style="display: list-item;">
94
94
  支持格式:
95
- <div class="format-tags">
95
+ <div class="format-tags" :title="allowedExtensionsText" :aria-label="allowedExtensionsText" tabindex="0" @click.stop>
96
96
  <span
97
97
  v-for="ext in fileRestrictions.allowedExtensions"
98
98
  :key="ext"
@@ -259,10 +259,19 @@
259
259
 
260
260
  <script>
261
261
  import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, defineEmits, defineProps, nextTick, getCurrentInstance } from 'vue'
262
+ import { createUploadSdk } from '../../shared/browser-access'
263
+ import { loadUploadDependencies } from '../../shared/sdk-loader'
262
264
 
263
265
  // 组件统一允许的单文件最大值,maxSize 对外单位保持为 KB
264
266
  const MAX_UPLOAD_SIZE_KB = 10 * 1024 * 1024
265
267
 
268
+ // 统一处理前导点、空格和大小写,确保 accept 配置与真实文件后缀可直接比较。
269
+ const normalizeFileExtension = (value) =>
270
+ String(value || '').trim().toLowerCase().replace(/^\.+/, '')
271
+
272
+ const normalizeFileExtensions = (values) => Array.from(new Set(values
273
+ .map(normalizeFileExtension).filter(Boolean).map(ext => '.' + ext)))
274
+
266
275
  export default {
267
276
  name: 'JrUploadModalVue3',
268
277
 
@@ -308,7 +317,7 @@ export default {
308
317
  onClose: { type: Function, default: null },
309
318
 
310
319
  // 文件限制
311
- accept: { type: String, default: '' },
320
+ accept: { type: String, default: '' }, // 未传时读取上传服务允许类型
312
321
  maxSize: { type: Number, default: MAX_UPLOAD_SIZE_KB }, // KB,默认最大10GB
313
322
  maxCount: { type: Number, default: 10 },
314
323
  multiple: { type: Boolean, default: true },
@@ -378,6 +387,7 @@ export default {
378
387
 
379
388
  // SDK实例和配置
380
389
  const sdkInstance = ref(null)
390
+ const serverAllowedExtensions = ref([])
381
391
  const isElectronEnv = ref(false)
382
392
  const electronFileMap = ref(new Map())
383
393
  const waitingForValidation = ref(false)
@@ -408,18 +418,9 @@ export default {
408
418
 
409
419
  // 计算属性
410
420
  const fileRestrictions = computed(() => {
411
- const allowedExtensions = props.accept ? props.accept.split(',').map(ext => {
412
- const trimmed = ext.trim()
413
- return trimmed.startsWith('.') ? trimmed : '.' + trimmed
414
- }) : null
415
-
416
- if (allowedExtensions) {
417
- ['.aqtf', '.hftf', '.gef', '.tb_dg_gef', '.nsxtf', '.sxt2', '.gbq7', '.jmbs'].forEach(ext => {
418
- if (!allowedExtensions.some(item => item.toLowerCase() === ext)) {
419
- allowedExtensions.push(ext)
420
- }
421
- })
422
- }
421
+ const allowedExtensions = props.accept && props.accept.trim()
422
+ ? normalizeFileExtensions(props.accept.split(','))
423
+ : serverAllowedExtensions.value
423
424
 
424
425
  return {
425
426
  allowedExtensions,
@@ -436,7 +437,7 @@ export default {
436
437
  const isUploadDisabled = computed(() => {
437
438
  // 参考原始 stsUpload.html 的逻辑:只在真正达到文件数量限制时才禁用
438
439
  // 验证期间不禁用选择文件按钮,与原始页面行为保持一致
439
- if (props.disabled) {
440
+ if (props.disabled || !fileRestrictions.value.allowedExtensions.length) {
440
441
  return true
441
442
  }
442
443
 
@@ -450,7 +451,7 @@ export default {
450
451
 
451
452
  const uploadButtonText = computed(() => {
452
453
  if (isUploading.value) return '上传中...'
453
- if (isUploadDisabled.value && fileRestrictions.value.maxFileCount && fileRestrictions.value.maxFileCount > 0) {
454
+ if (fileRestrictions.value.maxFileCount > 0 && filesToUpload.value.length >= fileRestrictions.value.maxFileCount) {
454
455
  return `已达到限制 (${fileRestrictions.value.maxFileCount}个文件)`
455
456
  }
456
457
  return '选择文件'
@@ -461,20 +462,28 @@ export default {
461
462
  })
462
463
 
463
464
  const acceptedTypes = computed(() => {
464
- if (!fileRestrictions.value.allowedExtensions) return '*'
465
465
  return fileRestrictions.value.allowedExtensions.join(',')
466
466
  })
467
467
 
468
+ const allowedExtensionsText = computed(() =>
469
+ fileRestrictions.value.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、'))
470
+
468
471
  const showRestrictions = computed(() => {
469
472
  // 总是显示限制说明区域,但具体显示内容由各个参数控制
470
473
  // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
471
474
  return true
472
475
  })
473
476
 
477
+ watch(() => props.accept, () => {
478
+ if (sdkInstance.value) {
479
+ loadFileTypeRestrictions().catch(error => showError(error.message))
480
+ }
481
+ })
482
+
474
483
  // watch监听器
475
484
  watch(() => props.visible, async (newVal) => {
476
485
  if (newVal) {
477
- await initializeComponent()
486
+ await initializeComponent().catch(error => showError(error.message))
478
487
  // append-to-body: 弹框显示时将根元素移动到document.body
479
488
  if (props.appendToBody && instance && instance.vnode.el) {
480
489
  await nextTick()
@@ -545,20 +554,32 @@ export default {
545
554
 
546
555
  // 方法定义
547
556
  /**
548
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
557
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
549
558
  */
550
559
  const isAllowedFileExtension = (fileExt, allowedExtensions) => {
551
- const normalizedExt = (fileExt || '').toLowerCase()
560
+ const normalizedExt = normalizeFileExtension(fileExt)
552
561
  if (!normalizedExt) return false
553
562
 
554
- if (['.aqtf', '.hftf', '.gef', '.tb_dg_gef', '.nsxtf', '.sxt2', '.gbq7', '.jmbs'].includes(normalizedExt)
555
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
556
- return true
557
- }
558
-
559
- return allowedExtensions.some(ext => ext.toLowerCase() === normalizedExt)
563
+ return Array.isArray(allowedExtensions)
564
+ && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
560
565
  }
561
566
 
567
+ /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
568
+ const loadFileTypeRestrictions = async () => {
569
+ serverAllowedExtensions.value = []
570
+ if (props.accept && props.accept.trim()) {
571
+ if (!normalizeFileExtensions(props.accept.split(',')).length) {
572
+ throw new Error('未配置有效的允许上传类型')
573
+ }
574
+ return
575
+ }
576
+ const config = await sdkInstance.value.getFileExtensionConfig()
577
+ const extensions = config && Array.isArray(config.whitelist)
578
+ ? normalizeFileExtensions(config.whitelist) : []
579
+ if (!extensions.length) throw new Error('未获取到有效的允许上传类型')
580
+ serverAllowedExtensions.value = extensions
581
+ }
582
+
562
583
  const initializeComponent = async () => {
563
584
  isElectronEnv.value = detectElectronEnvironment()
564
585
 
@@ -600,76 +621,45 @@ export default {
600
621
 
601
622
  // 初始化Transfer SDK
602
623
  if (window.JrTransferSDK) {
603
- sdkInstance.value = new window.JrTransferSDK({
604
- baseUrl: props.config.baseUrl,
605
- apiToken: props.config.token,
624
+ sdkInstance.value = await createUploadSdk(window.JrTransferSDK, props.config, {
625
+ bucketName: props.bucketName,
626
+ uploadPath: props.uploadPath || props.config.uploadPath
606
627
  })
607
628
 
608
- emit('sdk-initialized', {
609
- success: true,
610
- timestamp: Date.now()
611
- })
612
-
613
- console.log('✅ Transfer SDK初始化成功')
614
629
  } else {
615
630
  throw new Error('JrTransferSDK未加载')
616
631
  }
617
632
 
633
+ await loadFileTypeRestrictions()
634
+
618
635
  // 如果启用了压缩,加载压缩配置
619
636
  if (props.enableCompression) {
620
637
  await loadCompressionConfig()
621
638
  }
639
+ emit('sdk-initialized', {
640
+ success: true,
641
+ timestamp: Date.now()
642
+ })
622
643
  } catch (error) {
644
+ sdkInstance.value = null
623
645
  console.error('❌ SDK初始化失败:', error)
624
646
  emit('sdk-initialized', {
625
647
  success: false,
626
648
  error: error.message,
627
649
  timestamp: Date.now()
628
650
  })
651
+ throw error
629
652
  }
630
653
  }
631
654
 
632
655
  const loadExternalDependencies = async () => {
633
- const baseUrl = props.config.baseUrl
634
- const dependencies = [
635
- `${baseUrl}/js/aliyun-oss-sdk-6.18.0.min.js`,
636
- `${baseUrl}/js/jr-transfer-sdk.js?v=20260814-10gb`,
637
- `${baseUrl}/js/jszip.min.js`
638
- ]
639
-
640
- // 检查是否已加载
641
- if (window.JrTransferSDK && window.JrTransferSDK.SDK_VERSION === '20260814-10gb' && window.OSS && window.JSZip) {
642
- return Promise.resolve()
643
- }
644
-
645
- // 动态加载脚本
646
- const loadScript = (src) => {
647
- return new Promise((resolve, reject) => {
648
- if (document.querySelector(`script[src="${src}"]`)) {
649
- resolve()
650
- return
651
- }
652
-
653
- const script = document.createElement('script')
654
- script.src = src
655
- script.onload = resolve
656
- script.onerror = reject
657
- document.head.appendChild(script)
658
- })
659
- }
660
-
661
- try {
662
- for (const dep of dependencies) {
663
- await loadScript(dep)
664
- }
665
- console.log('✅ 外部依赖加载完成')
666
- } catch (error) {
667
- console.error('❌ 外部依赖加载失败:', error)
668
- throw error
669
- }
656
+ await loadUploadDependencies(props.config.baseUrl)
670
657
  }
671
658
 
672
659
  const cleanup = () => {
660
+ sdkInstance.value = null
661
+ serverAllowedExtensions.value = []
662
+ compressionConfig.loaded = false
673
663
  if (autoCloseTimer.value) {
674
664
  clearTimeout(autoCloseTimer.value)
675
665
  autoCloseTimer.value = null
@@ -715,29 +705,21 @@ export default {
715
705
  }
716
706
 
717
707
  try {
718
- const baseUrl = props.config.baseUrl
719
- let apiUrl = `${baseUrl}/api/sts/compression-config?token=${encodeURIComponent(props.config.token)}`
720
-
721
- // 如果提供了bucketName,添加到请求参数中
722
- if (props.bucketName && props.bucketName.trim() !== '') {
723
- apiUrl += `&bucketName=${encodeURIComponent(props.bucketName.trim())}`
724
- }
725
-
726
- console.log('📡 请求压缩配置:', apiUrl)
727
-
728
- const response = await fetch(apiUrl)
729
-
730
- if (!response.ok) {
731
- throw new Error(`HTTP ${response.status}: ${response.statusText}`)
732
- }
733
-
734
- const result = await response.json()
735
-
736
- if (!result.success) {
737
- throw new Error(result.message || '获取压缩配置失败')
708
+ let config
709
+ if (sdkInstance.value && sdkInstance.value.browserAccessMode) {
710
+ config = await sdkInstance.value.getUploadCompressionConfig()
711
+ } else {
712
+ const baseUrl = props.config.baseUrl
713
+ let apiUrl = `${baseUrl}/api/sts/compression-config?token=${encodeURIComponent(props.config.token)}`
714
+ if (props.bucketName && props.bucketName.trim() !== '') {
715
+ apiUrl += `&bucketName=${encodeURIComponent(props.bucketName.trim())}`
716
+ }
717
+ const response = await fetch(apiUrl)
718
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`)
719
+ const result = await response.json()
720
+ if (!result.success) throw new Error(result.message || '获取压缩配置失败')
721
+ config = result.config
738
722
  }
739
-
740
- const config = result.config
741
723
  compressionConfig.level = config.level || 'balanced'
742
724
  compressionConfig.mode = config.mode || 'smart'
743
725
  compressionConfig.threshold = config.threshold || 10 * 1024 * 1024
@@ -750,6 +732,7 @@ export default {
750
732
  return compressionConfig
751
733
 
752
734
  } catch (error) {
735
+ if (typeof props.config.getUploadTicket === 'function' || props.config.browserTicket) throw error
753
736
  console.error('❌ 获取压缩配置失败,使用默认配置:', error)
754
737
  // 使用默认配置
755
738
  compressionConfig.enabled = props.enableCompression
@@ -799,6 +782,8 @@ export default {
799
782
  if (!props.enableCompression) {
800
783
  return 'none'
801
784
  }
785
+ // 受限 STS 使用浏览器直传,压缩在当前页面完成。
786
+ if (sdkInstance.value && sdkInstance.value.browserAccessMode) return 'frontend'
802
787
 
803
788
  await loadCompressionConfig()
804
789
 
@@ -1371,7 +1356,7 @@ export default {
1371
1356
  try {
1372
1357
  // 构建文件过滤器(与原始页面逻辑一致)
1373
1358
  const filters = []
1374
- if (fileRestrictions.value.showFileTypeInfo && fileRestrictions.value.allowedExtensions) {
1359
+ if (fileRestrictions.value.allowedExtensions.length) {
1375
1360
  const extensions = fileRestrictions.value.allowedExtensions.map(ext =>
1376
1361
  ext.startsWith('.') ? ext.slice(1) : ext
1377
1362
  )
@@ -1639,6 +1624,49 @@ export default {
1639
1624
  'sxt2': 'application/octet-stream',
1640
1625
  'gbq7': 'application/octet-stream',
1641
1626
  'jmbs': 'application/octet-stream',
1627
+ 'ujyzbx': 'application/octet-stream',
1628
+ 'zkzf': 'application/octet-stream',
1629
+ 'nzktf': 'application/octet-stream',
1630
+ 'zgzs': 'application/octet-stream',
1631
+ 'zgzf': 'application/octet-stream',
1632
+ 'zgsf': 'application/octet-stream',
1633
+ 'zgtf': 'application/octet-stream',
1634
+ 'zgcs': 'application/octet-stream',
1635
+ 'zgcf': 'application/octet-stream',
1636
+ 'tbsx': 'application/octet-stream',
1637
+ 'sgef': 'application/octet-stream',
1638
+ 'czr': 'application/octet-stream',
1639
+ 'zytf': 'application/octet-stream',
1640
+ 'nzjy': 'application/octet-stream',
1641
+ 'zsf': 'application/octet-stream',
1642
+ 'gscs': 'application/octet-stream',
1643
+ 'gscf': 'application/octet-stream',
1644
+ 'zbxs': 'application/octet-stream',
1645
+ 'zbwj': 'application/octet-stream',
1646
+ 'zyzf': 'application/octet-stream',
1647
+ 'gszs': 'application/octet-stream',
1648
+ 'gszf': 'application/octet-stream',
1649
+ 'zbjy': 'application/octet-stream',
1650
+ 'zbsx': 'application/octet-stream',
1651
+ 'gctb': 'application/octet-stream',
1652
+ 'fwtb': 'application/octet-stream',
1653
+ 'nzytf': 'application/octet-stream',
1654
+ 'mtbjy': 'application/octet-stream',
1655
+ 'gstf': 'application/octet-stream',
1656
+ 'dxtf': 'application/octet-stream',
1657
+ 'gssf': 'application/octet-stream',
1658
+ 'qbcg': 'application/octet-stream',
1659
+ 'jtb4': 'application/octet-stream',
1660
+ 'jzb4': 'application/octet-stream',
1661
+ 'xml': 'application/xml',
1662
+ 'ydbx': 'application/octet-stream',
1663
+ 'ydjc': 'application/octet-stream',
1664
+ 'sxzb': 'application/octet-stream',
1665
+ 'sxtb': 'application/octet-stream',
1666
+ 'sxxj': 'application/octet-stream',
1667
+ 'hebzbx': 'application/octet-stream',
1668
+ 'hebkzjx': 'application/octet-stream',
1669
+ 'hebtbx': 'application/octet-stream',
1642
1670
  'ppt': 'application/vnd.ms-powerpoint',
1643
1671
  'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
1644
1672
  'txt': 'text/plain',
@@ -1656,7 +1684,7 @@ export default {
1656
1684
  const getElectronFileFilters = () => {
1657
1685
  const filters = []
1658
1686
 
1659
- if (fileRestrictions.value.allowedExtensions) {
1687
+ if (fileRestrictions.value.allowedExtensions.length) {
1660
1688
  const extensions = fileRestrictions.value.allowedExtensions.map(ext => ext.replace('.', ''))
1661
1689
  filters.push({
1662
1690
  name: '支持的文件',
@@ -1664,10 +1692,12 @@ export default {
1664
1692
  })
1665
1693
  }
1666
1694
 
1667
- filters.push({
1668
- name: '所有文件',
1669
- extensions: ['*']
1670
- })
1695
+ if (!filters.length) {
1696
+ filters.push({
1697
+ name: '所有文件',
1698
+ extensions: ['*']
1699
+ })
1700
+ }
1671
1701
 
1672
1702
  return filters
1673
1703
  }
@@ -2034,9 +2064,9 @@ export default {
2034
2064
  } finally {
2035
2065
  isUploading.value = false
2036
2066
  }
2037
- },
2038
-
2039
- const uploadSingleFile = async (fileObj) => {
2067
+ }
2068
+
2069
+ const uploadSingleFile = async (fileObj) => {
2040
2070
  console.log('📤 上传文件:', fileObj.name)
2041
2071
 
2042
2072
  if (!sdkInstance.value) {
@@ -2056,6 +2086,10 @@ export default {
2056
2086
  })
2057
2087
 
2058
2088
  try {
2089
+ if (typeof props.config.getUploadTicket === 'function'
2090
+ && sdkInstance.value.browserExpiresAt <= Date.now() + 30000) {
2091
+ await initializeSDK()
2092
+ }
2059
2093
  // 决定压缩策略
2060
2094
  const compressionStrategy = await determineCompressionStrategy(fileObj.file)
2061
2095
  let fileToUpload = fileObj.file
@@ -2228,9 +2262,9 @@ export default {
2228
2262
  }, 8000)
2229
2263
  }
2230
2264
  }
2231
- },
2232
-
2233
- // 文件压缩判断
2265
+ }
2266
+
2267
+ // 文件压缩判断
2234
2268
  const shouldCompressFile = (file) => {
2235
2269
  if (!props.enableCompression) return false
2236
2270
 
@@ -2438,6 +2472,7 @@ export default {
2438
2472
  uploadButtonText,
2439
2473
  hasPendingFiles,
2440
2474
  acceptedTypes,
2475
+ allowedExtensionsText,
2441
2476
  showRestrictions,
2442
2477
 
2443
2478
  // 模板引用
@@ -2605,6 +2640,7 @@ export default {
2605
2640
  /* 模拟iframe的body区域 */
2606
2641
  .modal-content {
2607
2642
  flex: 1;
2643
+ min-height: 0;
2608
2644
  overflow: hidden;
2609
2645
  position: relative;
2610
2646
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2624,6 +2660,7 @@ export default {
2624
2660
 
2625
2661
  /* 标题栏 */
2626
2662
  .modal-header {
2663
+ flex-shrink: 0;
2627
2664
  height: 50px !important;
2628
2665
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2629
2666
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2740,12 +2777,16 @@ export default {
2740
2777
 
2741
2778
  .content-grid {
2742
2779
  display: grid;
2743
- grid-template-columns: 350px 1fr;
2780
+ grid-template-columns: 350px minmax(0, 1fr);
2744
2781
  height: 100%;
2782
+ min-height: 0;
2745
2783
  position: relative;
2746
2784
  }
2747
2785
 
2748
2786
  .upload-panel {
2787
+ box-sizing: border-box;
2788
+ min-width: 0;
2789
+ min-height: 0;
2749
2790
  padding: 30px;
2750
2791
  background:
2751
2792
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2754,13 +2795,14 @@ export default {
2754
2795
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2755
2796
  display: flex;
2756
2797
  flex-direction: column;
2757
- justify-content: center;
2798
+ justify-content: flex-start;
2758
2799
  align-items: center;
2759
2800
  text-align: center;
2760
2801
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2761
2802
  cursor: pointer;
2762
2803
  position: relative;
2763
- overflow: hidden;
2804
+ overflow-x: hidden;
2805
+ overflow-y: auto;
2764
2806
  }
2765
2807
 
2766
2808
  .upload-panel::before {
@@ -2822,7 +2864,9 @@ export default {
2822
2864
  border-radius: 0;
2823
2865
  padding: 0;
2824
2866
  width: 100%;
2825
- height: 100%;
2867
+ height: auto;
2868
+ margin-block: auto;
2869
+ flex-shrink: 0;
2826
2870
  display: flex;
2827
2871
  flex-direction: column;
2828
2872
  justify-content: center;
@@ -3107,10 +3151,14 @@ export default {
3107
3151
  }
3108
3152
 
3109
3153
  .format-tags {
3110
- display: flex;
3111
- flex-wrap: wrap;
3112
- gap: 2px;
3154
+ display: -webkit-box;
3155
+ -webkit-box-orient: vertical;
3156
+ -webkit-line-clamp: 2;
3157
+ line-height: 20px;
3158
+ max-height: 40px;
3159
+ overflow: hidden;
3113
3160
  margin-top: 2px;
3161
+ cursor: help;
3114
3162
  }
3115
3163
 
3116
3164
  .format-tag {
@@ -3131,6 +3179,9 @@ export default {
3131
3179
  }
3132
3180
 
3133
3181
  .files-panel {
3182
+ box-sizing: border-box;
3183
+ min-width: 0;
3184
+ min-height: 0;
3134
3185
  padding: 30px;
3135
3186
  background:
3136
3187
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3674,4 +3725,53 @@ export default {
3674
3725
  grid-template-columns: 280px 1fr;
3675
3726
  }
3676
3727
  }
3728
+
3729
+ @media (max-width: 640px) {
3730
+ .jr-upload-modal-overlay.with-overlay .modal-content {
3731
+ padding: 0;
3732
+ }
3733
+
3734
+ .jr-upload-modal-overlay.with-overlay .main-container {
3735
+ width: 100%;
3736
+ height: 100% !important;
3737
+ border-radius: 0;
3738
+ }
3739
+
3740
+ .content-grid {
3741
+ grid-template-columns: minmax(0, 1fr);
3742
+ grid-template-rows: minmax(0, auto) minmax(160px, 1fr);
3743
+ }
3744
+
3745
+ .upload-panel {
3746
+ padding: 12px;
3747
+ border-right: 0;
3748
+ border-bottom: 1px solid rgba(200, 200, 200, 0.8);
3749
+ }
3750
+
3751
+ .upload-area {
3752
+ display: grid;
3753
+ grid-template-columns: 104px minmax(0, 1fr);
3754
+ gap: 12px;
3755
+ }
3756
+
3757
+ .upload-visual {
3758
+ display: none;
3759
+ }
3760
+
3761
+ .upload-button {
3762
+ width: 100%;
3763
+ padding: 10px 12px;
3764
+ overflow-wrap: anywhere;
3765
+ margin: 0;
3766
+ }
3767
+
3768
+ .upload-restrictions {
3769
+ min-width: 0;
3770
+ margin: 0;
3771
+ }
3772
+
3773
+ .files-panel {
3774
+ padding: 12px;
3775
+ }
3776
+ }
3677
3777
  </style>
@@ -1,4 +1,5 @@
1
1
  import JrUploadModalVue3 from './JrUploadModalVUE3.vue'
2
2
 
3
3
  export { JrUploadModalVue3 }
4
+ export { getAuthorizedFileUrl } from '../../shared/browser-access'
4
5
  export default JrUploadModalVue3
package/vue2/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // vue2 入口文件 - 转发到实际的源文件
2
- export { default, JrUploadModal } from '../packages/vue2/src/index.js'
2
+ export { default, JrUploadModal, getAuthorizedFileUrl } from '../packages/vue2/src/index.js'
package/vue3/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // vue3 入口文件 - 转发到实际的源文件
2
- export { default, JrUploadModalVue3 } from '../packages/vue3/src/index.js'
2
+ export { default, JrUploadModalVue3, getAuthorizedFileUrl } from '../packages/vue3/src/index.js'