@jr-public/jr-upload-ui 1.1.0 → 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.0",
3
+ "version": "1.1.2",
4
4
  "description": "JR upload modal components for Vue2 and Vue3",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -0,0 +1,50 @@
1
+ // 仅作为脚本 URL 的缓存标识,不要求服务返回相同的 SDK 发布版本。
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(typeof window.JrTransferSDK === 'function'
45
+ && window.JrTransferSDK.prototype
46
+ && typeof window.JrTransferSDK.prototype.exchangeBrowserTicket === 'function'),
47
+ '上传 SDK 缺少浏览器授权能力,请更新上传服务', true)
48
+ await loadScript(`${base}/js/jszip.min.js`,
49
+ () => Boolean(window.JSZip), '文件压缩依赖加载失败')
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"
@@ -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,8 +440,13 @@ export default {
454
440
  },
455
441
 
456
442
  acceptedTypes() {
457
- if (!this.fileRestrictions.allowedExtensions) return '*'
458
- return this.fileRestrictions.allowedExtensions.join(',')
443
+ return this.accept && this.accept.trim()
444
+ ? this.fileRestrictions.allowedExtensions.join(',')
445
+ : ''
446
+ },
447
+
448
+ allowedExtensionsText() {
449
+ return this.fileRestrictions.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、')
459
450
  },
460
451
 
461
452
  showRestrictions() {
@@ -466,6 +457,12 @@ export default {
466
457
  },
467
458
 
468
459
  watch: {
460
+ accept() {
461
+ if (this.sdkInstance) {
462
+ this.loadFileTypeRestrictions().catch(error => this.showError(error.message))
463
+ }
464
+ },
465
+
469
466
  visible(newVal) {
470
467
  if (newVal) {
471
468
  this.initializeComponent().catch(error => this.showError(error.message))
@@ -537,21 +534,35 @@ export default {
537
534
 
538
535
  methods: {
539
536
  /**
540
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
537
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
541
538
  */
542
539
  isAllowedFileExtension(fileExt, allowedExtensions) {
543
540
  const normalizedExt = normalizeFileExtension(fileExt)
544
541
  if (!normalizedExt) return false
545
542
 
546
- if (DEFAULT_UPLOAD_EXTENSIONS.includes(normalizedExt)
547
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
548
- return true
549
- }
550
-
551
- return Array.isArray(allowedExtensions)
552
- && 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'))
553
548
  },
554
549
 
550
+ /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
551
+ async loadFileTypeRestrictions() {
552
+ this.serverAllowedExtensions = []
553
+ if (this.accept && this.accept.trim()) {
554
+ if (!normalizeFileExtensions(this.accept.split(',')).length) {
555
+ throw new Error('未配置有效的允许上传类型')
556
+ }
557
+ return
558
+ }
559
+ const config = await this.sdkInstance.getFileExtensionConfig()
560
+ const extensions = config && Array.isArray(config.whitelist)
561
+ ? normalizeFileExtensions(config.whitelist) : []
562
+ if (!extensions.length) throw new Error('未获取到有效的允许上传类型')
563
+ this.serverAllowedExtensions = extensions
564
+ },
565
+
555
566
  async initializeComponent() {
556
567
  this.isElectronEnv = this.detectElectronEnvironment()
557
568
 
@@ -602,6 +613,8 @@ export default {
602
613
  throw new Error('JrTransferSDK未加载')
603
614
  }
604
615
 
616
+ await this.loadFileTypeRestrictions()
617
+
605
618
  // 如果启用了压缩,加载压缩配置
606
619
  if (this.enableCompression) {
607
620
  await this.loadCompressionConfig()
@@ -623,47 +636,12 @@ export default {
623
636
  },
624
637
 
625
638
  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
- }
639
+ await loadUploadDependencies(this.config.baseUrl)
663
640
  },
664
641
 
665
642
  cleanup() {
666
643
  this.sdkInstance = null
644
+ this.serverAllowedExtensions = []
667
645
  this.compressionConfig.loaded = false
668
646
  if (this.autoCloseTimer) {
669
647
  clearTimeout(this.autoCloseTimer)
@@ -1359,7 +1337,7 @@ export default {
1359
1337
  try {
1360
1338
  // 构建文件过滤器(与原始页面逻辑一致)
1361
1339
  const filters = []
1362
- if (this.fileRestrictions.showFileTypeInfo && this.fileRestrictions.allowedExtensions) {
1340
+ if (this.fileRestrictions.allowedExtensions.length) {
1363
1341
  const extensions = this.fileRestrictions.allowedExtensions.map(ext =>
1364
1342
  ext.startsWith('.') ? ext.slice(1) : ext
1365
1343
  )
@@ -1687,7 +1665,7 @@ export default {
1687
1665
  getElectronFileFilters() {
1688
1666
  const filters = []
1689
1667
 
1690
- if (this.fileRestrictions.allowedExtensions) {
1668
+ if (this.accept && this.accept.trim() && this.fileRestrictions.allowedExtensions.length) {
1691
1669
  const extensions = this.fileRestrictions.allowedExtensions.map(ext => ext.replace('.', ''))
1692
1670
  filters.push({
1693
1671
  name: '支持的文件',
@@ -1695,10 +1673,12 @@ export default {
1695
1673
  })
1696
1674
  }
1697
1675
 
1698
- filters.push({
1699
- name: '所有文件',
1700
- extensions: ['*']
1701
- })
1676
+ if (!filters.length) {
1677
+ filters.push({
1678
+ name: '所有文件',
1679
+ extensions: ['*']
1680
+ })
1681
+ }
1702
1682
 
1703
1683
  return filters
1704
1684
  },
@@ -2552,6 +2532,7 @@ export default {
2552
2532
  /* 模拟iframe的body区域 */
2553
2533
  .modal-content {
2554
2534
  flex: 1;
2535
+ min-height: 0;
2555
2536
  overflow: hidden;
2556
2537
  position: relative;
2557
2538
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2571,6 +2552,7 @@ export default {
2571
2552
 
2572
2553
  /* 标题栏 */
2573
2554
  .modal-header {
2555
+ flex-shrink: 0;
2574
2556
  height: 50px !important;
2575
2557
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2576
2558
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2687,12 +2669,16 @@ export default {
2687
2669
 
2688
2670
  .content-grid {
2689
2671
  display: grid;
2690
- grid-template-columns: 350px 1fr;
2672
+ grid-template-columns: 350px minmax(0, 1fr);
2691
2673
  height: 100%;
2674
+ min-height: 0;
2692
2675
  position: relative;
2693
2676
  }
2694
2677
 
2695
2678
  .upload-panel {
2679
+ box-sizing: border-box;
2680
+ min-width: 0;
2681
+ min-height: 0;
2696
2682
  padding: 30px;
2697
2683
  background:
2698
2684
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2701,13 +2687,14 @@ export default {
2701
2687
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2702
2688
  display: flex;
2703
2689
  flex-direction: column;
2704
- justify-content: center;
2690
+ justify-content: flex-start;
2705
2691
  align-items: center;
2706
2692
  text-align: center;
2707
2693
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2708
2694
  cursor: pointer;
2709
2695
  position: relative;
2710
- overflow: hidden;
2696
+ overflow-x: hidden;
2697
+ overflow-y: auto;
2711
2698
  }
2712
2699
 
2713
2700
  .upload-panel::before {
@@ -2769,7 +2756,9 @@ export default {
2769
2756
  border-radius: 0;
2770
2757
  padding: 0;
2771
2758
  width: 100%;
2772
- height: 100%;
2759
+ height: auto;
2760
+ margin-block: auto;
2761
+ flex-shrink: 0;
2773
2762
  display: flex;
2774
2763
  flex-direction: column;
2775
2764
  justify-content: center;
@@ -3054,10 +3043,14 @@ export default {
3054
3043
  }
3055
3044
 
3056
3045
  .format-tags {
3057
- display: flex;
3058
- flex-wrap: wrap;
3059
- gap: 2px;
3046
+ display: -webkit-box;
3047
+ -webkit-box-orient: vertical;
3048
+ -webkit-line-clamp: 2;
3049
+ line-height: 20px;
3050
+ max-height: 40px;
3051
+ overflow: hidden;
3060
3052
  margin-top: 2px;
3053
+ cursor: help;
3061
3054
  }
3062
3055
 
3063
3056
  .format-tag {
@@ -3078,6 +3071,9 @@ export default {
3078
3071
  }
3079
3072
 
3080
3073
  .files-panel {
3074
+ box-sizing: border-box;
3075
+ min-width: 0;
3076
+ min-height: 0;
3081
3077
  padding: 30px;
3082
3078
  background:
3083
3079
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3621,4 +3617,53 @@ export default {
3621
3617
  grid-template-columns: 280px 1fr;
3622
3618
  }
3623
3619
  }
3620
+
3621
+ @media (max-width: 640px) {
3622
+ .jr-upload-modal-overlay.with-overlay .modal-content {
3623
+ padding: 0;
3624
+ }
3625
+
3626
+ .jr-upload-modal-overlay.with-overlay .main-container {
3627
+ width: 100%;
3628
+ height: 100% !important;
3629
+ border-radius: 0;
3630
+ }
3631
+
3632
+ .content-grid {
3633
+ grid-template-columns: minmax(0, 1fr);
3634
+ grid-template-rows: minmax(0, auto) minmax(160px, 1fr);
3635
+ }
3636
+
3637
+ .upload-panel {
3638
+ padding: 12px;
3639
+ border-right: 0;
3640
+ border-bottom: 1px solid rgba(200, 200, 200, 0.8);
3641
+ }
3642
+
3643
+ .upload-area {
3644
+ display: grid;
3645
+ grid-template-columns: 104px minmax(0, 1fr);
3646
+ gap: 12px;
3647
+ }
3648
+
3649
+ .upload-visual {
3650
+ display: none;
3651
+ }
3652
+
3653
+ .upload-button {
3654
+ width: 100%;
3655
+ padding: 10px 12px;
3656
+ overflow-wrap: anywhere;
3657
+ margin: 0;
3658
+ }
3659
+
3660
+ .upload-restrictions {
3661
+ min-width: 0;
3662
+ margin: 0;
3663
+ }
3664
+
3665
+ .files-panel {
3666
+ padding: 12px;
3667
+ }
3668
+ }
3624
3669
  </style>
@@ -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"
@@ -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,26 @@ export default {
476
462
  })
477
463
 
478
464
  const acceptedTypes = computed(() => {
479
- if (!fileRestrictions.value.allowedExtensions) return '*'
480
- return fileRestrictions.value.allowedExtensions.join(',')
465
+ return props.accept && props.accept.trim()
466
+ ? fileRestrictions.value.allowedExtensions.join(',')
467
+ : ''
481
468
  })
482
469
 
470
+ const allowedExtensionsText = computed(() =>
471
+ fileRestrictions.value.allowedExtensions.map(ext => ext.slice(1).toUpperCase()).join('、'))
472
+
483
473
  const showRestrictions = computed(() => {
484
474
  // 总是显示限制说明区域,但具体显示内容由各个参数控制
485
475
  // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
486
476
  return true
487
477
  })
488
478
 
479
+ watch(() => props.accept, () => {
480
+ if (sdkInstance.value) {
481
+ loadFileTypeRestrictions().catch(error => showError(error.message))
482
+ }
483
+ })
484
+
489
485
  // watch监听器
490
486
  watch(() => props.visible, async (newVal) => {
491
487
  if (newVal) {
@@ -560,21 +556,35 @@ export default {
560
556
 
561
557
  // 方法定义
562
558
  /**
563
- * 判断文件后缀是否允许上传,投标成果类后缀兼容包含 gef 或 sxt 的扩展名。
559
+ * 展示、选择及校验共用生效列表,内置业务规则不得扩大调用方范围。
564
560
  */
565
561
  const isAllowedFileExtension = (fileExt, allowedExtensions) => {
566
562
  const normalizedExt = normalizeFileExtension(fileExt)
567
563
  if (!normalizedExt) return false
568
564
 
569
- if (DEFAULT_UPLOAD_EXTENSIONS.includes(normalizedExt)
570
- || normalizedExt.includes('gef') || normalizedExt.includes('sxt')) {
571
- return true
572
- }
573
-
574
- return Array.isArray(allowedExtensions)
575
- && 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'))
576
570
  }
577
571
 
572
+ /** 未指定 accept 时,从已鉴权的上传服务读取允许类型。 */
573
+ const loadFileTypeRestrictions = async () => {
574
+ serverAllowedExtensions.value = []
575
+ if (props.accept && props.accept.trim()) {
576
+ if (!normalizeFileExtensions(props.accept.split(',')).length) {
577
+ throw new Error('未配置有效的允许上传类型')
578
+ }
579
+ return
580
+ }
581
+ const config = await sdkInstance.value.getFileExtensionConfig()
582
+ const extensions = config && Array.isArray(config.whitelist)
583
+ ? normalizeFileExtensions(config.whitelist) : []
584
+ if (!extensions.length) throw new Error('未获取到有效的允许上传类型')
585
+ serverAllowedExtensions.value = extensions
586
+ }
587
+
578
588
  const initializeComponent = async () => {
579
589
  isElectronEnv.value = detectElectronEnvironment()
580
590
 
@@ -625,6 +635,8 @@ export default {
625
635
  throw new Error('JrTransferSDK未加载')
626
636
  }
627
637
 
638
+ await loadFileTypeRestrictions()
639
+
628
640
  // 如果启用了压缩,加载压缩配置
629
641
  if (props.enableCompression) {
630
642
  await loadCompressionConfig()
@@ -646,47 +658,12 @@ export default {
646
658
  }
647
659
 
648
660
  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
- }
661
+ await loadUploadDependencies(props.config.baseUrl)
686
662
  }
687
663
 
688
664
  const cleanup = () => {
689
665
  sdkInstance.value = null
666
+ serverAllowedExtensions.value = []
690
667
  compressionConfig.loaded = false
691
668
  if (autoCloseTimer.value) {
692
669
  clearTimeout(autoCloseTimer.value)
@@ -1384,7 +1361,7 @@ export default {
1384
1361
  try {
1385
1362
  // 构建文件过滤器(与原始页面逻辑一致)
1386
1363
  const filters = []
1387
- if (fileRestrictions.value.showFileTypeInfo && fileRestrictions.value.allowedExtensions) {
1364
+ if (fileRestrictions.value.allowedExtensions.length) {
1388
1365
  const extensions = fileRestrictions.value.allowedExtensions.map(ext =>
1389
1366
  ext.startsWith('.') ? ext.slice(1) : ext
1390
1367
  )
@@ -1712,7 +1689,7 @@ export default {
1712
1689
  const getElectronFileFilters = () => {
1713
1690
  const filters = []
1714
1691
 
1715
- if (fileRestrictions.value.allowedExtensions) {
1692
+ if (props.accept && props.accept.trim() && fileRestrictions.value.allowedExtensions.length) {
1716
1693
  const extensions = fileRestrictions.value.allowedExtensions.map(ext => ext.replace('.', ''))
1717
1694
  filters.push({
1718
1695
  name: '支持的文件',
@@ -1720,10 +1697,12 @@ export default {
1720
1697
  })
1721
1698
  }
1722
1699
 
1723
- filters.push({
1724
- name: '所有文件',
1725
- extensions: ['*']
1726
- })
1700
+ if (!filters.length) {
1701
+ filters.push({
1702
+ name: '所有文件',
1703
+ extensions: ['*']
1704
+ })
1705
+ }
1727
1706
 
1728
1707
  return filters
1729
1708
  }
@@ -2498,6 +2477,7 @@ export default {
2498
2477
  uploadButtonText,
2499
2478
  hasPendingFiles,
2500
2479
  acceptedTypes,
2480
+ allowedExtensionsText,
2501
2481
  showRestrictions,
2502
2482
 
2503
2483
  // 模板引用
@@ -2665,6 +2645,7 @@ export default {
2665
2645
  /* 模拟iframe的body区域 */
2666
2646
  .modal-content {
2667
2647
  flex: 1;
2648
+ min-height: 0;
2668
2649
  overflow: hidden;
2669
2650
  position: relative;
2670
2651
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
@@ -2684,6 +2665,7 @@ export default {
2684
2665
 
2685
2666
  /* 标题栏 */
2686
2667
  .modal-header {
2668
+ flex-shrink: 0;
2687
2669
  height: 50px !important;
2688
2670
  background: linear-gradient(135deg, #0c5ee3 0%, rgba(59, 130, 246, 0.9) 100%) !important;
2689
2671
  border-bottom: 1px solid rgba(12, 94, 227, 0.25) !important;
@@ -2800,12 +2782,16 @@ export default {
2800
2782
 
2801
2783
  .content-grid {
2802
2784
  display: grid;
2803
- grid-template-columns: 350px 1fr;
2785
+ grid-template-columns: 350px minmax(0, 1fr);
2804
2786
  height: 100%;
2787
+ min-height: 0;
2805
2788
  position: relative;
2806
2789
  }
2807
2790
 
2808
2791
  .upload-panel {
2792
+ box-sizing: border-box;
2793
+ min-width: 0;
2794
+ min-height: 0;
2809
2795
  padding: 30px;
2810
2796
  background:
2811
2797
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -2814,13 +2800,14 @@ export default {
2814
2800
  border-right: 1px solid rgba(200, 200, 200, 0.8);
2815
2801
  display: flex;
2816
2802
  flex-direction: column;
2817
- justify-content: center;
2803
+ justify-content: flex-start;
2818
2804
  align-items: center;
2819
2805
  text-align: center;
2820
2806
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2821
2807
  cursor: pointer;
2822
2808
  position: relative;
2823
- overflow: hidden;
2809
+ overflow-x: hidden;
2810
+ overflow-y: auto;
2824
2811
  }
2825
2812
 
2826
2813
  .upload-panel::before {
@@ -2882,7 +2869,9 @@ export default {
2882
2869
  border-radius: 0;
2883
2870
  padding: 0;
2884
2871
  width: 100%;
2885
- height: 100%;
2872
+ height: auto;
2873
+ margin-block: auto;
2874
+ flex-shrink: 0;
2886
2875
  display: flex;
2887
2876
  flex-direction: column;
2888
2877
  justify-content: center;
@@ -3167,10 +3156,14 @@ export default {
3167
3156
  }
3168
3157
 
3169
3158
  .format-tags {
3170
- display: flex;
3171
- flex-wrap: wrap;
3172
- gap: 2px;
3159
+ display: -webkit-box;
3160
+ -webkit-box-orient: vertical;
3161
+ -webkit-line-clamp: 2;
3162
+ line-height: 20px;
3163
+ max-height: 40px;
3164
+ overflow: hidden;
3173
3165
  margin-top: 2px;
3166
+ cursor: help;
3174
3167
  }
3175
3168
 
3176
3169
  .format-tag {
@@ -3191,6 +3184,9 @@ export default {
3191
3184
  }
3192
3185
 
3193
3186
  .files-panel {
3187
+ box-sizing: border-box;
3188
+ min-width: 0;
3189
+ min-height: 0;
3194
3190
  padding: 30px;
3195
3191
  background:
3196
3192
  linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
@@ -3734,4 +3730,53 @@ export default {
3734
3730
  grid-template-columns: 280px 1fr;
3735
3731
  }
3736
3732
  }
3733
+
3734
+ @media (max-width: 640px) {
3735
+ .jr-upload-modal-overlay.with-overlay .modal-content {
3736
+ padding: 0;
3737
+ }
3738
+
3739
+ .jr-upload-modal-overlay.with-overlay .main-container {
3740
+ width: 100%;
3741
+ height: 100% !important;
3742
+ border-radius: 0;
3743
+ }
3744
+
3745
+ .content-grid {
3746
+ grid-template-columns: minmax(0, 1fr);
3747
+ grid-template-rows: minmax(0, auto) minmax(160px, 1fr);
3748
+ }
3749
+
3750
+ .upload-panel {
3751
+ padding: 12px;
3752
+ border-right: 0;
3753
+ border-bottom: 1px solid rgba(200, 200, 200, 0.8);
3754
+ }
3755
+
3756
+ .upload-area {
3757
+ display: grid;
3758
+ grid-template-columns: 104px minmax(0, 1fr);
3759
+ gap: 12px;
3760
+ }
3761
+
3762
+ .upload-visual {
3763
+ display: none;
3764
+ }
3765
+
3766
+ .upload-button {
3767
+ width: 100%;
3768
+ padding: 10px 12px;
3769
+ overflow-wrap: anywhere;
3770
+ margin: 0;
3771
+ }
3772
+
3773
+ .upload-restrictions {
3774
+ min-width: 0;
3775
+ margin: 0;
3776
+ }
3777
+
3778
+ .files-panel {
3779
+ padding: 12px;
3780
+ }
3781
+ }
3737
3782
  </style>