@jr-public/jr-upload-ui 1.1.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jr-public/jr-upload-ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "JR upload modal components for Vue2 and Vue3",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -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"
@@ -259,23 +259,17 @@
259
259
 
260
260
  <script>
261
261
  import { createUploadSdk } from '../../shared/browser-access'
262
+ import { loadUploadDependencies } from '../../shared/sdk-loader'
262
263
  // 组件统一允许的单文件最大值,maxSize 对外单位保持为 KB
263
264
  const MAX_UPLOAD_SIZE_KB = 10 * 1024 * 1024
264
265
 
265
- // 组件内置业务后缀白名单,统一使用不带点号的小写形式。
266
- const DEFAULT_UPLOAD_EXTENSIONS = [
267
- 'aqtf', 'hftf', 'gef', 'tb_dg_gef', 'nsxtf', 'sxt2', 'gbq7', 'jmbs',
268
- 'ujyzbx', 'zkzf', 'nzktf', 'zgzs', 'zgzf', 'zgsf', 'zgtf', 'zgcs', 'zgcf', 'tbsx', 'sgef', 'czr', 'zytf',
269
- 'nzjy', 'zsf', 'gscs', 'gscf', 'zbxs', 'zbwj', 'zyzf', 'gszs', 'gszf', 'zbjy',
270
- 'zbsx', 'gctb', 'fwtb', 'nzytf', 'mtbjy', 'gstf', 'dxtf', 'gssf',
271
- 'qbcg', 'jtb4', 'jzb4', 'xml', 'ydbx', 'ydjc', 'sxzb', 'sxtb', 'sxxj',
272
- 'hebzbx', 'hebkzjx', 'hebtbx'
273
- ]
274
-
275
266
  // 统一处理前导点、空格和大小写,确保 accept 配置与真实文件后缀可直接比较。
276
267
  const normalizeFileExtension = (value) =>
277
268
  String(value || '').trim().toLowerCase().replace(/^\.+/, '')
278
269
 
270
+ const normalizeFileExtensions = (values) => Array.from(new Set(values
271
+ .map(normalizeFileExtension).filter(Boolean).map(ext => '.' + ext)))
272
+
279
273
  export default {
280
274
  name: 'JrUploadModal',
281
275
 
@@ -321,7 +315,7 @@ export default {
321
315
  onClose: { type: Function, default: null },
322
316
 
323
317
  // 文件限制
324
- accept: { type: String, default: '' },
318
+ accept: { type: String, default: '' }, // 未传时读取上传服务允许类型
325
319
  maxSize: { type: Number, default: MAX_UPLOAD_SIZE_KB }, // KB,默认最大10GB
326
320
  maxCount: { type: Number, default: 10 },
327
321
  multiple: { type: Boolean, default: true },
@@ -377,6 +371,7 @@ export default {
377
371
 
378
372
  // SDK实例和配置
379
373
  sdkInstance: null,
374
+ serverAllowedExtensions: [],
380
375
  isElectronEnv: false,
381
376
  electronFileMap: new Map(),
382
377
  waitingForValidation: false,
@@ -401,18 +396,9 @@ export default {
401
396
 
402
397
  computed: {
403
398
  fileRestrictions() {
404
- const allowedExtensions = this.accept ? this.accept.split(',').map(ext => {
405
- const normalized = normalizeFileExtension(ext)
406
- return normalized ? '.' + normalized : ''
407
- }).filter(Boolean) : null
408
-
409
- if (allowedExtensions) {
410
- DEFAULT_UPLOAD_EXTENSIONS.forEach(ext => {
411
- if (!allowedExtensions.some(item => normalizeFileExtension(item) === ext)) {
412
- allowedExtensions.push('.' + ext)
413
- }
414
- })
415
- }
399
+ const allowedExtensions = this.accept && this.accept.trim()
400
+ ? normalizeFileExtensions(this.accept.split(','))
401
+ : this.serverAllowedExtensions
416
402
 
417
403
  return {
418
404
  allowedExtensions,
@@ -429,7 +415,7 @@ export default {
429
415
  isUploadDisabled() {
430
416
  // 参考原始 stsUpload.html 的逻辑:只在真正达到文件数量限制时才禁用
431
417
  // 验证期间不禁用选择文件按钮,与原始页面行为保持一致
432
- if (this.disabled) {
418
+ if (this.disabled || !this.fileRestrictions.allowedExtensions.length) {
433
419
  return true
434
420
  }
435
421
 
@@ -443,7 +429,7 @@ export default {
443
429
 
444
430
  uploadButtonText() {
445
431
  if (this.isUploading) return '上传中...'
446
- if (this.isUploadDisabled && this.fileRestrictions.maxFileCount && this.fileRestrictions.maxFileCount > 0) {
432
+ if (this.fileRestrictions.maxFileCount > 0 && this.filesToUpload.length >= this.fileRestrictions.maxFileCount) {
447
433
  return `已达到限制 (${this.fileRestrictions.maxFileCount}个文件)`
448
434
  }
449
435
  return '选择文件'
@@ -454,10 +440,13 @@ export default {
454
440
  },
455
441
 
456
442
  acceptedTypes() {
457
- if (!this.fileRestrictions.allowedExtensions) return '*'
458
443
  return this.fileRestrictions.allowedExtensions.join(',')
459
444
  },
460
445
 
446
+ allowedExtensionsText() {
447
+ return this.fileRestrictions.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、')
448
+ },
449
+
461
450
  showRestrictions() {
462
451
  // 总是显示限制说明区域,但具体显示内容由各个参数控制
463
452
  // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
@@ -466,6 +455,12 @@ export default {
466
455
  },
467
456
 
468
457
  watch: {
458
+ accept() {
459
+ if (this.sdkInstance) {
460
+ this.loadFileTypeRestrictions().catch(error => this.showError(error.message))
461
+ }
462
+ },
463
+
469
464
  visible(newVal) {
470
465
  if (newVal) {
471
466
  this.initializeComponent().catch(error => this.showError(error.message))
@@ -537,21 +532,32 @@ export default {
537
532
 
538
533
  methods: {
539
534
  /**
540
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
535
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
541
536
  */
542
537
  isAllowedFileExtension(fileExt, allowedExtensions) {
543
538
  const normalizedExt = normalizeFileExtension(fileExt)
544
539
  if (!normalizedExt) return false
545
540
 
546
- if (DEFAULT_UPLOAD_EXTENSIONS.includes(normalizedExt)
547
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
548
- return true
549
- }
550
-
551
541
  return Array.isArray(allowedExtensions)
552
542
  && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
553
543
  },
554
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
+
555
561
  async initializeComponent() {
556
562
  this.isElectronEnv = this.detectElectronEnvironment()
557
563
 
@@ -602,6 +608,8 @@ export default {
602
608
  throw new Error('JrTransferSDK未加载')
603
609
  }
604
610
 
611
+ await this.loadFileTypeRestrictions()
612
+
605
613
  // 如果启用了压缩,加载压缩配置
606
614
  if (this.enableCompression) {
607
615
  await this.loadCompressionConfig()
@@ -623,47 +631,12 @@ export default {
623
631
  },
624
632
 
625
633
  async loadExternalDependencies() {
626
- const baseUrl = this.config.baseUrl
627
- const dependencies = [
628
- `${baseUrl}/js/aliyun-oss-sdk-6.18.0.min.js`,
629
- `${baseUrl}/js/jr-transfer-sdk.js?v=20261014-ext`,
630
- `${baseUrl}/js/jszip.min.js`
631
- ]
632
-
633
- // 检查是否已加载
634
- if (window.JrTransferSDK && window.JrTransferSDK.SDK_VERSION === '20261014-ext' && window.OSS && window.JSZip) {
635
- return Promise.resolve()
636
- }
637
-
638
- // 动态加载脚本
639
- const loadScript = (src) => {
640
- return new Promise((resolve, reject) => {
641
- if (document.querySelector(`script[src="${src}"]`)) {
642
- resolve()
643
- return
644
- }
645
-
646
- const script = document.createElement('script')
647
- script.src = src
648
- script.onload = resolve
649
- script.onerror = reject
650
- document.head.appendChild(script)
651
- })
652
- }
653
-
654
- try {
655
- for (const dep of dependencies) {
656
- await loadScript(dep)
657
- }
658
- console.log('✅ 外部依赖加载完成')
659
- } catch (error) {
660
- console.error('❌ 外部依赖加载失败:', error)
661
- throw error
662
- }
634
+ await loadUploadDependencies(this.config.baseUrl)
663
635
  },
664
636
 
665
637
  cleanup() {
666
638
  this.sdkInstance = null
639
+ this.serverAllowedExtensions = []
667
640
  this.compressionConfig.loaded = false
668
641
  if (this.autoCloseTimer) {
669
642
  clearTimeout(this.autoCloseTimer)
@@ -1359,7 +1332,7 @@ export default {
1359
1332
  try {
1360
1333
  // 构建文件过滤器(与原始页面逻辑一致)
1361
1334
  const filters = []
1362
- if (this.fileRestrictions.showFileTypeInfo && this.fileRestrictions.allowedExtensions) {
1335
+ if (this.fileRestrictions.allowedExtensions.length) {
1363
1336
  const extensions = this.fileRestrictions.allowedExtensions.map(ext =>
1364
1337
  ext.startsWith('.') ? ext.slice(1) : ext
1365
1338
  )
@@ -1687,7 +1660,7 @@ export default {
1687
1660
  getElectronFileFilters() {
1688
1661
  const filters = []
1689
1662
 
1690
- if (this.fileRestrictions.allowedExtensions) {
1663
+ if (this.fileRestrictions.allowedExtensions.length) {
1691
1664
  const extensions = this.fileRestrictions.allowedExtensions.map(ext => ext.replace('.', ''))
1692
1665
  filters.push({
1693
1666
  name: '支持的文件',
@@ -1695,10 +1668,12 @@ export default {
1695
1668
  })
1696
1669
  }
1697
1670
 
1698
- filters.push({
1699
- name: '所有文件',
1700
- extensions: ['*']
1701
- })
1671
+ if (!filters.length) {
1672
+ filters.push({
1673
+ name: '所有文件',
1674
+ extensions: ['*']
1675
+ })
1676
+ }
1702
1677
 
1703
1678
  return filters
1704
1679
  },
@@ -2552,6 +2527,7 @@ export default {
2552
2527
  /* 模拟iframe的body区域 */
2553
2528
  .modal-content {
2554
2529
  flex: 1;
2530
+ min-height: 0;
2555
2531
  overflow: hidden;
2556
2532
  position: relative;
2557
2533
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2571,6 +2547,7 @@ export default {
2571
2547
 
2572
2548
  /* 标题栏 */
2573
2549
  .modal-header {
2550
+ flex-shrink: 0;
2574
2551
  height: 50px !important;
2575
2552
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2576
2553
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2687,12 +2664,16 @@ export default {
2687
2664
 
2688
2665
  .content-grid {
2689
2666
  display: grid;
2690
- grid-template-columns: 350px 1fr;
2667
+ grid-template-columns: 350px minmax(0, 1fr);
2691
2668
  height: 100%;
2669
+ min-height: 0;
2692
2670
  position: relative;
2693
2671
  }
2694
2672
 
2695
2673
  .upload-panel {
2674
+ box-sizing: border-box;
2675
+ min-width: 0;
2676
+ min-height: 0;
2696
2677
  padding: 30px;
2697
2678
  background:
2698
2679
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2701,13 +2682,14 @@ export default {
2701
2682
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2702
2683
  display: flex;
2703
2684
  flex-direction: column;
2704
- justify-content: center;
2685
+ justify-content: flex-start;
2705
2686
  align-items: center;
2706
2687
  text-align: center;
2707
2688
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2708
2689
  cursor: pointer;
2709
2690
  position: relative;
2710
- overflow: hidden;
2691
+ overflow-x: hidden;
2692
+ overflow-y: auto;
2711
2693
  }
2712
2694
 
2713
2695
  .upload-panel::before {
@@ -2769,7 +2751,9 @@ export default {
2769
2751
  border-radius: 0;
2770
2752
  padding: 0;
2771
2753
  width: 100%;
2772
- height: 100%;
2754
+ height: auto;
2755
+ margin-block: auto;
2756
+ flex-shrink: 0;
2773
2757
  display: flex;
2774
2758
  flex-direction: column;
2775
2759
  justify-content: center;
@@ -3054,10 +3038,14 @@ export default {
3054
3038
  }
3055
3039
 
3056
3040
  .format-tags {
3057
- display: flex;
3058
- flex-wrap: wrap;
3059
- 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;
3060
3047
  margin-top: 2px;
3048
+ cursor: help;
3061
3049
  }
3062
3050
 
3063
3051
  .format-tag {
@@ -3078,6 +3066,9 @@ export default {
3078
3066
  }
3079
3067
 
3080
3068
  .files-panel {
3069
+ box-sizing: border-box;
3070
+ min-width: 0;
3071
+ min-height: 0;
3081
3072
  padding: 30px;
3082
3073
  background:
3083
3074
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3621,4 +3612,53 @@ export default {
3621
3612
  grid-template-columns: 280px 1fr;
3622
3613
  }
3623
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
+ }
3624
3664
  </style>
@@ -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"
@@ -260,24 +260,18 @@
260
260
  <script>
261
261
  import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, defineEmits, defineProps, nextTick, getCurrentInstance } from 'vue'
262
262
  import { createUploadSdk } from '../../shared/browser-access'
263
+ import { loadUploadDependencies } from '../../shared/sdk-loader'
263
264
 
264
265
  // 组件统一允许的单文件最大值,maxSize 对外单位保持为 KB
265
266
  const MAX_UPLOAD_SIZE_KB = 10 * 1024 * 1024
266
267
 
267
- // 组件内置业务后缀白名单,统一使用不带点号的小写形式。
268
- const DEFAULT_UPLOAD_EXTENSIONS = [
269
- 'aqtf', 'hftf', 'gef', 'tb_dg_gef', 'nsxtf', 'sxt2', 'gbq7', 'jmbs',
270
- 'ujyzbx', 'zkzf', 'nzktf', 'zgzs', 'zgzf', 'zgsf', 'zgtf', 'zgcs', 'zgcf', 'tbsx', 'sgef', 'czr', 'zytf',
271
- 'nzjy', 'zsf', 'gscs', 'gscf', 'zbxs', 'zbwj', 'zyzf', 'gszs', 'gszf', 'zbjy',
272
- 'zbsx', 'gctb', 'fwtb', 'nzytf', 'mtbjy', 'gstf', 'dxtf', 'gssf',
273
- 'qbcg', 'jtb4', 'jzb4', 'xml', 'ydbx', 'ydjc', 'sxzb', 'sxtb', 'sxxj',
274
- 'hebzbx', 'hebkzjx', 'hebtbx'
275
- ]
276
-
277
268
  // 统一处理前导点、空格和大小写,确保 accept 配置与真实文件后缀可直接比较。
278
269
  const normalizeFileExtension = (value) =>
279
270
  String(value || '').trim().toLowerCase().replace(/^\.+/, '')
280
271
 
272
+ const normalizeFileExtensions = (values) => Array.from(new Set(values
273
+ .map(normalizeFileExtension).filter(Boolean).map(ext => '.' + ext)))
274
+
281
275
  export default {
282
276
  name: 'JrUploadModalVue3',
283
277
 
@@ -323,7 +317,7 @@ export default {
323
317
  onClose: { type: Function, default: null },
324
318
 
325
319
  // 文件限制
326
- accept: { type: String, default: '' },
320
+ accept: { type: String, default: '' }, // 未传时读取上传服务允许类型
327
321
  maxSize: { type: Number, default: MAX_UPLOAD_SIZE_KB }, // KB,默认最大10GB
328
322
  maxCount: { type: Number, default: 10 },
329
323
  multiple: { type: Boolean, default: true },
@@ -393,6 +387,7 @@ export default {
393
387
 
394
388
  // SDK实例和配置
395
389
  const sdkInstance = ref(null)
390
+ const serverAllowedExtensions = ref([])
396
391
  const isElectronEnv = ref(false)
397
392
  const electronFileMap = ref(new Map())
398
393
  const waitingForValidation = ref(false)
@@ -423,18 +418,9 @@ export default {
423
418
 
424
419
  // 计算属性
425
420
  const fileRestrictions = computed(() => {
426
- const allowedExtensions = props.accept ? props.accept.split(',').map(ext => {
427
- const normalized = normalizeFileExtension(ext)
428
- return normalized ? '.' + normalized : ''
429
- }).filter(Boolean) : null
430
-
431
- if (allowedExtensions) {
432
- DEFAULT_UPLOAD_EXTENSIONS.forEach(ext => {
433
- if (!allowedExtensions.some(item => normalizeFileExtension(item) === ext)) {
434
- allowedExtensions.push('.' + ext)
435
- }
436
- })
437
- }
421
+ const allowedExtensions = props.accept && props.accept.trim()
422
+ ? normalizeFileExtensions(props.accept.split(','))
423
+ : serverAllowedExtensions.value
438
424
 
439
425
  return {
440
426
  allowedExtensions,
@@ -451,7 +437,7 @@ export default {
451
437
  const isUploadDisabled = computed(() => {
452
438
  // 参考原始 stsUpload.html 的逻辑:只在真正达到文件数量限制时才禁用
453
439
  // 验证期间不禁用选择文件按钮,与原始页面行为保持一致
454
- if (props.disabled) {
440
+ if (props.disabled || !fileRestrictions.value.allowedExtensions.length) {
455
441
  return true
456
442
  }
457
443
 
@@ -465,7 +451,7 @@ export default {
465
451
 
466
452
  const uploadButtonText = computed(() => {
467
453
  if (isUploading.value) return '上传中...'
468
- if (isUploadDisabled.value && fileRestrictions.value.maxFileCount && fileRestrictions.value.maxFileCount > 0) {
454
+ if (fileRestrictions.value.maxFileCount > 0 && filesToUpload.value.length >= fileRestrictions.value.maxFileCount) {
469
455
  return `已达到限制 (${fileRestrictions.value.maxFileCount}个文件)`
470
456
  }
471
457
  return '选择文件'
@@ -476,16 +462,24 @@ export default {
476
462
  })
477
463
 
478
464
  const acceptedTypes = computed(() => {
479
- if (!fileRestrictions.value.allowedExtensions) return '*'
480
465
  return fileRestrictions.value.allowedExtensions.join(',')
481
466
  })
482
467
 
468
+ const allowedExtensionsText = computed(() =>
469
+ fileRestrictions.value.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、'))
470
+
483
471
  const showRestrictions = computed(() => {
484
472
  // 总是显示限制说明区域,但具体显示内容由各个参数控制
485
473
  // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
486
474
  return true
487
475
  })
488
476
 
477
+ watch(() => props.accept, () => {
478
+ if (sdkInstance.value) {
479
+ loadFileTypeRestrictions().catch(error => showError(error.message))
480
+ }
481
+ })
482
+
489
483
  // watch监听器
490
484
  watch(() => props.visible, async (newVal) => {
491
485
  if (newVal) {
@@ -560,21 +554,32 @@ export default {
560
554
 
561
555
  // 方法定义
562
556
  /**
563
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
557
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
564
558
  */
565
559
  const isAllowedFileExtension = (fileExt, allowedExtensions) => {
566
560
  const normalizedExt = normalizeFileExtension(fileExt)
567
561
  if (!normalizedExt) return false
568
562
 
569
- if (DEFAULT_UPLOAD_EXTENSIONS.includes(normalizedExt)
570
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
571
- return true
572
- }
573
-
574
563
  return Array.isArray(allowedExtensions)
575
564
  && allowedExtensions.some(ext => normalizeFileExtension(ext) === normalizedExt)
576
565
  }
577
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
+
578
583
  const initializeComponent = async () => {
579
584
  isElectronEnv.value = detectElectronEnvironment()
580
585
 
@@ -625,6 +630,8 @@ export default {
625
630
  throw new Error('JrTransferSDK未加载')
626
631
  }
627
632
 
633
+ await loadFileTypeRestrictions()
634
+
628
635
  // 如果启用了压缩,加载压缩配置
629
636
  if (props.enableCompression) {
630
637
  await loadCompressionConfig()
@@ -646,47 +653,12 @@ export default {
646
653
  }
647
654
 
648
655
  const loadExternalDependencies = async () => {
649
- const baseUrl = props.config.baseUrl
650
- const dependencies = [
651
- `${baseUrl}/js/aliyun-oss-sdk-6.18.0.min.js`,
652
- `${baseUrl}/js/jr-transfer-sdk.js?v=20261014-ext`,
653
- `${baseUrl}/js/jszip.min.js`
654
- ]
655
-
656
- // 检查是否已加载
657
- if (window.JrTransferSDK && window.JrTransferSDK.SDK_VERSION === '20261014-ext' && window.OSS && window.JSZip) {
658
- return Promise.resolve()
659
- }
660
-
661
- // 动态加载脚本
662
- const loadScript = (src) => {
663
- return new Promise((resolve, reject) => {
664
- if (document.querySelector(`script[src="${src}"]`)) {
665
- resolve()
666
- return
667
- }
668
-
669
- const script = document.createElement('script')
670
- script.src = src
671
- script.onload = resolve
672
- script.onerror = reject
673
- document.head.appendChild(script)
674
- })
675
- }
676
-
677
- try {
678
- for (const dep of dependencies) {
679
- await loadScript(dep)
680
- }
681
- console.log('✅ 外部依赖加载完成')
682
- } catch (error) {
683
- console.error('❌ 外部依赖加载失败:', error)
684
- throw error
685
- }
656
+ await loadUploadDependencies(props.config.baseUrl)
686
657
  }
687
658
 
688
659
  const cleanup = () => {
689
660
  sdkInstance.value = null
661
+ serverAllowedExtensions.value = []
690
662
  compressionConfig.loaded = false
691
663
  if (autoCloseTimer.value) {
692
664
  clearTimeout(autoCloseTimer.value)
@@ -1384,7 +1356,7 @@ export default {
1384
1356
  try {
1385
1357
  // 构建文件过滤器(与原始页面逻辑一致)
1386
1358
  const filters = []
1387
- if (fileRestrictions.value.showFileTypeInfo && fileRestrictions.value.allowedExtensions) {
1359
+ if (fileRestrictions.value.allowedExtensions.length) {
1388
1360
  const extensions = fileRestrictions.value.allowedExtensions.map(ext =>
1389
1361
  ext.startsWith('.') ? ext.slice(1) : ext
1390
1362
  )
@@ -1712,7 +1684,7 @@ export default {
1712
1684
  const getElectronFileFilters = () => {
1713
1685
  const filters = []
1714
1686
 
1715
- if (fileRestrictions.value.allowedExtensions) {
1687
+ if (fileRestrictions.value.allowedExtensions.length) {
1716
1688
  const extensions = fileRestrictions.value.allowedExtensions.map(ext => ext.replace('.', ''))
1717
1689
  filters.push({
1718
1690
  name: '支持的文件',
@@ -1720,10 +1692,12 @@ export default {
1720
1692
  })
1721
1693
  }
1722
1694
 
1723
- filters.push({
1724
- name: '所有文件',
1725
- extensions: ['*']
1726
- })
1695
+ if (!filters.length) {
1696
+ filters.push({
1697
+ name: '所有文件',
1698
+ extensions: ['*']
1699
+ })
1700
+ }
1727
1701
 
1728
1702
  return filters
1729
1703
  }
@@ -2498,6 +2472,7 @@ export default {
2498
2472
  uploadButtonText,
2499
2473
  hasPendingFiles,
2500
2474
  acceptedTypes,
2475
+ allowedExtensionsText,
2501
2476
  showRestrictions,
2502
2477
 
2503
2478
  // 模板引用
@@ -2665,6 +2640,7 @@ export default {
2665
2640
  /* 模拟iframe的body区域 */
2666
2641
  .modal-content {
2667
2642
  flex: 1;
2643
+ min-height: 0;
2668
2644
  overflow: hidden;
2669
2645
  position: relative;
2670
2646
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2684,6 +2660,7 @@ export default {
2684
2660
 
2685
2661
  /* 标题栏 */
2686
2662
  .modal-header {
2663
+ flex-shrink: 0;
2687
2664
  height: 50px !important;
2688
2665
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2689
2666
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2800,12 +2777,16 @@ export default {
2800
2777
 
2801
2778
  .content-grid {
2802
2779
  display: grid;
2803
- grid-template-columns: 350px 1fr;
2780
+ grid-template-columns: 350px minmax(0, 1fr);
2804
2781
  height: 100%;
2782
+ min-height: 0;
2805
2783
  position: relative;
2806
2784
  }
2807
2785
 
2808
2786
  .upload-panel {
2787
+ box-sizing: border-box;
2788
+ min-width: 0;
2789
+ min-height: 0;
2809
2790
  padding: 30px;
2810
2791
  background:
2811
2792
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2814,13 +2795,14 @@ export default {
2814
2795
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2815
2796
  display: flex;
2816
2797
  flex-direction: column;
2817
- justify-content: center;
2798
+ justify-content: flex-start;
2818
2799
  align-items: center;
2819
2800
  text-align: center;
2820
2801
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2821
2802
  cursor: pointer;
2822
2803
  position: relative;
2823
- overflow: hidden;
2804
+ overflow-x: hidden;
2805
+ overflow-y: auto;
2824
2806
  }
2825
2807
 
2826
2808
  .upload-panel::before {
@@ -2882,7 +2864,9 @@ export default {
2882
2864
  border-radius: 0;
2883
2865
  padding: 0;
2884
2866
  width: 100%;
2885
- height: 100%;
2867
+ height: auto;
2868
+ margin-block: auto;
2869
+ flex-shrink: 0;
2886
2870
  display: flex;
2887
2871
  flex-direction: column;
2888
2872
  justify-content: center;
@@ -3167,10 +3151,14 @@ export default {
3167
3151
  }
3168
3152
 
3169
3153
  .format-tags {
3170
- display: flex;
3171
- flex-wrap: wrap;
3172
- 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;
3173
3160
  margin-top: 2px;
3161
+ cursor: help;
3174
3162
  }
3175
3163
 
3176
3164
  .format-tag {
@@ -3191,6 +3179,9 @@ export default {
3191
3179
  }
3192
3180
 
3193
3181
  .files-panel {
3182
+ box-sizing: border-box;
3183
+ min-width: 0;
3184
+ min-height: 0;
3194
3185
  padding: 30px;
3195
3186
  background:
3196
3187
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3734,4 +3725,53 @@ export default {
3734
3725
  grid-template-columns: 280px 1fr;
3735
3726
  }
3736
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
+ }
3737
3777
  </style>