@jr-public/jr-upload-ui 1.0.0

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.
@@ -0,0 +1,3422 @@
1
+ <template>
2
+ <div class="jr-upload-modal-wrapper">
3
+ <!-- 主弹框 -->
4
+ <div
5
+ v-if="visible"
6
+ class="jr-upload-modal-overlay"
7
+ @click="handleOverlayClick"
8
+ >
9
+ <!-- 弹框容器 -->
10
+ <div
11
+ class="modal-container"
12
+ :class="{
13
+ 'minimized-to-corner': isMinimized,
14
+ 'minimizing': isMinimizing,
15
+ 'restoring': isRestoring
16
+ }"
17
+ @click.stop
18
+ >
19
+ <!-- 标题栏 -->
20
+ <div class="modal-header" @mousedown="handleDragStart">
21
+ <div class="modal-title">
22
+ <span>{{ title }}</span>
23
+ </div>
24
+ <div class="window-controls">
25
+ <button class="control-btn minimize-btn" @click="minimizeModal" title="最小化"></button>
26
+ <button class="control-btn close-btn" @click="closeModal" title="关闭"></button>
27
+ </div>
28
+ </div>
29
+
30
+ <!-- 主内容区域 -->
31
+ <div class="modal-content" :style="{ backgroundImage: 'url(' + config.baseUrl + '/images/bg.jpg)' }">
32
+ <div class="main-container">
33
+ <div class="content-grid">
34
+ <!-- 左侧上传区域 -->
35
+ <div
36
+ class="upload-panel"
37
+ :class="{ 'active': isDragActive, 'disabled': isUploadDisabled }"
38
+ @click="handlePanelClick"
39
+ @dragover="handleDragOver"
40
+ @dragleave="handleDragLeave"
41
+ @drop="handleDrop"
42
+ >
43
+ <div class="upload-area">
44
+ <div class="upload-visual" :class="{ 'success': uploadSuccess }">
45
+ <div class="folder-icon">
46
+ <img :src="config.baseUrl + '/images/file-icon.png'" alt="文件夹">
47
+ </div>
48
+ <div class="file-icon" v-show="isDragActive">
49
+ <img :src="config.baseUrl + '/images/fileicon.svg'" alt="文件">
50
+ </div>
51
+ <div class="drag-indicator" v-show="isDragActive">
52
+ <div class="drag-arrow"></div>
53
+ <div class="drag-arrow"></div>
54
+ <div class="drag-arrow"></div>
55
+ </div>
56
+ </div>
57
+
58
+ <button
59
+ class="upload-button"
60
+ @click="selectFiles"
61
+ :disabled="isUploading || isUploadDisabled"
62
+ ref="uploadButton"
63
+ >
64
+ {{ uploadButtonText }}
65
+ </button>
66
+
67
+ <!-- 隐藏的文件输入框 -->
68
+ <input
69
+ ref="fileInput"
70
+ type="file"
71
+ :multiple="fileRestrictions.multiple"
72
+ :accept="acceptedTypes"
73
+ @change="handleFileSelect"
74
+ style="display: none;"
75
+ :disabled="isUploadDisabled"
76
+ >
77
+
78
+ <!-- 文件限制说明 -->
79
+ <div class="upload-restrictions" v-if="showRestrictions">
80
+ <div
81
+ class="restrictions-title"
82
+ :class="{
83
+ 'error': validationMessageType === 'error',
84
+ 'success': validationMessageType === 'success',
85
+ 'warning': validationMessageType === 'warning',
86
+ 'validating': waitingForValidation
87
+ }"
88
+ >
89
+ {{ waitingForValidation ? '正在验证文件...' : (validationMessage || '文件上传要求') }}
90
+ </div>
91
+ <ul class="restrictions-list" v-if="!validationMessage && !waitingForValidation">
92
+ <li v-if="fileRestrictions.showFileTypeInfo && fileRestrictions.allowedExtensions" style="display: list-item;">
93
+ 支持格式:
94
+ <div class="format-tags">
95
+ <span
96
+ v-for="ext in fileRestrictions.allowedExtensions"
97
+ :key="ext"
98
+ class="format-tag"
99
+ >
100
+ {{ ext.replace('.', '').toUpperCase() }}
101
+ </span>
102
+ </div>
103
+ </li>
104
+ <li v-if="fileRestrictions.showFileCountInfo && fileRestrictions.maxFileCount && fileRestrictions.maxFileCount > 0" style="display: list-item;">
105
+ 最多上传:<span class="count-highlight">{{ fileRestrictions.maxFileCount }}个文件</span>
106
+ </li>
107
+ <li v-if="fileRestrictions.showFileSizeInfo && fileRestrictions.maxSizeBytes && fileRestrictions.maxSizeBytes > 0" style="display: list-item;">
108
+ 单个文件大小:不超过 <span class="size-highlight">{{ formatFileSize(fileRestrictions.maxSizeBytes) }}</span>
109
+ </li>
110
+ <li style="display: list-item;">建议文件名使用中英文、数字和下划线</li>
111
+ </ul>
112
+
113
+ <!-- Electron环境指示器 -->
114
+ <!-- <div v-if="isElectronEnv" class="electron-indicator">-->
115
+ <!-- 🖥️ Electron环境 - 支持本地路径显示-->
116
+ <!-- </div>-->
117
+ </div>
118
+ </div>
119
+ </div>
120
+
121
+ <!-- 右侧文件面板 -->
122
+ <div class="files-panel">
123
+ <div class="panel-header">
124
+ <h2 class="panel-title">文件列表</h2>
125
+ </div>
126
+
127
+ <div class="files-content">
128
+ <!-- 空状态提示 -->
129
+ <div v-if="filesToUpload.length === 0" class="empty-state">
130
+ <div class="empty-state-content">
131
+ <div class="empty-state-icon">📁</div>
132
+ <div class="empty-state-text">请点击左侧按钮添加文件</div>
133
+ </div>
134
+ </div>
135
+
136
+ <!-- 文件列表 -->
137
+ <div v-if="filesToUpload.length > 0" class="file-grid">
138
+ <div
139
+ v-for="(file, index) in filesToUpload"
140
+ :key="file.id"
141
+ class="file-item"
142
+ >
143
+ <div class="file-card">
144
+ <div class="file-row">
145
+ <div class="file-type">
146
+ <img :src="config.baseUrl + '/images/fileicon.svg'" alt="文件">
147
+ </div>
148
+ <div class="file-details">
149
+ <div
150
+ class="file-title"
151
+ :title="file.name"
152
+ style="cursor: pointer;"
153
+ >
154
+ {{ truncateFileName(file.name) }}
155
+ </div>
156
+ <div class="file-meta">
157
+ <span v-if="file.compressed" class="compression-indicator">已压缩</span>
158
+ <div v-if="isElectronEnv && file.localPath" class="file-local-path">
159
+ <span class="path-label">本地路径:</span>
160
+ <span class="path-value" :title="file.localPath">{{ truncateFilePath(file.localPath) }}</span>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ <div class="file-side-panel">
165
+ <div class="file-actions">
166
+ <button
167
+ v-if="file.status !== 'uploading' && file.status !== 'success'"
168
+ @click="removeFile(file)"
169
+ class="file-action remove-btn"
170
+ title="移除"
171
+ >
172
+ 移除
173
+ </button>
174
+ </div>
175
+ <div class="file-size">{{ formatFileSize(file.size) }}</div>
176
+ </div>
177
+ </div>
178
+
179
+ <!-- 进度条 -->
180
+ <div v-if="file.status === 'uploading'" class="file-progress">
181
+ <div class="progress-track">
182
+ <div class="progress-bar" :style="{ width: file.progress + '%' }"></div>
183
+ </div>
184
+ <div class="progress-text">
185
+ <span class="progress-left">
186
+ <span class="progress-status">{{ file.statusText || '上传中...' }}</span>
187
+ <span class="progress-percent">{{ Math.floor(file.progress) }}%</span>
188
+ </span>
189
+ <span class="progress-time" v-if="file.remainingTime">{{ file.remainingTime }}</span>
190
+ </div>
191
+ </div>
192
+
193
+ <!-- 完成状态 -->
194
+ <div v-if="file.status === 'success'" class="completion-info">
195
+ <span class="completion-text">
196
+ <img :src="config.baseUrl + '/images/answer-icon.png'" alt="成功" class="status-icon">
197
+ 上传成功
198
+ </span>
199
+ </div>
200
+
201
+ <!-- 错误状态 -->
202
+ <div v-if="file.status === 'error'" class="error-info" @click="retryUpload(file)">
203
+ <div class="error-text">
204
+ ⚠️ 上传失败: {{ file.errorMessage }}
205
+ <button class="retry-button">点击重试</button>
206
+ </div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+ </div>
211
+
212
+ </div>
213
+
214
+ <!-- 上传操作区 - 固定在底部 -->
215
+ <div v-if="filesToUpload.length > 0" class="upload-action-area">
216
+ <button
217
+ class="start-upload-button"
218
+ @click="startUpload"
219
+ :disabled="isUploading || !hasPendingFiles"
220
+ >
221
+ <span v-if="!isUploading">开始上传</span>
222
+ <span v-else>上传中... {{ uploadProgress.completed }}/{{ uploadProgress.total }}</span>
223
+ </button>
224
+ </div>
225
+ </div>
226
+ </div>
227
+ </div>
228
+ <!-- 结束 modal-content -->
229
+ </div>
230
+ <!-- 结束 modal-container -->
231
+ </div>
232
+ <!-- 结束 jr-upload-modal-overlay -->
233
+
234
+ <!-- 错误弹框 -->
235
+ <div v-if="errorMessage" class="error-modal" @click="errorMessage = ''">
236
+ <div class="error-content" @click.stop>
237
+ <div class="error-header">
238
+ <h3>⚠️ 上传错误</h3>
239
+ <button @click="errorMessage = ''" class="close-error">×</button>
240
+ </div>
241
+ <div class="error-body">{{ errorMessage }}</div>
242
+ </div>
243
+ <!-- 结束 error-content -->
244
+ </div>
245
+ <!-- 结束 error-modal -->
246
+ </div>
247
+ <!-- 结束 jr-upload-modal-wrapper -->
248
+ </div>
249
+ </template>
250
+
251
+ <script>
252
+ import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, defineEmits, defineProps, nextTick } from 'vue'
253
+
254
+ export default {
255
+ name: 'JrUploadModalVue3',
256
+
257
+ props: {
258
+ // 基础配置
259
+ visible: {
260
+ type: Boolean,
261
+ default: false
262
+ },
263
+ title: {
264
+ type: String,
265
+ default: '文件上传'
266
+ },
267
+ config: {
268
+ type: Object,
269
+ default: () => ({
270
+ token: '',
271
+ uploadPath: '',
272
+ baseUrl: '' // JS依赖文件的基础路径
273
+ })
274
+ },
275
+
276
+ // 回调函数(与jr-simple-sdk.js保持一致)
277
+ onSuccess: { type: Function, default: null },
278
+ onError: { type: Function, default: null },
279
+ onProgress: { type: Function, default: null },
280
+ onReady: { type: Function, default: null },
281
+ onSelect: { type: Function, default: null },
282
+ onValidate: { type: Function, default: null },
283
+ onPostProcess: { type: Function, default: null },
284
+ onClose: { type: Function, default: null },
285
+
286
+ // 文件限制
287
+ accept: { type: String, default: '' },
288
+ maxSize: { type: Number, default: 50 * 1024 }, // KB
289
+ maxCount: { type: Number, default: 10 },
290
+ multiple: { type: Boolean, default: true },
291
+
292
+ // 显示控制
293
+ showFileTypeInfo: { type: Boolean, default: true },
294
+ showFileSizeInfo: { type: Boolean, default: true },
295
+ showFileCountInfo: { type: Boolean, default: true },
296
+
297
+ // 功能开关
298
+ addUuidPrefix: { type: Boolean, default: false },
299
+ enableCompression: { type: Boolean, default: false },
300
+ useServerUpload: { type: Boolean, default: false },
301
+ enableValidation: { type: Boolean, default: false },
302
+ enablePostProcess: { type: Boolean, default: false },
303
+ disabled: { type: Boolean, default: false },
304
+
305
+ // MD5去重功能
306
+ enableMd5Deduplication: { type: Boolean, default: false },
307
+
308
+ // 上传路径
309
+ uploadPath: { type: String, default: '' },
310
+
311
+ // bucket名称(可选)
312
+ bucketName: { type: String, default: '' }
313
+ },
314
+
315
+ emits: [
316
+ 'upload-success',
317
+ 'upload-error',
318
+ 'upload-progress',
319
+ 'upload-start',
320
+ 'upload-ready',
321
+ 'file-select',
322
+ 'file-validate',
323
+ 'file-post-process',
324
+ 'close'
325
+ ],
326
+
327
+ setup(props, { emit }) {
328
+ // 响应式数据
329
+ const filesToUpload = ref([])
330
+ const isUploading = ref(false)
331
+ const isDragActive = ref(false)
332
+ const errorMessage = ref('')
333
+ const validationMessage = ref('')
334
+ const validationMessageType = ref('info')
335
+ const uploadProgress = reactive({ total: 0, completed: 0, failed: 0 })
336
+ const uploadSuccess = ref(false)
337
+
338
+ // 弹框控制
339
+ const isMinimized = ref(false)
340
+ const isMinimizing = ref(false)
341
+ const isRestoring = ref(false)
342
+
343
+ // 拖拽相关
344
+ const dragStartX = ref(0)
345
+ const dragStartY = ref(0)
346
+ const isDragging = ref(false)
347
+
348
+ // SDK实例和配置
349
+ const sdkInstance = ref(null)
350
+ const isElectronEnv = ref(false)
351
+ const electronFileMap = ref(new Map())
352
+ const waitingForValidation = ref(false)
353
+ const validationErrorVisible = ref(false)
354
+
355
+ // 临时文件数据
356
+ const tempFiles = ref([])
357
+ const tempFileInfos = ref([])
358
+ const tempLocalPaths = ref([])
359
+
360
+ // 压缩配置
361
+ const compressionConfig = reactive({
362
+ enabled: false,
363
+ level: 'balanced', // fast, balanced, best
364
+ mode: 'smart', // frontend, backend, smart
365
+ threshold: 10 * 1024 * 1024, // 10MB
366
+ compressionRatio: 6,
367
+ compressedFileSuffix: '_compressed',
368
+ loaded: false
369
+ })
370
+
371
+ // 动态样式
372
+ const _dynamicStyle = ref(null)
373
+
374
+ // 模板引用
375
+ const fileInput = ref(null)
376
+ const uploadButton = ref(null)
377
+
378
+ // 计算属性
379
+ const fileRestrictions = computed(() => {
380
+ return {
381
+ allowedExtensions: props.accept ? props.accept.split(',').map(ext => {
382
+ const trimmed = ext.trim()
383
+ return trimmed.startsWith('.') ? trimmed : '.' + trimmed
384
+ }) : null,
385
+ maxSizeBytes: props.maxSize && props.maxSize > 0 ? props.maxSize * 1024 : null,
386
+ maxFileCount: props.maxCount && props.maxCount > 0 ? props.maxCount : null,
387
+ multiple: props.multiple,
388
+ showFileTypeInfo: props.showFileTypeInfo,
389
+ showFileSizeInfo: props.showFileSizeInfo,
390
+ showFileCountInfo: props.showFileCountInfo
391
+ }
392
+ })
393
+
394
+ const isUploadDisabled = computed(() => {
395
+ // 参考原始 stsUpload.html 的逻辑:只在真正达到文件数量限制时才禁用
396
+ // 验证期间不禁用选择文件按钮,与原始页面行为保持一致
397
+ if (props.disabled) {
398
+ return true
399
+ }
400
+
401
+ // 检查是否达到文件数量限制(与原始页面逻辑完全一致)
402
+ const isAtLimit = fileRestrictions.value.showFileCountInfo &&
403
+ fileRestrictions.value.maxFileCount > 0 &&
404
+ filesToUpload.value.length >= fileRestrictions.value.maxFileCount
405
+
406
+ return isAtLimit
407
+ })
408
+
409
+ const uploadButtonText = computed(() => {
410
+ if (isUploading.value) return '上传中...'
411
+ if (isUploadDisabled.value && fileRestrictions.value.maxFileCount && fileRestrictions.value.maxFileCount > 0) {
412
+ return `已达到限制 (${fileRestrictions.value.maxFileCount}个文件)`
413
+ }
414
+ return '选择文件'
415
+ })
416
+
417
+ const hasPendingFiles = computed(() => {
418
+ return filesToUpload.value.some(file => file.status === 'pending')
419
+ })
420
+
421
+ const acceptedTypes = computed(() => {
422
+ if (!fileRestrictions.value.allowedExtensions) return '*'
423
+ return fileRestrictions.value.allowedExtensions.join(',')
424
+ })
425
+
426
+ const showRestrictions = computed(() => {
427
+ // 总是显示限制说明区域,但具体显示内容由各个参数控制
428
+ // 至少显示"建议文件名使用中英文、数字和下划线"这个固定提示
429
+ return true
430
+ })
431
+
432
+ // watch监听器
433
+ watch(() => props.visible, async (newVal) => {
434
+ if (newVal) {
435
+ await initializeComponent()
436
+ // 调试信息:打印当前组件参数
437
+ console.log('🔧 JrUploadModal 组件参数:', {
438
+ accept: props.accept,
439
+ maxSize: props.maxSize,
440
+ maxCount: props.maxCount,
441
+ multiple: props.multiple,
442
+ showFileTypeInfo: props.showFileTypeInfo,
443
+ showFileSizeInfo: props.showFileSizeInfo,
444
+ showFileCountInfo: props.showFileCountInfo,
445
+ addUuidPrefix: props.addUuidPrefix,
446
+ enableCompression: props.enableCompression,
447
+ useServerUpload: props.useServerUpload,
448
+ enableValidation: props.enableValidation,
449
+ enablePostProcess: props.enablePostProcess,
450
+ disabled: props.disabled,
451
+ uploadPath: props.uploadPath,
452
+ enableMd5Deduplication: props.enableMd5Deduplication,
453
+ bucketName: props.bucketName,
454
+ bucketNameType: typeof props.bucketName,
455
+ bucketNameTrimmed: props.bucketName && props.bucketName.trim() !== '' ? props.bucketName.trim() : '【空值】'
456
+ })
457
+
458
+ // 如果没有提供bucketName,给出警告
459
+ if (!props.bucketName || props.bucketName.trim() === '') {
460
+ console.warn('⚠️ 注意:bucketName为空,将使用默认配置。如需指定特定bucket,请传递bucketName属性')
461
+ }
462
+ console.log('📋 计算属性 fileRestrictions:', fileRestrictions.value)
463
+ } else {
464
+ // 重要:当外部直接把 visible 设为 false(例如上传成功后自动关闭弹窗)时,
465
+ // 组件不会走 closeModal(),因此需要在这里同步清空上次的上传状态。
466
+ resetState()
467
+ cleanup()
468
+ }
469
+ })
470
+
471
+ // 监听参数变化,便于调试
472
+ watch(fileRestrictions, (newVal) => {
473
+ console.log('📋 fileRestrictions 更新:', newVal)
474
+ }, { deep: true, immediate: true })
475
+
476
+ // 生命周期钩子
477
+ onMounted(async () => {
478
+ if (props.visible) {
479
+ await initializeComponent()
480
+ }
481
+
482
+ // 动态设置CSS背景图片
483
+ setDynamicBackgroundImages()
484
+ })
485
+
486
+ onBeforeUnmount(() => {
487
+ cleanup()
488
+ })
489
+
490
+ // 方法定义
491
+ const initializeComponent = async () => {
492
+ isElectronEnv.value = detectElectronEnvironment()
493
+
494
+ // 发送环境检测事件
495
+ emit('environment-detected', {
496
+ isElectron: isElectronEnv.value,
497
+ userAgent: navigator.userAgent,
498
+ timestamp: Date.now()
499
+ })
500
+
501
+ // 初始化SDK
502
+ await initializeSDK()
503
+
504
+ // 发送组件就绪事件
505
+ emit('ready', {
506
+ component: 'vue3',
507
+ isElectron: isElectronEnv.value,
508
+ sdkReady: !!sdkInstance.value,
509
+ timestamp: Date.now()
510
+ })
511
+
512
+ // 调用onReady回调
513
+ if (props.onReady) {
514
+ props.onReady({
515
+ component: 'vue3',
516
+ isElectron: isElectronEnv.value,
517
+ sdkReady: !!sdkInstance.value,
518
+ timestamp: Date.now()
519
+ })
520
+ }
521
+
522
+ console.log('🚀 JR上传组件已就绪')
523
+ }
524
+
525
+ const initializeSDK = async () => {
526
+ try {
527
+ // 动态加载必要的依赖
528
+ await loadExternalDependencies()
529
+
530
+ // 初始化Transfer SDK
531
+ if (window.JrTransferSDK) {
532
+ sdkInstance.value = new window.JrTransferSDK({
533
+ baseUrl: props.config.baseUrl,
534
+ apiToken: props.config.token,
535
+ })
536
+
537
+ emit('sdk-initialized', {
538
+ success: true,
539
+ timestamp: Date.now()
540
+ })
541
+
542
+ console.log('✅ Transfer SDK初始化成功')
543
+ } else {
544
+ throw new Error('JrTransferSDK未加载')
545
+ }
546
+
547
+ // 如果启用了压缩,加载压缩配置
548
+ if (props.enableCompression) {
549
+ await loadCompressionConfig()
550
+ }
551
+ } catch (error) {
552
+ console.error('❌ SDK初始化失败:', error)
553
+ emit('sdk-initialized', {
554
+ success: false,
555
+ error: error.message,
556
+ timestamp: Date.now()
557
+ })
558
+ }
559
+ }
560
+
561
+ const loadExternalDependencies = async () => {
562
+ const baseUrl = props.config.baseUrl
563
+ const dependencies = [
564
+ `${baseUrl}/js/aliyun-oss-sdk-6.18.0.min.js`,
565
+ `${baseUrl}/js/jr-transfer-sdk.js`,
566
+ `${baseUrl}/js/jszip.min.js`
567
+ ]
568
+
569
+ // 检查是否已加载
570
+ if (window.JrTransferSDK && window.OSS && window.JSZip) {
571
+ return Promise.resolve()
572
+ }
573
+
574
+ // 动态加载脚本
575
+ const loadScript = (src) => {
576
+ return new Promise((resolve, reject) => {
577
+ if (document.querySelector(`script[src="${src}"]`)) {
578
+ resolve()
579
+ return
580
+ }
581
+
582
+ const script = document.createElement('script')
583
+ script.src = src
584
+ script.onload = resolve
585
+ script.onerror = reject
586
+ document.head.appendChild(script)
587
+ })
588
+ }
589
+
590
+ try {
591
+ for (const dep of dependencies) {
592
+ await loadScript(dep)
593
+ }
594
+ console.log('✅ 外部依赖加载完成')
595
+ } catch (error) {
596
+ console.error('❌ 外部依赖加载失败:', error)
597
+ throw error
598
+ }
599
+ }
600
+
601
+ const cleanup = () => {
602
+ // 清理资源
603
+ if (_dynamicStyle.value) {
604
+ _dynamicStyle.value.remove()
605
+ _dynamicStyle.value = null
606
+ }
607
+ }
608
+
609
+ const resetState = () => {
610
+ filesToUpload.value = []
611
+ uploadProgress.total = 0
612
+ uploadProgress.completed = 0
613
+ uploadProgress.failed = 0
614
+ isUploading.value = false
615
+ isDragActive.value = false
616
+ uploadSuccess.value = false
617
+ errorMessage.value = ''
618
+ validationMessage.value = ''
619
+ validationMessageType.value = 'info'
620
+ waitingForValidation.value = false
621
+ electronFileMap.value = new Map()
622
+ tempFiles.value = []
623
+ tempFileInfos.value = []
624
+ tempLocalPaths.value = []
625
+ }
626
+
627
+ // 动态设置CSS背景图片
628
+ const setDynamicBackgroundImages = () => {
629
+ if (!props.config.baseUrl) return
630
+
631
+ // 设置提示图标背景
632
+ const style = document.createElement('style')
633
+ style.textContent = `
634
+ .jr-upload-modal-wrapper .restrictions-title::before {
635
+ background-image: url('${props.config.baseUrl}/images/tipsicon.svg') !important;
636
+ }
637
+ `
638
+ document.head.appendChild(style)
639
+
640
+ // 保存引用以便清理
641
+ _dynamicStyle.value = style
642
+ }
643
+
644
+ // 加载压缩配置
645
+ const loadCompressionConfig = async () => {
646
+ if (compressionConfig.loaded) {
647
+ return compressionConfig
648
+ }
649
+
650
+ try {
651
+ const baseUrl = props.config.baseUrl
652
+ let apiUrl = `${baseUrl}/api/sts/compression-config?token=${encodeURIComponent(props.config.token)}`
653
+
654
+ // 如果提供了bucketName,添加到请求参数中
655
+ if (props.bucketName && props.bucketName.trim() !== '') {
656
+ apiUrl += `&bucketName=${encodeURIComponent(props.bucketName.trim())}`
657
+ }
658
+
659
+ console.log('📡 请求压缩配置:', apiUrl)
660
+
661
+ const response = await fetch(apiUrl)
662
+
663
+ if (!response.ok) {
664
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
665
+ }
666
+
667
+ const result = await response.json()
668
+
669
+ if (!result.success) {
670
+ throw new Error(result.message || '获取压缩配置失败')
671
+ }
672
+
673
+ const config = result.config
674
+ compressionConfig.level = config.level || 'balanced'
675
+ compressionConfig.mode = config.mode || 'smart'
676
+ compressionConfig.threshold = config.threshold || 10 * 1024 * 1024
677
+ compressionConfig.compressionRatio = config.compressionRatio || 6
678
+ compressionConfig.compressedFileSuffix = config.compressedFileSuffix || '_compressed'
679
+ compressionConfig.enabled = props.enableCompression
680
+ compressionConfig.loaded = true
681
+
682
+ console.log('✅ 压缩配置加载成功:', compressionConfig)
683
+ return compressionConfig
684
+
685
+ } catch (error) {
686
+ console.error('❌ 获取压缩配置失败,使用默认配置:', error)
687
+ // 使用默认配置
688
+ compressionConfig.enabled = props.enableCompression
689
+ compressionConfig.loaded = true
690
+ return compressionConfig
691
+ }
692
+ }
693
+
694
+ // 判断文件是否可压缩
695
+ const isFileCompressible = (fileName) => {
696
+ if (!fileName) return true
697
+
698
+ const lowerFileName = fileName.toLowerCase()
699
+
700
+ // 已压缩的图片格式
701
+ if (lowerFileName.endsWith('.jpg') || lowerFileName.endsWith('.jpeg') ||
702
+ lowerFileName.endsWith('.png') || lowerFileName.endsWith('.gif') ||
703
+ lowerFileName.endsWith('.webp') || lowerFileName.endsWith('.bmp')) {
704
+ return false
705
+ }
706
+
707
+ // 音视频文件
708
+ if (lowerFileName.endsWith('.mp3') || lowerFileName.endsWith('.mp4') ||
709
+ lowerFileName.endsWith('.avi') || lowerFileName.endsWith('.mov') ||
710
+ lowerFileName.endsWith('.wmv') || lowerFileName.endsWith('.flv') ||
711
+ lowerFileName.endsWith('.wav') || lowerFileName.endsWith('.aac')) {
712
+ return false
713
+ }
714
+
715
+ // 已压缩的文件
716
+ if (lowerFileName.endsWith('.zip') || lowerFileName.endsWith('.rar') ||
717
+ lowerFileName.endsWith('.7z') || lowerFileName.endsWith('.gz') ||
718
+ lowerFileName.endsWith('.tar.gz') || lowerFileName.endsWith('.bz2')) {
719
+ return false
720
+ }
721
+
722
+ // PDF文件通常已经过优化
723
+ // if (lowerFileName.endsWith('.pdf')) {
724
+ // return false
725
+ // }
726
+
727
+ return true
728
+ }
729
+
730
+ // 决定压缩策略
731
+ const determineCompressionStrategy = async (file) => {
732
+ if (!props.enableCompression) {
733
+ return 'none'
734
+ }
735
+
736
+ await loadCompressionConfig()
737
+
738
+ if (!compressionConfig.enabled) {
739
+ return 'none'
740
+ }
741
+
742
+ // 检查文件是否可压缩
743
+ // if (!isFileCompressible(file.name)) {
744
+ // console.log(`🚫 跳过不可压缩文件: ${file.name}`)
745
+ // return 'none'
746
+ // }
747
+
748
+ const fileName = file.name
749
+ const fileSize = file.size
750
+
751
+ switch (compressionConfig.mode) {
752
+ case 'frontend':
753
+ return 'frontend'
754
+ case 'backend':
755
+ return 'backend'
756
+ case 'smart':
757
+ default:
758
+ // 智能模式:小于阈值使用前端压缩,大于阈值使用后端压缩
759
+ const strategy = fileSize < compressionConfig.threshold ? 'frontend' : 'backend'
760
+ console.log(`🧠 智能压缩策略 - 文件: ${fileName}, 大小: ${formatFileSize(fileSize)}, 阈值: ${formatFileSize(compressionConfig.threshold)}, 策略: ${strategy}`)
761
+ return strategy
762
+ }
763
+ }
764
+
765
+ // 获取压缩级别
766
+ const getCompressionLevel = (level) => {
767
+ switch (level) {
768
+ case 'fast': return 3
769
+ case 'best': return 9
770
+ case 'balanced':
771
+ default: return 6
772
+ }
773
+ }
774
+
775
+ // 环境检测(与原始页面完全一致)
776
+ const detectElectronEnvironment = () => {
777
+ if (typeof window !== 'undefined') {
778
+ // 检测多种Electron标识,与原始stsUpload.html保持一致
779
+ const hasElectronProcess = window.process && window.process.type
780
+ const hasElectronAPI = window.electronAPI
781
+ const hasRequire = window.require
782
+ const hasElectron = window.electron
783
+ const hasUserAgent = typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.indexOf('Electron') >= 0
784
+ const hasElapp = typeof window.elapp !== 'undefined'
785
+ const hasFsop = typeof window.fsop !== 'undefined'
786
+
787
+ const isElectron = !!(hasElectronProcess || hasElectronAPI || hasRequire || hasElectron || hasUserAgent || hasElapp || hasFsop)
788
+
789
+ if (isElectron) {
790
+ console.log('🖥️ 检测到Electron环境')
791
+ console.log('🔧 Electron检测详情:', {
792
+ hasElectronProcess,
793
+ hasElectronAPI,
794
+ hasRequire,
795
+ hasElectron,
796
+ hasUserAgent,
797
+ hasElapp,
798
+ hasFsop
799
+ })
800
+
801
+ // 详细检测fsop API的可用性
802
+ if (hasFsop) {
803
+ console.log('📂 fsop API详细检测:', {
804
+ 'fsop': typeof window.fsop,
805
+ 'fsop.showOpenDialog': typeof window.fsop.showOpenDialog,
806
+ 'fsop.fs': typeof window.fsop.fs,
807
+ 'fsop.fs.stat': window.fsop.fs ? typeof window.fsop.fs.stat : 'undefined',
808
+ 'fsop.fs.readFileSync': window.fsop.fs ? typeof window.fsop.fs.readFileSync : 'undefined',
809
+ 'fsop.fs.readFile': window.fsop.fs ? typeof window.fsop.fs.readFile : 'undefined'
810
+ })
811
+ } else {
812
+ console.warn('⚠️ fsop对象不可用,Electron文件选择功能将被禁用')
813
+ }
814
+ }
815
+
816
+ return isElectron
817
+ }
818
+ return false
819
+ }
820
+
821
+
822
+
823
+ // 面板点击处理
824
+ const handlePanelClick = (event) => {
825
+ if (event.target.closest('.upload-button')) {
826
+ return
827
+ }
828
+
829
+ // 参考原始页面:验证期间也允许选择文件
830
+ if (!isUploading.value && !isUploadDisabled.value) {
831
+ selectFiles()
832
+ }
833
+ }
834
+
835
+ // 拖拽处理
836
+ const handleDragOver = (event) => {
837
+ event.preventDefault()
838
+ if (!isUploadDisabled.value) {
839
+ isDragActive.value = true
840
+ }
841
+ }
842
+
843
+ const handleDragLeave = (event) => {
844
+ event.preventDefault()
845
+ isDragActive.value = false
846
+ }
847
+
848
+ const handleDrop = (event) => {
849
+ event.preventDefault()
850
+ isDragActive.value = false
851
+
852
+ if (isUploadDisabled.value) {
853
+ showError('已达到文件数量限制')
854
+ return
855
+ }
856
+
857
+ const files = Array.from(event.dataTransfer.files)
858
+ processSelectedFiles(files)
859
+ }
860
+
861
+ // 文件选择处理
862
+ const handleFileSelect = (event) => {
863
+ console.log('🔽 文件选择事件触发', event.target.files)
864
+
865
+ const files = Array.from(event.target.files)
866
+ console.log('📂 选择的文件:', files)
867
+
868
+ if (files.length > 0) {
869
+ processSelectedFiles(files)
870
+ }
871
+
872
+ event.target.value = ''
873
+ }
874
+
875
+ // 处理选中的文件
876
+ const processSelectedFiles = (files) => {
877
+ processSelectedFilesWithPaths(files, null)
878
+ }
879
+
880
+ // 处理带有本地路径信息的文件选择(支持Electron)
881
+ const processSelectedFilesWithPaths = (files, localPaths = null) => {
882
+ console.log('📝 处理文件:', files)
883
+ console.log('📋 处理前当前文件列表数量:', filesToUpload.value.length)
884
+ console.log('📂 本地路径信息:', localPaths)
885
+
886
+ // 验证文件数量
887
+ if (fileRestrictions.value.maxFileCount && fileRestrictions.value.maxFileCount > 0) {
888
+ const totalCount = filesToUpload.value.length + files.length
889
+ if (totalCount > fileRestrictions.value.maxFileCount) {
890
+ showError(`文件数量超过限制,最多允许 ${fileRestrictions.value.maxFileCount} 个文件`)
891
+ return
892
+ }
893
+ }
894
+
895
+ // 验证每个文件
896
+ const validFiles = []
897
+ const validLocalPaths = []
898
+
899
+ for (let i = 0; i < files.length; i++) {
900
+ const file = files[i]
901
+
902
+ // 文件类型验证
903
+ if (fileRestrictions.value.allowedExtensions) {
904
+ const fileExt = '.' + file.name.toLowerCase().split('.').pop()
905
+ if (!fileRestrictions.value.allowedExtensions.some(ext => ext.toLowerCase() === fileExt)) {
906
+ showError(`不支持的文件类型 ${fileExt}`)
907
+ continue
908
+ }
909
+ }
910
+
911
+ // 文件大小验证
912
+ if (fileRestrictions.value.maxSizeBytes && file.size > fileRestrictions.value.maxSizeBytes) {
913
+ showError(`文件 ${file.name} 大小超过限制 ${formatFileSize(fileRestrictions.value.maxSizeBytes)}`)
914
+ continue
915
+ }
916
+
917
+ validFiles.push(file)
918
+
919
+ // 保存对应的本地路径
920
+ if (localPaths && localPaths[i]) {
921
+ validLocalPaths.push(localPaths[i])
922
+ } else if (file.localPath) {
923
+ // 从文件对象获取本地路径(Electron创建的文件对象)
924
+ validLocalPaths.push(file.localPath)
925
+ } else {
926
+ validLocalPaths.push(null)
927
+ }
928
+ }
929
+
930
+ console.log('📋 通过基础验证的文件数量:', validFiles.length)
931
+
932
+ // 如果启用了验证,先不添加到文件列表,等验证通过后再添加
933
+ if (props.enableValidation && props.onValidate) {
934
+ waitingForValidation.value = true
935
+
936
+ // 预创建文件对象用于验证,但不添加到 filesToUpload
937
+ const tempFileObjects = validFiles.map((file, index) => ({
938
+ id: generateFileId(),
939
+ name: file.name,
940
+ size: file.size,
941
+ type: file.type || '',
942
+ file: file,
943
+ localPath: validLocalPaths[index] || null
944
+ }))
945
+
946
+ // 构建验证数据格式
947
+ const fileInfos = tempFileObjects.map(fileObj => ({
948
+ id: fileObj.id,
949
+ name: fileObj.name,
950
+ size: fileObj.size,
951
+ type: fileObj.type || fileObj.name.split('.').pop()
952
+ }))
953
+
954
+ const validationData = {
955
+ files: fileInfos,
956
+ uploadPath: props.uploadPath || props.config.uploadPath
957
+ }
958
+
959
+ console.log('🔍 开始文件验证 (验证前不添加到列表):', validationData)
960
+ console.log('📋 发送验证的文件ID列表:', fileInfos.map(f => f.id))
961
+ console.log('📋 当前filesToUpload的ID列表:', filesToUpload.value.map(f => f.id))
962
+
963
+ try {
964
+ const validationPromise = props.onValidate(validationData)
965
+
966
+ if (validationPromise && typeof validationPromise.then === 'function') {
967
+ // 异步验证
968
+ validationPromise
969
+ .then((result) => {
970
+ console.log('🔍 收到异步验证结果:', result)
971
+ handleValidationResultWithPaths(result, tempFileObjects, validFiles, validLocalPaths)
972
+ })
973
+ .catch((error) => {
974
+ showError('文件验证失败: ' + error.message)
975
+ waitingForValidation.value = false
976
+ })
977
+ } else {
978
+ // 同步验证
979
+ console.log('🔍 收到同步验证结果:', validationPromise)
980
+ handleValidationResultWithPaths(validationPromise, tempFileObjects, validFiles, validLocalPaths)
981
+ }
982
+ } catch (error) {
983
+ showError('文件验证错误: ' + error.message)
984
+ waitingForValidation.value = false
985
+ }
986
+ } else {
987
+ // 没有启用验证,直接添加到文件列表
988
+ addValidatedFilesToListWithPaths(validFiles, validLocalPaths)
989
+ }
990
+ }
991
+
992
+ // 添加通过验证的文件到列表
993
+ const addValidatedFilesToList = (validFiles) => {
994
+ addValidatedFilesToListWithPaths(validFiles, null)
995
+ }
996
+
997
+ // 添加带有本地路径信息的文件到列表
998
+ const addValidatedFilesToListWithPaths = (validFiles, localPaths = null) => {
999
+ validFiles.forEach((file, index) => {
1000
+ const localPath = localPaths && localPaths[index]
1001
+ ? localPaths[index]
1002
+ : (file.localPath || getFileLocalPath(file))
1003
+
1004
+ const fileObj = {
1005
+ id: generateFileId(),
1006
+ name: file.name,
1007
+ size: file.size,
1008
+ type: file.type || '',
1009
+ file: file,
1010
+ status: 'pending',
1011
+ progress: 0,
1012
+ statusText: '等待上传',
1013
+ errorMessage: '',
1014
+ result: null,
1015
+ localPath: localPath, // 保存本地路径信息
1016
+ compressed: false,
1017
+ compressionStrategy: 'none',
1018
+ originalFileName: file.name,
1019
+ renamedFileName: file.name,
1020
+ startTime: null,
1021
+ remainingTime: ''
1022
+ }
1023
+ filesToUpload.value.push(fileObj)
1024
+
1025
+ // 在Electron环境中,将文件ID与本地路径建立映射
1026
+ if (isElectronEnv.value && localPath) {
1027
+ electronFileMap.value.set(fileObj.id, localPath)
1028
+ console.log(`📂 映射文件ID ${fileObj.id} -> ${localPath}`)
1029
+ }
1030
+ })
1031
+
1032
+ // 发送文件选择事件
1033
+ emit('file-select', validFiles)
1034
+
1035
+ // 调用onSelect回调
1036
+ if (props.onSelect) {
1037
+ props.onSelect(validFiles)
1038
+ }
1039
+
1040
+ console.log('✅ 文件添加完成,当前文件列表数量:', filesToUpload.value.length)
1041
+ if (isElectronEnv.value) {
1042
+ console.log('📂 Electron文件映射状态:', Array.from(electronFileMap.value.entries()))
1043
+ }
1044
+ }
1045
+
1046
+ // 处理带有本地路径信息的验证结果
1047
+ const handleValidationResultWithPaths = (result, tempFileObjects, validFiles, validLocalPaths) => {
1048
+ waitingForValidation.value = false
1049
+
1050
+ if (!result) {
1051
+ showError('文件验证失败:无效的验证结果')
1052
+ return
1053
+ }
1054
+
1055
+ // 支持jr-simple-sdk.js的验证结果格式
1056
+ if (result.results && Array.isArray(result.results)) {
1057
+ // 格式:{ results: [{ id, uploadFlag, msg }] }
1058
+ const approvedIds = new Set()
1059
+ const rejectedFiles = []
1060
+
1061
+ console.log('🔍 处理验证结果,验证项数量:', result.results.length)
1062
+
1063
+ const originalApprovedIds = [] // 记录原始通过验证的ID(用于计数)
1064
+
1065
+ result.results.forEach(validationItem => {
1066
+ console.log(`📋 验证项: ID=${validationItem.id}, 类型=${typeof validationItem.id}, 通过=${validationItem.uploadFlag}, 消息=${validationItem.msg}`)
1067
+
1068
+ if (validationItem.uploadFlag) {
1069
+ // 记录原始通过的ID(用于准确计数)
1070
+ originalApprovedIds.push(validationItem.id)
1071
+
1072
+ // 为匹配添加多种格式的ID
1073
+ approvedIds.add(validationItem.id)
1074
+ approvedIds.add(validationItem.id.toString())
1075
+ // 如果是数字字符串,也添加数字格式
1076
+ if (!isNaN(validationItem.id)) {
1077
+ approvedIds.add(Number(validationItem.id))
1078
+ }
1079
+ } else {
1080
+ rejectedFiles.push({
1081
+ id: validationItem.id,
1082
+ reason: validationItem.msg || '校验失败'
1083
+ })
1084
+ }
1085
+ })
1086
+
1087
+ console.log('✅ 原始通过验证的ID:', originalApprovedIds)
1088
+ console.log('✅ 批准的ID集合(用于匹配):', Array.from(approvedIds))
1089
+ console.log('❌ 拒绝的文件:', rejectedFiles)
1090
+
1091
+ // 只添加通过验证的文件到文件列表
1092
+ const approvedTempFiles = tempFileObjects.filter(tempFileObj => {
1093
+ const isApproved = approvedIds.has(tempFileObj.id) ||
1094
+ approvedIds.has(tempFileObj.id.toString()) ||
1095
+ approvedIds.has(String(tempFileObj.id))
1096
+ if (!isApproved) {
1097
+ const rejection = rejectedFiles.find(r =>
1098
+ r.id == tempFileObj.id || r.id == tempFileObj.id.toString() || String(r.id) == String(tempFileObj.id)
1099
+ )
1100
+ console.log(`🚫 拒绝文件: ${tempFileObj.name}, 原因: ${rejection ? rejection.reason : '未通过验证'}`)
1101
+ }
1102
+ return isApproved
1103
+ })
1104
+
1105
+ // 将通过验证的文件添加到文件列表
1106
+ const approvedFiles = []
1107
+ const approvedPaths = []
1108
+
1109
+ approvedTempFiles.forEach(tempFileObj => {
1110
+ const originalFile = validFiles.find(f => f.name === tempFileObj.name)
1111
+ if (originalFile) {
1112
+ approvedFiles.push(originalFile)
1113
+ approvedPaths.push(tempFileObj.localPath)
1114
+
1115
+ // 创建文件对象
1116
+ const fileObj = {
1117
+ id: tempFileObj.id, // 使用验证时生成的ID
1118
+ name: originalFile.name,
1119
+ size: originalFile.size,
1120
+ type: originalFile.type || '',
1121
+ file: originalFile,
1122
+ status: 'pending',
1123
+ progress: 0,
1124
+ statusText: '等待上传',
1125
+ errorMessage: '',
1126
+ result: null,
1127
+ localPath: tempFileObj.localPath, // 使用本地路径
1128
+ compressed: false,
1129
+ compressionStrategy: 'none',
1130
+ originalFileName: originalFile.name,
1131
+ renamedFileName: originalFile.name,
1132
+ startTime: null,
1133
+ remainingTime: ''
1134
+ }
1135
+ filesToUpload.value.push(fileObj)
1136
+
1137
+ // 在Electron环境中建立映射
1138
+ if (isElectronEnv.value && tempFileObj.localPath) {
1139
+ electronFileMap.value.set(fileObj.id, tempFileObj.localPath)
1140
+ }
1141
+ }
1142
+ })
1143
+
1144
+ // 发送文件选择事件(只包含通过验证的文件)
1145
+ emit('file-select', approvedFiles)
1146
+
1147
+ // 调用onSelect回调
1148
+ if (props.onSelect) {
1149
+ props.onSelect(approvedFiles)
1150
+ }
1151
+
1152
+ if (rejectedFiles.length > 0) {
1153
+ showError(`验证失败: ${rejectedFiles.length}个文件未通过验证`)
1154
+ }
1155
+
1156
+ console.log(`✅ 文件验证完成: ${originalApprovedIds.length}个文件通过, ${rejectedFiles.length}个文件被拒绝`)
1157
+ console.log('✅ 最终文件列表数量:', filesToUpload.value.length)
1158
+
1159
+ } else if (result === false || (result && result.success === false)) {
1160
+ // 简单格式:直接失败
1161
+ const errorMsg = result && result.message ? result.message : '文件验证失败'
1162
+ showError(errorMsg)
1163
+ console.log('❌ 所有文件验证失败')
1164
+ } else {
1165
+ // 验证成功,添加所有文件
1166
+ console.log('✅ 文件验证通过,添加所有文件')
1167
+ addValidatedFilesToListWithPaths(validFiles, validLocalPaths)
1168
+ }
1169
+ }
1170
+
1171
+ // 获取文件本地路径(Electron环境)
1172
+ const getFileLocalPath = (file) => {
1173
+ if (!isElectronEnv.value) return null
1174
+
1175
+ // 尝试从文件对象获取路径
1176
+ if (file.path) return file.path
1177
+ if (file.webkitRelativePath) return file.webkitRelativePath
1178
+
1179
+ // 尝试从Electron API获取
1180
+ try {
1181
+ if (window.electronAPI && window.electronAPI.getFilePath) {
1182
+ return window.electronAPI.getFilePath(file)
1183
+ }
1184
+ if (window.elapp && window.elapp.getFilePath) {
1185
+ return window.elapp.getFilePath(file)
1186
+ }
1187
+ } catch (error) {
1188
+ console.warn('获取文件本地路径失败:', error)
1189
+ }
1190
+
1191
+ return null
1192
+ }
1193
+
1194
+ // 文件选择方法(增强Electron支持)
1195
+ const selectFiles = async () => {
1196
+ // 参考原始页面:只在真正禁用时才阻止选择文件(不包括验证期间)
1197
+ if (isUploadDisabled.value) {
1198
+ console.log('🚫 文件选择已被禁用 - 已达到文件数量限制')
1199
+ return
1200
+ }
1201
+
1202
+ // 在Electron环境下使用专门的文件选择处理
1203
+ if (isElectronEnv.value) {
1204
+ console.log('🖥️ Electron环境:使用系统文件对话框')
1205
+ await handleElectronFileSelection()
1206
+ return
1207
+ }
1208
+
1209
+ // 普通浏览器环境
1210
+ fileInput.value.click()
1211
+ }
1212
+
1213
+ // 处理Electron环境的文件选择(参考原始页面实现)
1214
+ const handleElectronFileSelection = async () => {
1215
+ try {
1216
+ console.log('🔍 启动Electron文件选择器...')
1217
+
1218
+ // 先检查必要的API是否可用
1219
+ if (typeof window.fsop === 'undefined') {
1220
+ showError('Electron文件系统API不可用,请检查应用程序配置')
1221
+ return
1222
+ }
1223
+
1224
+ if (typeof window.fsop.showOpenDialog !== 'function') {
1225
+ showError('Electron文件对话框API不可用,请检查应用程序配置')
1226
+ return
1227
+ }
1228
+
1229
+ const filePaths = await selectFilesFromElectron()
1230
+
1231
+ if (!filePaths || filePaths.length === 0) {
1232
+ console.log('📂 用户取消了文件选择或未选择任何文件')
1233
+ return
1234
+ }
1235
+
1236
+ console.log('📁 Electron选择的文件路径:', filePaths)
1237
+
1238
+ // 验证文件数量
1239
+ if (fileRestrictions.value.maxFileCount && fileRestrictions.value.maxFileCount > 0) {
1240
+ const totalCount = filesToUpload.value.length + filePaths.length
1241
+ if (totalCount > fileRestrictions.value.maxFileCount) {
1242
+ showError(`文件数量超过限制,最多允许 ${fileRestrictions.value.maxFileCount} 个文件`)
1243
+ return
1244
+ }
1245
+ }
1246
+
1247
+ // 从文件路径创建File对象
1248
+ const filePromises = filePaths.map(async (filePath, index) => {
1249
+ try {
1250
+ const file = await createFileFromPath(filePath)
1251
+ return { file, localPath: filePath }
1252
+ } catch (error) {
1253
+ console.error(`❌ 从路径创建文件对象失败 (${filePath}):`, error)
1254
+ return { file: null, localPath: filePath, error: error.message }
1255
+ }
1256
+ })
1257
+
1258
+ const fileResults = await Promise.all(filePromises)
1259
+ const validFileResults = fileResults.filter(result => result.file !== null)
1260
+ const failedResults = fileResults.filter(result => result.file === null)
1261
+
1262
+ // 报告失败的文件
1263
+ if (failedResults.length > 0) {
1264
+ const failedPaths = failedResults.map(r => r.localPath).join(', ')
1265
+ console.warn(`⚠️ ${failedResults.length}个文件无法读取: ${failedPaths}`)
1266
+ }
1267
+
1268
+ if (validFileResults.length === 0) {
1269
+ showError('无法读取选择的文件,请检查文件权限或文件是否损坏')
1270
+ return
1271
+ }
1272
+
1273
+ const files = validFileResults.map(result => result.file)
1274
+ const localPaths = validFileResults.map(result => result.localPath)
1275
+
1276
+ console.log('✅ 成功创建文件对象:', files.length, '个文件')
1277
+
1278
+ // 处理选中的文件(传入本地路径信息)
1279
+ processSelectedFilesWithPaths(files, localPaths)
1280
+
1281
+ } catch (error) {
1282
+ console.error('❌ Electron文件选择失败:', error)
1283
+
1284
+ // 提供更具体的错误信息
1285
+ let errorMessage = '文件选择失败'
1286
+ if (error.message.includes('showOpenDialog')) {
1287
+ errorMessage = 'Electron文件对话框API调用失败,请检查应用程序配置'
1288
+ } else if (error.message.includes('fsop')) {
1289
+ errorMessage = 'Electron文件系统API不可用,请检查应用程序配置'
1290
+ } else {
1291
+ errorMessage = `文件选择失败: ${error.message}`
1292
+ }
1293
+
1294
+ showError(errorMessage)
1295
+ }
1296
+ }
1297
+
1298
+ // 从Electron选择文件(与原始页面完全一致)
1299
+ const selectFilesFromElectron = async () => {
1300
+ if (!isElectronEnv.value || typeof window.fsop === 'undefined') {
1301
+ return null
1302
+ }
1303
+
1304
+ try {
1305
+ // 构建文件过滤器(与原始页面逻辑一致)
1306
+ const filters = []
1307
+ if (fileRestrictions.value.showFileTypeInfo && fileRestrictions.value.allowedExtensions) {
1308
+ const extensions = fileRestrictions.value.allowedExtensions.map(ext =>
1309
+ ext.startsWith('.') ? ext.slice(1) : ext
1310
+ )
1311
+ const displayTypes = fileRestrictions.value.allowedExtensions.map(ext =>
1312
+ ext.replace('.', '').toUpperCase()
1313
+ ).join(', ')
1314
+ filters.push({
1315
+ name: `允许的文件类型 (${displayTypes})`,
1316
+ extensions: extensions
1317
+ })
1318
+ }
1319
+
1320
+ if (filters.length === 0) {
1321
+ filters.push({
1322
+ name: '所有文件',
1323
+ extensions: ['*']
1324
+ })
1325
+ }
1326
+
1327
+ // 根据 multiple 参数动态设置 properties(与原始页面一致)
1328
+ const properties = ['openFile']
1329
+ if (fileRestrictions.value.multiple) {
1330
+ properties.push('multiSelections')
1331
+ }
1332
+
1333
+ const dialogOptions = {
1334
+ title: '选择要上传的文件',
1335
+ properties: properties,
1336
+ filters: filters
1337
+ }
1338
+
1339
+ console.log('🔧 Electron文件选择器配置:', dialogOptions)
1340
+
1341
+ // 使用正确的API路径:window.fsop.showOpenDialog(不是 dialog.showOpenDialog)
1342
+ const result = await window.fsop.showOpenDialog(dialogOptions)
1343
+
1344
+ if (result && !result.canceled && result.filePaths && result.filePaths.length > 0) {
1345
+ return result.filePaths
1346
+ }
1347
+
1348
+ return null
1349
+ } catch (error) {
1350
+ console.error('❌ Electron文件选择失败:', error)
1351
+ return null
1352
+ }
1353
+ }
1354
+
1355
+ // 从文件路径创建File对象(与原始页面完全一致)
1356
+ const createFileFromPath = async (filePath) => {
1357
+ if (!isElectronEnv.value) {
1358
+ throw new Error('不在Electron环境中')
1359
+ }
1360
+
1361
+ if (typeof window.fsop === 'undefined') {
1362
+ throw new Error('fsop对象不可用')
1363
+ }
1364
+
1365
+ if (!window.fsop.fs) {
1366
+ throw new Error('fsop.fs不可用')
1367
+ }
1368
+
1369
+ try {
1370
+ console.log(`📁 正在从路径创建文件对象: ${filePath}`)
1371
+
1372
+ const fileName = filePath.split(/[\\\/]/).pop()
1373
+
1374
+ // 获取文件统计信息(与原始页面一致)
1375
+ const stats = await new Promise((resolve, reject) => {
1376
+ window.fsop.fs.stat(filePath, (err, stats) => {
1377
+ if (err) {
1378
+ reject(new Error(`文件不存在或无法访问: ${err.message}`))
1379
+ } else {
1380
+ resolve(stats)
1381
+ }
1382
+ })
1383
+ })
1384
+
1385
+ // 检查是否为文件(与原始页面一致)
1386
+ let isFile = true
1387
+ if (typeof stats.isFile === 'function') {
1388
+ isFile = stats.isFile()
1389
+ } else if (stats.size !== undefined && stats.size >= 0) {
1390
+ isFile = true
1391
+ }
1392
+
1393
+ if (!isFile) {
1394
+ throw new Error('选中的不是文件')
1395
+ }
1396
+
1397
+ // 读取文件内容 - 多种回退方案(与原始页面一致)
1398
+ let fileBuffer
1399
+ let readSuccess = false
1400
+
1401
+ // 方案1:同步读取
1402
+ if (!readSuccess) {
1403
+ try {
1404
+ fileBuffer = window.fsop.fs.readFileSync(filePath)
1405
+ readSuccess = true
1406
+ } catch (syncError) {
1407
+ console.warn(`⚠️ 文件读取失败,尝试其他方法:`, syncError.message)
1408
+ }
1409
+ }
1410
+
1411
+ // 方案2:异步读取(带超时)
1412
+ if (!readSuccess) {
1413
+ try {
1414
+ fileBuffer = await new Promise((resolve, reject) => {
1415
+ window.fsop.fs.readFile(filePath, (err, data) => {
1416
+ if (err) {
1417
+ reject(new Error(`异步读取失败: ${err.message}`))
1418
+ } else {
1419
+ resolve(data)
1420
+ }
1421
+ })
1422
+
1423
+ // 超时处理(与原始页面一致)
1424
+ setTimeout(() => {
1425
+ reject(new Error('readFile 回调超时 (5秒)'))
1426
+ }, 5000)
1427
+ })
1428
+ readSuccess = true
1429
+ } catch (asyncError) {
1430
+ console.warn(`⚠️ 异步读取失败:`, asyncError.message)
1431
+ }
1432
+ }
1433
+
1434
+ if (!readSuccess || !fileBuffer) {
1435
+ throw new Error(`所有文件读取方法都失败,无法读取文件: ${filePath}`)
1436
+ }
1437
+
1438
+ // 创建File对象
1439
+ const blob = new Blob([fileBuffer])
1440
+ const file = new File([blob], fileName, {
1441
+ type: getMimeType(fileName),
1442
+ lastModified: stats.mtime ? stats.mtime.getTime() : Date.now()
1443
+ })
1444
+
1445
+ // 添加本地路径信息到File对象
1446
+ file.localPath = filePath
1447
+
1448
+ console.log(`✅ 成功创建文件对象: ${fileName} (${formatFileSize(file.size)})`)
1449
+
1450
+ return file
1451
+ } catch (error) {
1452
+ console.error(`❌ 从路径创建文件对象失败 (${filePath}):`, error)
1453
+ throw error
1454
+ }
1455
+ }
1456
+
1457
+ // 尝试Electron文件对话框
1458
+ const tryElectronFileDialog = () => {
1459
+ try {
1460
+ // 检查各种Electron API
1461
+ if (window.electronAPI && window.electronAPI.showOpenDialog) {
1462
+ openElectronFileDialog()
1463
+ return true
1464
+ }
1465
+ if (window.elapp && window.elapp.showOpenDialog) {
1466
+ openElectronFileDialogLegacy()
1467
+ return true
1468
+ }
1469
+ if (window.require) {
1470
+ openElectronFileDialogRequire()
1471
+ return true
1472
+ }
1473
+ } catch (error) {
1474
+ console.warn('Electron文件对话框打开失败,回退到标准选择器:', error)
1475
+ }
1476
+ return false
1477
+ }
1478
+
1479
+ // 使用Electron文件对话框
1480
+ const openElectronFileDialog = async () => {
1481
+ try {
1482
+ const options = {
1483
+ properties: ['openFile'],
1484
+ filters: getElectronFileFilters()
1485
+ }
1486
+
1487
+ if (fileRestrictions.value.multiple) {
1488
+ options.properties.push('multiSelections')
1489
+ }
1490
+
1491
+ const result = await window.electronAPI.showOpenDialog(options)
1492
+ if (!result.canceled && result.filePaths) {
1493
+ handleElectronFiles(result.filePaths)
1494
+ }
1495
+ } catch (error) {
1496
+ console.error('Electron文件对话框错误:', error)
1497
+ }
1498
+ }
1499
+
1500
+ // 处理Electron选择的文件
1501
+ const handleElectronFiles = async (filePaths) => {
1502
+ const files = []
1503
+
1504
+ for (const filePath of filePaths) {
1505
+ try {
1506
+ // 读取文件信息
1507
+ const fileInfo = await getElectronFileInfo(filePath)
1508
+ if (fileInfo) {
1509
+ files.push(fileInfo)
1510
+ }
1511
+ } catch (error) {
1512
+ console.error('读取Electron文件失败:', filePath, error)
1513
+ }
1514
+ }
1515
+
1516
+ if (files.length > 0) {
1517
+ processSelectedFiles(files)
1518
+ }
1519
+ }
1520
+
1521
+ // 获取Electron文件信息
1522
+ const getElectronFileInfo = async (filePath) => {
1523
+ try {
1524
+ if (window.electronAPI && window.electronAPI.getFileInfo) {
1525
+ return await window.electronAPI.getFileInfo(filePath)
1526
+ }
1527
+
1528
+ // 回退方案:使用文件系统API
1529
+ if (window.require) {
1530
+ const fs = window.require('fs')
1531
+ const path = window.require('path')
1532
+
1533
+ const stats = fs.statSync(filePath)
1534
+ const fileName = path.basename(filePath)
1535
+
1536
+ // 读取文件内容
1537
+ const buffer = fs.readFileSync(filePath)
1538
+ const blob = new Blob([buffer])
1539
+
1540
+ // 创建File对象
1541
+ const file = new File([blob], fileName, {
1542
+ type: getMimeType(fileName),
1543
+ lastModified: stats.mtime.getTime()
1544
+ })
1545
+
1546
+ // 添加本地路径信息
1547
+ file.path = filePath
1548
+
1549
+ return file
1550
+ }
1551
+ } catch (error) {
1552
+ console.error('获取Electron文件信息失败:', error)
1553
+ }
1554
+ return null
1555
+ }
1556
+
1557
+ // 获取MIME类型
1558
+ const getMimeType = (fileName) => {
1559
+ const ext = fileName.toLowerCase().split('.').pop()
1560
+ const mimeTypes = {
1561
+ 'pdf': 'application/pdf',
1562
+ 'doc': 'application/msword',
1563
+ 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
1564
+ 'xls': 'application/vnd.ms-excel',
1565
+ 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
1566
+ 'ppt': 'application/vnd.ms-powerpoint',
1567
+ 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
1568
+ 'txt': 'text/plain',
1569
+ 'jpg': 'image/jpeg',
1570
+ 'jpeg': 'image/jpeg',
1571
+ 'png': 'image/png',
1572
+ 'gif': 'image/gif',
1573
+ 'zip': 'application/zip',
1574
+ 'rar': 'application/x-rar-compressed'
1575
+ }
1576
+ return mimeTypes[ext] || 'application/octet-stream'
1577
+ }
1578
+
1579
+ // 获取Electron文件过滤器
1580
+ const getElectronFileFilters = () => {
1581
+ const filters = []
1582
+
1583
+ if (fileRestrictions.value.allowedExtensions) {
1584
+ const extensions = fileRestrictions.value.allowedExtensions.map(ext => ext.replace('.', ''))
1585
+ filters.push({
1586
+ name: '支持的文件',
1587
+ extensions: extensions
1588
+ })
1589
+ }
1590
+
1591
+ filters.push({
1592
+ name: '所有文件',
1593
+ extensions: ['*']
1594
+ })
1595
+
1596
+ return filters
1597
+ }
1598
+
1599
+ // 使用旧版Electron API
1600
+ const openElectronFileDialogLegacy = async () => {
1601
+ try {
1602
+ const options = {
1603
+ properties: fileRestrictions.value.multiple ? ['openFile', 'multiSelections'] : ['openFile'],
1604
+ filters: getElectronFileFilters()
1605
+ }
1606
+
1607
+ const result = await window.elapp.showOpenDialog(options)
1608
+ if (result && result.filePaths) {
1609
+ handleElectronFiles(result.filePaths)
1610
+ }
1611
+ } catch (error) {
1612
+ console.error('旧版Electron文件对话框错误:', error)
1613
+ }
1614
+ }
1615
+
1616
+ // 使用require方式的Electron API
1617
+ const openElectronFileDialogRequire = async () => {
1618
+ try {
1619
+ const { dialog } = window.require('electron').remote || window.require('@electron/remote')
1620
+ const options = {
1621
+ properties: fileRestrictions.value.multiple ? ['openFile', 'multiSelections'] : ['openFile'],
1622
+ filters: getElectronFileFilters()
1623
+ }
1624
+
1625
+ const result = await dialog.showOpenDialog(options)
1626
+ if (!result.canceled && result.filePaths) {
1627
+ handleElectronFiles(result.filePaths)
1628
+ }
1629
+ } catch (error) {
1630
+ console.error('Require方式Electron文件对话框错误:', error)
1631
+ }
1632
+ }
1633
+
1634
+ // 工具方法
1635
+ const formatFileSize = (bytes) => {
1636
+ if (bytes === 0) return '0 B'
1637
+ const k = 1024
1638
+ const sizes = ['B', 'KB', 'MB', 'GB']
1639
+ const i = Math.floor(Math.log(bytes) / Math.log(k))
1640
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]
1641
+ }
1642
+
1643
+ // 生成文件ID,与原始stsUpload.html格式一致
1644
+ const generateFileId = () => {
1645
+ // 格式:file-timestamp-randomNumber
1646
+ const timestamp = Date.now()
1647
+ const randomNumber = Math.random()
1648
+ return `file-${timestamp}-${randomNumber}`
1649
+ }
1650
+
1651
+ // 生成32位UUID字符串(不含连字符)
1652
+ const generateUUID32 = () => {
1653
+ // 生成标准UUID并去掉连字符
1654
+ const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
1655
+ const r = Math.random() * 16 | 0
1656
+ const v = c == 'x' ? r : (r & 0x3 | 0x8)
1657
+ return v.toString(16)
1658
+ })
1659
+ return uuid.replace(/-/g, '')
1660
+ }
1661
+
1662
+ const truncateFileName = (fileName, maxLength = 32) => {
1663
+ if (fileName.length <= maxLength) return fileName
1664
+ const extension = fileName.includes('.') ? '.' + fileName.split('.').pop() : ''
1665
+ const nameWithoutExt = extension ? fileName.slice(0, -(extension.length)) : fileName
1666
+ const truncatedName = nameWithoutExt.slice(0, maxLength - extension.length - 3) + '...'
1667
+ return truncatedName + extension
1668
+ }
1669
+
1670
+ // 截断文件路径显示
1671
+ const truncateFilePath = (filePath, maxLength = 40) => {
1672
+ if (!filePath || filePath.length <= maxLength) return filePath
1673
+
1674
+ // 尝试保留文件名和关键路径部分
1675
+ const fileName = filePath.split(/[\\\/]/).pop()
1676
+ const pathParts = filePath.split(/[\\\/]/)
1677
+
1678
+ if (pathParts.length <= 2) {
1679
+ return filePath
1680
+ }
1681
+
1682
+ // 保留开头部分和文件名,中间用...表示
1683
+ const startPart = pathParts.slice(0, 2).join('/')
1684
+ const endPart = fileName
1685
+ const truncated = `${startPart}/.../${endPart}`
1686
+
1687
+ if (truncated.length <= maxLength) {
1688
+ return truncated
1689
+ }
1690
+
1691
+ // 如果还是太长,直接截断
1692
+ return filePath.slice(0, maxLength - 3) + '...'
1693
+ }
1694
+
1695
+ const showError = (message) => {
1696
+ errorMessage.value = message
1697
+ console.error('上传错误:', message)
1698
+
1699
+ // 调用onError回调
1700
+ if (props.onError) {
1701
+ props.onError(new Error(message))
1702
+ }
1703
+ }
1704
+
1705
+ // 处理文件验证结果(兼容旧版本)
1706
+ const handleValidationResult = (result, tempFileObjects, validFiles) => {
1707
+ // 将旧版本调用转发到新的带路径版本
1708
+ handleValidationResultWithPaths(result, tempFileObjects, validFiles, null)
1709
+ }
1710
+
1711
+ // 文件操作方法
1712
+ const removeFile = (fileObj) => {
1713
+ const index = filesToUpload.value.findIndex(f => f.id === fileObj.id)
1714
+ if (index > -1) {
1715
+ filesToUpload.value.splice(index, 1)
1716
+ emit('file-remove', { file: fileObj, index })
1717
+ }
1718
+ }
1719
+
1720
+ const retryUpload = async (fileObj) => {
1721
+ fileObj.status = 'pending'
1722
+ await uploadSingleFile(fileObj)
1723
+ }
1724
+
1725
+ const startUpload = async () => {
1726
+ if (isUploading.value || !hasPendingFiles.value) return
1727
+
1728
+ isUploading.value = true
1729
+ uploadProgress.total = filesToUpload.value.filter(f => f.status === 'pending').length
1730
+ uploadProgress.completed = 0
1731
+ uploadProgress.failed = 0
1732
+
1733
+ console.log('🚀 开始上传,文件数量:', uploadProgress.total)
1734
+
1735
+ try {
1736
+ const pendingFiles = filesToUpload.value.filter(f => f.status === 'pending')
1737
+
1738
+ // 模拟上传过程 - 实际项目中这里应该调用真实的上传API
1739
+ for (const fileObj of pendingFiles) {
1740
+ await uploadSingleFile(fileObj)
1741
+ }
1742
+
1743
+ const successFiles = filesToUpload.value.filter(f => f.status === 'success')
1744
+ const failedFiles = filesToUpload.value.filter(f => f.status === 'error')
1745
+
1746
+ // 构造上传结果,兼容jr-simple-sdk.js和stsUpload.html的格式
1747
+ const uploadResult = successFiles.map(f => ({
1748
+ id: f.id,
1749
+ name: f.originalFileName || f.name, // 原始文件名
1750
+ renamedFileName: f.renamedFileName || f.name, // 重命名后的文件名(压缩或UUID前缀)
1751
+ size: f.size,
1752
+ type: f.file ? f.file.type : '',
1753
+ fileName: f.originalFileName || f.name, // 保持fileName为原始名
1754
+ serverfilePath: f.result ? (f.result.key || f.result.objectKey || `${props.uploadPath || props.config.uploadPath}/${f.renamedFileName || f.name}`) : `${props.uploadPath || props.config.uploadPath}/${f.renamedFileName || f.name}`,
1755
+ fileSize: f.size,
1756
+ uploadTime: new Date().getTime(),
1757
+ uploadPath: props.uploadPath || props.config.uploadPath,
1758
+ compressed: f.compressed || false,
1759
+ compressionStrategy: f.compressionStrategy || 'none',
1760
+ result: f.result
1761
+ }))
1762
+
1763
+ // 发送上传完成事件
1764
+ emit('upload-success', uploadResult)
1765
+
1766
+ // 调用onSuccess回调
1767
+ if (props.onSuccess) {
1768
+ props.onSuccess(uploadResult)
1769
+ }
1770
+
1771
+ // 上传后处理(如果启用)
1772
+ if (props.enablePostProcess && props.onPostProcess) {
1773
+ try {
1774
+ console.log('🔄 开始上传后处理:', uploadResult)
1775
+
1776
+ // 为每个上传成功的文件调用后处理
1777
+ const postProcessPromises = uploadResult.map(async (fileInfo, index) => {
1778
+ try {
1779
+ const postProcessData = {
1780
+ file: fileInfo,
1781
+ index: index,
1782
+ uploadPath: props.uploadPath || props.config.uploadPath,
1783
+ // 额外信息便于后处理逻辑判断
1784
+ originalFileName: fileInfo.name,
1785
+ renamedFileName: fileInfo.renamedFileName
1786
+ }
1787
+
1788
+ const postProcessResult = props.onPostProcess(postProcessData)
1789
+
1790
+ if (postProcessResult && typeof postProcessResult.then === 'function') {
1791
+ // 异步处理
1792
+ const result = await postProcessResult
1793
+ console.log(`✅ 文件 ${fileInfo.fileName} 后处理完成:`, result)
1794
+
1795
+ // 检查是否需要删除文件
1796
+ if (result && result.action === 'delete') {
1797
+ console.log(`🗑️ 文件 ${fileInfo.fileName} 被后处理删除`)
1798
+ return null // 标记为删除
1799
+ }
1800
+ return { ...fileInfo, ...result }
1801
+ } else {
1802
+ // 同步处理
1803
+ console.log(`✅ 文件 ${fileInfo.fileName} 后处理完成:`, postProcessResult)
1804
+
1805
+ if (postProcessResult && postProcessResult.action === 'delete') {
1806
+ console.log(`🗑️ 文件 ${fileInfo.fileName} 被后处理删除`)
1807
+ return null
1808
+ }
1809
+ return { ...fileInfo, ...postProcessResult }
1810
+ }
1811
+ } catch (error) {
1812
+ console.error(`❌ 文件 ${fileInfo.fileName} 后处理失败:`, error)
1813
+ return fileInfo // 后处理失败,保留原文件信息
1814
+ }
1815
+ })
1816
+
1817
+ // 等待所有后处理完成
1818
+ const processedResults = await Promise.all(postProcessPromises)
1819
+
1820
+ // 过滤掉被删除的文件(null值)
1821
+ const finalResults = processedResults.filter(result => result !== null)
1822
+
1823
+ console.log(`✅ 上传后处理完成: ${finalResults.length}/${uploadResult.length} 文件保留`)
1824
+
1825
+ // 如果有文件被删除,更新结果
1826
+ if (finalResults.length < uploadResult.length) {
1827
+ // 发送更新后的结果
1828
+ emit('upload-success', finalResults)
1829
+ if (props.onSuccess) {
1830
+ props.onSuccess(finalResults)
1831
+ }
1832
+ }
1833
+
1834
+ } catch (error) {
1835
+ console.error('❌ 上传后处理失败:', error)
1836
+ }
1837
+ }
1838
+
1839
+ console.log('✅ 上传完成:', uploadResult)
1840
+
1841
+ } catch (error) {
1842
+ console.error('上传过程出错:', error)
1843
+
1844
+ // 检查是否是文件安全验证失败
1845
+ const shouldKeepModal = error.code === 'FILE_SECURITY_CHECK_FAILED' ||
1846
+ error.shouldKeepModal === true
1847
+
1848
+ emit('upload-error', {
1849
+ ...error,
1850
+ shouldKeepModal: shouldKeepModal,
1851
+ timestamp: Date.now()
1852
+ })
1853
+
1854
+ // 调用onError回调
1855
+ if (props.onError) {
1856
+ props.onError(error)
1857
+ }
1858
+
1859
+ // 如果是文件安全验证失败,显示详细的错误信息
1860
+ if (shouldKeepModal) {
1861
+ validationMessage.value = error.detailMessage || error.message
1862
+ validationMessageType.value = 'error'
1863
+ waitingForValidation.value = false
1864
+
1865
+ // 8秒后将错误信息改为提示重新选择文件
1866
+ setTimeout(() => {
1867
+ if (validationMessageType.value === 'error') {
1868
+ validationMessage.value = '请重新选择安全的文件进行上传'
1869
+ validationMessageType.value = 'warning'
1870
+ }
1871
+ }, 8000)
1872
+ }
1873
+ } finally {
1874
+ isUploading.value = false
1875
+ }
1876
+ },
1877
+
1878
+ const uploadSingleFile = async (fileObj) => {
1879
+ console.log('📤 上传文件:', fileObj.name)
1880
+
1881
+ if (!sdkInstance.value) {
1882
+ fileObj.status = 'error'
1883
+ fileObj.errorMessage = 'SDK未初始化'
1884
+ uploadProgress.failed++
1885
+ return
1886
+ }
1887
+
1888
+ fileObj.status = 'uploading'
1889
+ fileObj.progress = 0
1890
+ fileObj.startTime = Date.now()
1891
+
1892
+ emit('upload-start', {
1893
+ file: fileObj,
1894
+ timestamp: Date.now()
1895
+ })
1896
+
1897
+ try {
1898
+ // 决定压缩策略
1899
+ const compressionStrategy = await determineCompressionStrategy(fileObj.file)
1900
+ let fileToUpload = fileObj.file
1901
+
1902
+ // 根据压缩策略处理文件
1903
+ if (compressionStrategy === 'frontend') {
1904
+ console.log(`🗜️ 前端压缩文件: ${fileObj.file.name}`)
1905
+ const compressedResult = await compressFileWithJSZip(fileObj.file)
1906
+ if (compressedResult) {
1907
+ fileToUpload = new File([compressedResult.blob], compressedResult.fileName, {
1908
+ type: 'application/zip',
1909
+ lastModified: Date.now()
1910
+ })
1911
+ fileObj.compressed = true
1912
+ fileObj.compressionStrategy = 'frontend'
1913
+ fileObj.renamedFileName = compressedResult.fileName // 记录压缩后的文件名
1914
+ console.log(`✅ 前端压缩完成: ${fileObj.file.name} -> ${fileToUpload.name}`)
1915
+ }
1916
+ }
1917
+
1918
+ // 确定上传方式:后端压缩必须使用服务端上传
1919
+ const shouldUseServerUpload = props.useServerUpload || (compressionStrategy === 'backend')
1920
+
1921
+ // 构建上传选项
1922
+ const uploadOptions = {
1923
+ uploadPath: props.uploadPath || props.config.uploadPath,
1924
+ bucketName: props.bucketName && props.bucketName.trim() !== '' ? props.bucketName.trim() : undefined,
1925
+ addUuidPrefix: props.addUuidPrefix,
1926
+ enableCompression: compressionStrategy === 'backend', // 后端压缩
1927
+ useServerUpload: shouldUseServerUpload,
1928
+ enableMd5Deduplication: props.enableMd5Deduplication,
1929
+ onProgress: (progress, details) => {
1930
+ fileObj.progress = progress
1931
+
1932
+ // 统一处理状态文本(参考stsUpload.html)
1933
+ if (details && details.type) {
1934
+ switch (details.type) {
1935
+ case 'md5-calculation':
1936
+ fileObj.statusText = details.status || '正在计算文件MD5...'
1937
+ break
1938
+ case 'md5-deduplication':
1939
+ fileObj.statusText = details.status || '正在检查文件是否已存在...'
1940
+ break
1941
+ case 'server-upload-stage1':
1942
+ fileObj.statusText = '传输到服务端'
1943
+ break
1944
+ case 'server-upload-resumable':
1945
+ if (details.status === 'compressing') {
1946
+ fileObj.statusText = '服务端压缩中'
1947
+ } else {
1948
+ fileObj.statusText = '上传中'
1949
+ }
1950
+ break
1951
+ case 'server-upload-completed':
1952
+ fileObj.statusText = '处理中'
1953
+ break
1954
+ case 'frontend-direct':
1955
+ fileObj.statusText = '上传中'
1956
+ break
1957
+ default:
1958
+ fileObj.statusText = '上传中'
1959
+ }
1960
+ } else {
1961
+ fileObj.statusText = '上传中'
1962
+ }
1963
+
1964
+ fileObj.remainingTime = calculateRemainingTime(fileObj, progress)
1965
+
1966
+ emit('upload-progress', {
1967
+ file: fileObj,
1968
+ progress: progress,
1969
+ details: details,
1970
+ timestamp: Date.now()
1971
+ })
1972
+
1973
+ // 调用onProgress回调(参考jr-simple-sdk.js格式)
1974
+ if (props.onProgress) {
1975
+ props.onProgress({
1976
+ file: fileObj.name,
1977
+ progress: progress,
1978
+ details: details,
1979
+ compressionStrategy: fileObj.compressionStrategy || 'none',
1980
+ statusText: fileObj.statusText,
1981
+ timestamp: Date.now()
1982
+ })
1983
+ }
1984
+ },
1985
+ onSuccess: (result) => {
1986
+ fileObj.progress = 100
1987
+ fileObj.status = 'success'
1988
+ fileObj.result = result
1989
+ uploadProgress.completed++
1990
+
1991
+ console.log('✅ 文件上传成功:', fileObj.name, result)
1992
+ },
1993
+ onError: (error) => {
1994
+ fileObj.status = 'error'
1995
+ fileObj.errorMessage = error.message || '上传失败'
1996
+ uploadProgress.failed++
1997
+
1998
+ console.error('❌ 文件上传失败:', fileObj.name, error)
1999
+ }
2000
+ }
2001
+
2002
+ // 处理文件名(添加UUID前缀)
2003
+ let finalFile = fileToUpload
2004
+ if (props.addUuidPrefix) {
2005
+ const uuid32 = generateUUID32()
2006
+ const newFileName = `${uuid32}-${fileToUpload.name}`
2007
+ const renamedFile = new File([fileToUpload], newFileName, {
2008
+ type: fileToUpload.type,
2009
+ lastModified: fileToUpload.lastModified
2010
+ })
2011
+ finalFile = renamedFile
2012
+ fileObj.renamedFileName = newFileName // 更新重命名后的文件名
2013
+ console.log(`🔧 文件添加UUID前缀: ${fileToUpload.name} -> ${finalFile.name}`)
2014
+ }
2015
+
2016
+ // 使用SDK上传
2017
+ const result = await sdkInstance.value.upload(finalFile, uploadOptions)
2018
+
2019
+ // 确保状态正确设置
2020
+ if (fileObj.status !== 'error') {
2021
+ fileObj.status = 'success'
2022
+ fileObj.result = result
2023
+ fileObj.compressionStrategy = compressionStrategy || 'none'
2024
+ uploadProgress.completed++
2025
+ }
2026
+
2027
+ console.log('✅ 文件上传完成:', fileObj.name, {
2028
+ result: result,
2029
+ compressionStrategy: compressionStrategy,
2030
+ compressed: fileObj.compressed
2031
+ })
2032
+
2033
+ } catch (error) {
2034
+ fileObj.status = 'error'
2035
+ fileObj.errorMessage = error.message || '上传失败'
2036
+ uploadProgress.failed++
2037
+
2038
+ // 检查是否是文件安全验证失败,如果是则不关闭模态框
2039
+ const shouldKeepModal = error.code === 'FILE_SECURITY_CHECK_FAILED' ||
2040
+ error.shouldKeepModal === true
2041
+
2042
+ emit('upload-error', {
2043
+ file: fileObj,
2044
+ error: error.message,
2045
+ errorCode: error.code,
2046
+ details: error.details,
2047
+ dangerousFiles: error.dangerousFiles,
2048
+ shouldKeepModal: shouldKeepModal,
2049
+ timestamp: Date.now()
2050
+ })
2051
+
2052
+ console.error('❌ 文件上传失败:', fileObj.name, error)
2053
+
2054
+ // 如果是文件安全验证失败,显示详细的错误信息
2055
+ if (shouldKeepModal) {
2056
+ validationMessage.value = error.detailMessage || error.message
2057
+ validationMessageType.value = 'error'
2058
+ waitingForValidation.value = false
2059
+
2060
+ // 确保错误信息显示足够长的时间
2061
+ setTimeout(() => {
2062
+ if (validationMessageType.value === 'error') {
2063
+ // 5秒后清除错误信息,但不关闭模态框
2064
+ validationMessage.value = '请重新选择文件'
2065
+ validationMessageType.value = 'warning'
2066
+ }
2067
+ }, 8000)
2068
+ }
2069
+ }
2070
+ },
2071
+
2072
+ // 文件压缩判断
2073
+ const shouldCompressFile = (file) => {
2074
+ if (!props.enableCompression) return false
2075
+
2076
+ // 检查文件类型,某些类型不需要压缩(已经是压缩格式)
2077
+ const skipCompressionTypes = ['.zip', '.rar', '.7z', '.gz', '.jpg', '.jpeg', '.png', '.gif', '.mp4', '.mp3']
2078
+ const fileExt = '.' + file.name.toLowerCase().split('.').pop()
2079
+ if (skipCompressionTypes.includes(fileExt)) {
2080
+ console.log(`🚫 跳过压缩文件 ${file.name},原因:已压缩格式`)
2081
+ return false
2082
+ }
2083
+
2084
+ // 只压缩大于配置阈值的文件
2085
+ const threshold = compressionConfig.threshold || 1 * 1024 * 1024 // 1MB
2086
+ const shouldCompress = file.size > threshold
2087
+
2088
+ if (shouldCompress) {
2089
+ console.log(`🗜️ 文件 ${file.name} (${formatFileSize(file.size)}) 需要压缩`)
2090
+ }
2091
+
2092
+ return shouldCompress
2093
+ }
2094
+
2095
+ // 前端压缩文件(JSZip方式)
2096
+ const compressFileWithJSZip = async (file) => {
2097
+ if (!compressionConfig.enabled || !window.JSZip) {
2098
+ return null
2099
+ }
2100
+
2101
+ try {
2102
+ console.log('🗜️ 开始JSZip前端压缩:', file.name)
2103
+
2104
+ const zip = new window.JSZip()
2105
+ zip.file(file.name, file)
2106
+
2107
+ const compressionLevel = getCompressionLevel(compressionConfig.level)
2108
+ const compressedBlob = await zip.generateAsync({
2109
+ type: 'blob',
2110
+ compression: 'DEFLATE',
2111
+ compressionOptions: {
2112
+ level: compressionLevel
2113
+ }
2114
+ })
2115
+
2116
+ const compressedFileName = file.name + '.zip'
2117
+
2118
+ console.log(`✅ JSZip前端压缩完成: ${formatFileSize(file.size)} -> ${formatFileSize(compressedBlob.size)} (${Math.round((1 - compressedBlob.size / file.size) * 100)}% 减少)`)
2119
+
2120
+ return {
2121
+ blob: compressedBlob,
2122
+ fileName: compressedFileName
2123
+ }
2124
+ } catch (error) {
2125
+ console.error('❌ JSZip前端压缩失败:', error)
2126
+ return null
2127
+ }
2128
+ }
2129
+
2130
+ // 旧的压缩方法(保持兼容性)
2131
+ const compressFile = async (file) => {
2132
+ const result = await compressFileWithJSZip(file)
2133
+ if (result) {
2134
+ return new File([result.blob], result.fileName, { type: 'application/zip' })
2135
+ }
2136
+ return file
2137
+ }
2138
+
2139
+ // 计算剩余时间
2140
+ const calculateRemainingTime = (fileObj, currentProgress) => {
2141
+ const now = Date.now()
2142
+
2143
+ // 初始化开始时间
2144
+ if (!fileObj.startTime) {
2145
+ fileObj.startTime = now
2146
+ return ''
2147
+ }
2148
+
2149
+ // 如果进度小于1%或大于95%,不显示剩余时间
2150
+ if (currentProgress < 1 || currentProgress >= 95) {
2151
+ return ''
2152
+ }
2153
+
2154
+ // 计算已用时间(秒)
2155
+ const elapsedSeconds = (now - fileObj.startTime) / 1000
2156
+
2157
+ // 计算剩余时间
2158
+ const progressDecimal = currentProgress / 100
2159
+ const remainingProgress = 1 - progressDecimal
2160
+ const averageSpeed = progressDecimal / elapsedSeconds // 每秒完成的进度比例
2161
+
2162
+ if (averageSpeed <= 0) {
2163
+ return ''
2164
+ }
2165
+
2166
+ const remainingSeconds = remainingProgress / averageSpeed
2167
+
2168
+ // 格式化剩余时间
2169
+ if (remainingSeconds < 60) {
2170
+ return `剩余 ${Math.ceil(remainingSeconds)}秒`
2171
+ } else if (remainingSeconds < 3600) {
2172
+ const minutes = Math.ceil(remainingSeconds / 60)
2173
+ return `剩余 ${minutes}分钟`
2174
+ } else {
2175
+ const hours = Math.floor(remainingSeconds / 3600)
2176
+ const minutes = Math.ceil((remainingSeconds % 3600) / 60)
2177
+ return `剩余 ${hours}小时${minutes}分钟`
2178
+ }
2179
+ }
2180
+
2181
+ // 弹框控制方法
2182
+ const minimizeModal = () => {
2183
+ isMinimizing.value = true
2184
+ setTimeout(() => {
2185
+ isMinimized.value = true
2186
+ isMinimizing.value = false
2187
+ }, 400)
2188
+ }
2189
+
2190
+ const restoreModal = () => {
2191
+ isRestoring.value = true
2192
+ isMinimized.value = false
2193
+ setTimeout(() => {
2194
+ isRestoring.value = false
2195
+ }, 400)
2196
+ }
2197
+
2198
+ const closeModal = () => {
2199
+ resetState()
2200
+ emit('close')
2201
+ emit('update:visible', false)
2202
+
2203
+ // 调用onClose回调
2204
+ if (props.onClose) {
2205
+ props.onClose()
2206
+ }
2207
+ }
2208
+
2209
+ const handleOverlayClick = () => {
2210
+ if (!isMinimized.value) {
2211
+ closeModal()
2212
+ }
2213
+ }
2214
+
2215
+ // 拖拽功能
2216
+ const handleDragStart = (event) => {
2217
+ isDragging.value = true
2218
+ dragStartX.value = event.clientX
2219
+ dragStartY.value = event.clientY
2220
+
2221
+ const handleDragMove = (e) => {
2222
+ if (isDragging.value) {
2223
+ // 实现拖拽移动逻辑
2224
+ }
2225
+ }
2226
+
2227
+ const handleDragEnd = () => {
2228
+ isDragging.value = false
2229
+ document.removeEventListener('mousemove', handleDragMove)
2230
+ document.removeEventListener('mouseup', handleDragEnd)
2231
+ }
2232
+
2233
+ document.addEventListener('mousemove', handleDragMove)
2234
+ document.addEventListener('mouseup', handleDragEnd)
2235
+ }
2236
+
2237
+ // 返回所有需要在模板中使用的变量和方法
2238
+ return {
2239
+ // 响应式数据
2240
+ filesToUpload,
2241
+ isUploading,
2242
+ isDragActive,
2243
+ errorMessage,
2244
+ validationMessage,
2245
+ validationMessageType,
2246
+ uploadProgress,
2247
+ uploadSuccess,
2248
+ isMinimized,
2249
+ isMinimizing,
2250
+ isRestoring,
2251
+ isElectronEnv,
2252
+ waitingForValidation,
2253
+
2254
+ // 计算属性
2255
+ fileRestrictions,
2256
+ isUploadDisabled,
2257
+ uploadButtonText,
2258
+ hasPendingFiles,
2259
+ acceptedTypes,
2260
+ showRestrictions,
2261
+
2262
+ // 模板引用
2263
+ fileInput,
2264
+ uploadButton,
2265
+
2266
+ // 文件处理方法
2267
+ handlePanelClick,
2268
+ handleDragOver,
2269
+ handleDragLeave,
2270
+ handleDrop,
2271
+ handleFileSelect,
2272
+ selectFiles,
2273
+ processSelectedFiles,
2274
+ processSelectedFilesWithPaths,
2275
+ addValidatedFilesToList,
2276
+ addValidatedFilesToListWithPaths,
2277
+ handleValidationResult,
2278
+ handleValidationResultWithPaths,
2279
+ getFileLocalPath,
2280
+
2281
+ // 文件操作方法
2282
+ removeFile,
2283
+ retryUpload,
2284
+ startUpload,
2285
+ uploadSingleFile,
2286
+
2287
+ // Electron相关方法
2288
+ handleElectronFileSelection,
2289
+ selectFilesFromElectron,
2290
+ createFileFromPath,
2291
+ tryElectronFileDialog,
2292
+ openElectronFileDialog,
2293
+ handleElectronFiles,
2294
+ getElectronFileInfo,
2295
+ getMimeType,
2296
+ getElectronFileFilters,
2297
+ openElectronFileDialogLegacy,
2298
+ openElectronFileDialogRequire,
2299
+
2300
+ // 压缩相关方法
2301
+ determineCompressionStrategy,
2302
+ getCompressionLevel,
2303
+ isFileCompressible,
2304
+ shouldCompressFile,
2305
+ compressFileWithJSZip,
2306
+ compressFile,
2307
+
2308
+ // 工具方法
2309
+ formatFileSize,
2310
+ generateFileId,
2311
+ generateUUID32,
2312
+ truncateFileName,
2313
+ truncateFilePath,
2314
+ calculateRemainingTime,
2315
+ showError,
2316
+ detectElectronEnvironment,
2317
+
2318
+ // 弹框控制方法
2319
+ minimizeModal,
2320
+ restoreModal,
2321
+ closeModal,
2322
+ handleOverlayClick,
2323
+ handleDragStart,
2324
+
2325
+ // 初始化方法
2326
+ initializeComponent,
2327
+ initializeSDK,
2328
+ loadExternalDependencies,
2329
+ loadCompressionConfig,
2330
+ setDynamicBackgroundImages,
2331
+ cleanup,
2332
+ resetState
2333
+ }
2334
+ }
2335
+ }
2336
+ </script>
2337
+
2338
+ <style scoped>
2339
+ /* 完整的样式代码,与之前提供的完全一致 */
2340
+ * {
2341
+ margin: 0;
2342
+ padding: 0;
2343
+ box-sizing: border-box;
2344
+ }
2345
+
2346
+ /* 组件根包装器 */
2347
+ .jr-upload-modal-wrapper {
2348
+ position: relative;
2349
+ }
2350
+
2351
+ /* 弹框遮罩层 - 半透明遮罩 */
2352
+ .jr-upload-modal-overlay {
2353
+ position: fixed;
2354
+ top: 0;
2355
+ left: 0;
2356
+ width: 100%;
2357
+ height: 100%;
2358
+ background: rgba(0, 0, 0, 0.5);
2359
+ backdrop-filter: blur(2px);
2360
+ z-index: 9999;
2361
+ display: flex;
2362
+ justify-content: center;
2363
+ align-items: center;
2364
+ padding: 20px;
2365
+ overflow: hidden;
2366
+ }
2367
+
2368
+ /* 弹框容器 - 模拟jr-simple-sdk的模态框 */
2369
+ /* 弹框容器 */
2370
+ .modal-container {
2371
+ width: 90%;
2372
+ max-width: 1200px;
2373
+ height: 80vh;
2374
+ max-height: 800px;
2375
+ background: rgba(255, 255, 255, 0.95);
2376
+ backdrop-filter: blur(20px);
2377
+ -webkit-backdrop-filter: blur(20px);
2378
+ border-radius: 12px;
2379
+ box-shadow:
2380
+ 0 20px 60px rgba(0, 0, 0, 0.15),
2381
+ 0 8px 32px rgba(0, 0, 0, 0.1),
2382
+ 0 1px 3px rgba(0, 0, 0, 0.05);
2383
+ border: 1px solid rgba(255, 255, 255, 0.5);
2384
+ overflow: hidden;
2385
+ position: relative;
2386
+ display: flex;
2387
+ flex-direction: column;
2388
+ transform: scale(1);
2389
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2390
+ }
2391
+
2392
+ /* 模拟iframe的body区域 */
2393
+ .modal-content {
2394
+ flex: 1;
2395
+ overflow: hidden;
2396
+ position: relative;
2397
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
2398
+ /* 背景图片通过内联样式动态设置 */
2399
+ background-size: cover;
2400
+ display: flex;
2401
+ justify-content: center;
2402
+ align-items: center;
2403
+ padding: 20px;
2404
+ border-radius: 0 0 12px 12px;
2405
+ }
2406
+
2407
+ /* 标题栏 */
2408
+ .modal-header {
2409
+ height: 50px;
2410
+ background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
2411
+ border-bottom: 1px solid rgba(226, 232, 240, 0.8);
2412
+ display: flex;
2413
+ align-items: center;
2414
+ justify-content: space-between;
2415
+ padding: 0 20px;
2416
+ position: relative;
2417
+ cursor: move;
2418
+ user-select: none;
2419
+ }
2420
+
2421
+ .modal-title {
2422
+ font-size: 16px;
2423
+ font-weight: 500;
2424
+ color: #1e293b;
2425
+ display: flex;
2426
+ align-items: center;
2427
+ gap: 8px;
2428
+ }
2429
+
2430
+ /* 窗口控制按钮 */
2431
+ .window-controls {
2432
+ display: flex;
2433
+ align-items: center;
2434
+ gap: 8px;
2435
+ }
2436
+
2437
+ .control-btn {
2438
+ width: 16px;
2439
+ height: 16px;
2440
+ border-radius: 50%;
2441
+ border: none;
2442
+ cursor: pointer;
2443
+ transition: all 0.2s ease;
2444
+ position: relative;
2445
+ display: flex;
2446
+ align-items: center;
2447
+ justify-content: center;
2448
+ }
2449
+
2450
+ .control-btn:hover {
2451
+ transform: scale(1.1);
2452
+ }
2453
+
2454
+ .minimize-btn {
2455
+ background: #ffbd2e;
2456
+ }
2457
+
2458
+ .minimize-btn:hover {
2459
+ background: #f5a623;
2460
+ }
2461
+
2462
+ .minimize-btn::after {
2463
+ content: '';
2464
+ width: 6px;
2465
+ height: 1px;
2466
+ background: #fff;
2467
+ position: absolute;
2468
+ }
2469
+
2470
+ .close-btn {
2471
+ background: #ff5f57;
2472
+ }
2473
+
2474
+ .close-btn:hover {
2475
+ background: #e8443a;
2476
+ }
2477
+
2478
+ .close-btn::after {
2479
+ content: '×';
2480
+ font-size: 12px;
2481
+ color: #fff;
2482
+ line-height: 1;
2483
+ }
2484
+
2485
+ .main-container {
2486
+ margin-left: 0!important;
2487
+ width: 92%;
2488
+ max-width: 1200px;
2489
+ height: 85%!important;
2490
+ max-height: 800px;
2491
+ background: rgba(69, 70, 60, 0.5);
2492
+ backdrop-filter: blur(20px);
2493
+ -webkit-backdrop-filter: blur(20px);
2494
+ box-shadow:
2495
+ 0 8px 32px rgba(0, 0, 0, 0.1),
2496
+ 0 1px 3px rgba(0, 0, 0, 0.05),
2497
+ inset 0 1px 0 rgba(255, 255, 255, 0.6);
2498
+ overflow: hidden;
2499
+ position: relative;
2500
+ border-radius: 12px;
2501
+ }
2502
+
2503
+ .content-grid {
2504
+ display: grid;
2505
+ grid-template-columns: 350px 1fr;
2506
+ height: 100%;
2507
+ position: relative;
2508
+ }
2509
+
2510
+ .upload-panel {
2511
+ padding: 30px;
2512
+ background:
2513
+ linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
2514
+ backdrop-filter: blur(25px) saturate(1.1) brightness(1.02);
2515
+ -webkit-backdrop-filter: blur(25px) saturate(1.1) brightness(1.02);
2516
+ border-right: 1px solid rgba(200, 200, 200, 0.8);
2517
+ display: flex;
2518
+ flex-direction: column;
2519
+ justify-content: center;
2520
+ align-items: center;
2521
+ text-align: center;
2522
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
2523
+ cursor: pointer;
2524
+ position: relative;
2525
+ overflow: hidden;
2526
+ }
2527
+
2528
+ .upload-panel::before {
2529
+ content: '';
2530
+ position: absolute;
2531
+ top: -50%;
2532
+ left: -50%;
2533
+ width: 200%;
2534
+ height: 200%;
2535
+ background:
2536
+ radial-gradient(circle at 30% 70%, rgba(255, 140, 0, 0.06) 0%, transparent 40%),
2537
+ radial-gradient(circle at 70% 30%, rgba(255, 184, 77, 0.04) 0%, transparent 35%);
2538
+ animation: gentleGlow 20s ease-in-out infinite;
2539
+ pointer-events: none;
2540
+ z-index: 0;
2541
+ }
2542
+
2543
+ @keyframes gentleGlow {
2544
+ 0%, 100% {
2545
+ transform: translate(0, 0) scale(1);
2546
+ opacity: 0.3;
2547
+ }
2548
+ 50% {
2549
+ transform: translate(-2%, 2%) scale(1.02);
2550
+ opacity: 0.6;
2551
+ }
2552
+ }
2553
+
2554
+ /* 左下角渐变橙点 */
2555
+ .upload-panel::after {
2556
+ content: '';
2557
+ position: absolute;
2558
+ bottom: -60px;
2559
+ left: -60px;
2560
+ width: 200px;
2561
+ height: 200px;
2562
+ background: linear-gradient(135deg,
2563
+ rgba(255, 107, 3, 0.8) 0%,
2564
+ rgba(255, 131, 51, 0.7) 30%,
2565
+ rgba(255, 155, 99, 0.6) 60%,
2566
+ rgba(255, 179, 147, 0.5) 100%);
2567
+ border-radius: 50%;
2568
+ filter: blur(40px);
2569
+ pointer-events: none;
2570
+ z-index: 0;
2571
+ opacity: 0.8;
2572
+ }
2573
+
2574
+ .upload-panel.active {
2575
+ background:
2576
+ linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.4) 100%);
2577
+ }
2578
+
2579
+ .upload-area {
2580
+ position: relative;
2581
+ z-index: 1;
2582
+ background: transparent;
2583
+ border: none;
2584
+ border-radius: 0;
2585
+ padding: 0;
2586
+ width: 100%;
2587
+ height: 100%;
2588
+ display: flex;
2589
+ flex-direction: column;
2590
+ justify-content: center;
2591
+ align-items: center;
2592
+ text-align: center;
2593
+ transition: none;
2594
+ cursor: pointer;
2595
+ }
2596
+
2597
+ .upload-visual {
2598
+ width: 100px;
2599
+ height: 100px;
2600
+ margin: 0 auto 24px;
2601
+ background: linear-gradient(135deg,
2602
+ rgba(248, 205, 175, 0.8) 0%,
2603
+ rgba(242, 202, 185, 0.5) 100%);
2604
+ border-radius: 50%;
2605
+ display: flex;
2606
+ align-items: center;
2607
+ justify-content: center;
2608
+ font-size: 48px;
2609
+ color: #FF8C00;
2610
+ transition: all 0.3s ease;
2611
+ position: relative;
2612
+ overflow: visible;
2613
+ }
2614
+
2615
+ .folder-icon {
2616
+ transition: all 0.3s ease;
2617
+ z-index: 2;
2618
+ }
2619
+
2620
+ .folder-icon img {
2621
+ width: 60px;
2622
+ height: 60px;
2623
+ display: block;
2624
+ }
2625
+
2626
+ .file-icon {
2627
+ position: absolute;
2628
+ font-size: 24px;
2629
+ opacity: 0;
2630
+ transform: translateY(-60px) translateX(-40px) scale(0.8);
2631
+ transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
2632
+ z-index: 1;
2633
+ }
2634
+
2635
+ .drag-indicator {
2636
+ position: absolute;
2637
+ top: -60px;
2638
+ left: 50%;
2639
+ transform: translateX(-50%);
2640
+ opacity: 0;
2641
+ transition: all 0.3s ease;
2642
+ display: flex;
2643
+ flex-direction: column;
2644
+ align-items: center;
2645
+ height: 50px;
2646
+ }
2647
+
2648
+ .drag-arrow {
2649
+ position: relative;
2650
+ width: 3px;
2651
+ height: 25px;
2652
+ background: linear-gradient(180deg, #ff6822, #ff922b);
2653
+ border-radius: 2px;
2654
+ animation: arrowFlow 2.4s ease-in-out infinite;
2655
+ }
2656
+
2657
+ .drag-arrow::after {
2658
+ content: '';
2659
+ position: absolute;
2660
+ bottom: -8px;
2661
+ left: 50%;
2662
+ transform: translateX(-50%);
2663
+ width: 0;
2664
+ height: 0;
2665
+ border-left: 6px solid transparent;
2666
+ border-right: 6px solid transparent;
2667
+ border-top: 10px solid #ff922b;
2668
+ opacity: 0.7;
2669
+ }
2670
+
2671
+ .drag-arrow:nth-child(1) {
2672
+ animation-delay: 0s;
2673
+ }
2674
+
2675
+ .drag-arrow:nth-child(2) {
2676
+ animation-delay: 0.8s;
2677
+ margin-top: -20px;
2678
+ }
2679
+
2680
+ .drag-arrow:nth-child(3) {
2681
+ animation-delay: 1.6s;
2682
+ margin-top: -20px;
2683
+ }
2684
+
2685
+ @keyframes arrowFlow {
2686
+ 0% {
2687
+ opacity: 0;
2688
+ transform: translateY(-20px) scale(0.6);
2689
+ }
2690
+ 15% {
2691
+ opacity: 0.3;
2692
+ transform: translateY(-12px) scale(0.75);
2693
+ }
2694
+ 30% {
2695
+ opacity: 0.6;
2696
+ transform: translateY(-6px) scale(0.9);
2697
+ }
2698
+ 45% {
2699
+ opacity: 1;
2700
+ transform: translateY(0px) scale(1);
2701
+ }
2702
+ 60% {
2703
+ opacity: 0.6;
2704
+ transform: translateY(6px) scale(0.9);
2705
+ }
2706
+ 75% {
2707
+ opacity: 0.3;
2708
+ transform: translateY(12px) scale(0.75);
2709
+ }
2710
+ 90% {
2711
+ opacity: 0.1;
2712
+ transform: translateY(18px) scale(0.6);
2713
+ }
2714
+ 100% {
2715
+ opacity: 0;
2716
+ transform: translateY(20px) scale(0.6);
2717
+ }
2718
+ }
2719
+
2720
+ .upload-panel.active .upload-visual {
2721
+ background: linear-gradient(135deg, rgba(255, 140, 0, 0.2), rgba(255, 184, 77, 0.2));
2722
+ transform: scale(1.05);
2723
+ }
2724
+
2725
+ .upload-panel.active .file-icon {
2726
+ opacity: 1;
2727
+ animation: fileDropIn 1.2s ease-in-out infinite;
2728
+ }
2729
+
2730
+ .upload-panel.active .drag-indicator {
2731
+ opacity: 1;
2732
+ }
2733
+
2734
+ .upload-panel:hover .upload-visual {
2735
+ background: linear-gradient(135deg, rgba(255, 140, 0, 0.15), rgba(255, 184, 77, 0.15));
2736
+ transform: scale(1.02);
2737
+ }
2738
+
2739
+ .upload-panel:hover .folder-icon {
2740
+ transform: scale(1.1);
2741
+ }
2742
+
2743
+ .upload-panel:hover .drag-indicator {
2744
+ opacity: 0.8;
2745
+ }
2746
+
2747
+ @keyframes fileDropIn {
2748
+ 0% {
2749
+ opacity: 1;
2750
+ transform: translateY(-60px) translateX(-40px) scale(0.8) rotate(-10deg);
2751
+ }
2752
+ 50% {
2753
+ transform: translateY(-20px) translateX(-15px) scale(1) rotate(0deg);
2754
+ }
2755
+ 100% {
2756
+ opacity: 0;
2757
+ transform: translateY(10px) translateX(0px) scale(0.6) rotate(5deg);
2758
+ }
2759
+ }
2760
+
2761
+ .upload-button {
2762
+ background: linear-gradient(90deg, #ff6822, #ff922b);
2763
+ color: white;
2764
+ border: none;
2765
+ padding: 10px 24px;
2766
+ border-radius: 6px;
2767
+ font-size: 14px;
2768
+ font-weight: 500;
2769
+ cursor: pointer;
2770
+ transition: all 0.3s ease;
2771
+ box-shadow: 0 6px 20px rgba(255, 104, 34, 0.3);
2772
+ margin-bottom: 24px;
2773
+ position: relative;
2774
+ z-index: 2;
2775
+ }
2776
+
2777
+ .upload-button:hover {
2778
+ background: linear-gradient(90deg, #e55a1c, #ff8520);
2779
+ transform: translateY(-2px);
2780
+ box-shadow: 0 8px 25px rgba(255, 104, 34, 0.4);
2781
+ }
2782
+
2783
+ .upload-button:disabled {
2784
+ background: linear-gradient(90deg, #9ca3af, #d1d5db);
2785
+ color: #6b7280;
2786
+ cursor: not-allowed;
2787
+ transform: none;
2788
+ box-shadow: none;
2789
+ }
2790
+
2791
+ .upload-restrictions {
2792
+ background: rgba(255, 255, 255, 0.6);
2793
+ backdrop-filter: blur(15px);
2794
+ -webkit-backdrop-filter: blur(15px);
2795
+ border: 1px solid rgba(216, 216, 216, 0.4);
2796
+ border-radius: 6px;
2797
+ padding: 8px;
2798
+ margin-top: 0;
2799
+ position: relative;
2800
+ z-index: 1;
2801
+ }
2802
+
2803
+ .restrictions-title {
2804
+ font-size: 13px;
2805
+ font-weight: 600;
2806
+ color: #1e293b;
2807
+ margin-bottom: 10px;
2808
+ display: flex;
2809
+ align-items: center;
2810
+ gap: 6px;
2811
+ }
2812
+
2813
+ .restrictions-title::before {
2814
+ content: "";
2815
+ width: 16px;
2816
+ height: 16px;
2817
+ /* tipsicon.svg 通过JS动态设置,见mounted方法 */
2818
+ background-size: contain;
2819
+ background-repeat: no-repeat;
2820
+ background-position: center;
2821
+ display: inline-block;
2822
+ margin-right: 0px;
2823
+ position: relative;
2824
+ top: 1px;
2825
+ }
2826
+
2827
+ .restrictions-title.validating {
2828
+ color: #ff8c00;
2829
+ animation: validatingPulse 1.5s ease-in-out infinite;
2830
+ }
2831
+
2832
+ .restrictions-title.validating::before {
2833
+ background-image: none;
2834
+ content: "⏳";
2835
+ font-size: 14px;
2836
+ animation: spin 2s linear infinite;
2837
+ }
2838
+
2839
+ @keyframes validatingPulse {
2840
+ 0%, 100% { opacity: 1; }
2841
+ 50% { opacity: 0.7; }
2842
+ }
2843
+
2844
+ @keyframes spin {
2845
+ 0% { transform: rotate(0deg); }
2846
+ 100% { transform: rotate(360deg); }
2847
+ }
2848
+
2849
+ .restrictions-list {
2850
+ list-style: none;
2851
+ padding: 0;
2852
+ margin: 0;
2853
+ font-size: 12px;
2854
+ color: #64748b;
2855
+ line-height: 1.5;
2856
+ text-align: left;
2857
+ }
2858
+
2859
+ .restrictions-list li {
2860
+ margin-bottom: 6px;
2861
+ padding-left: 18px;
2862
+ position: relative;
2863
+ }
2864
+
2865
+ .format-tags {
2866
+ display: flex;
2867
+ flex-wrap: wrap;
2868
+ gap: 2px;
2869
+ margin-top: 2px;
2870
+ }
2871
+
2872
+ .format-tag {
2873
+ color: #ff8c00;
2874
+ font-size: 12px;
2875
+ font-weight: 500;
2876
+ text-transform: uppercase;
2877
+ margin-right: 6px;
2878
+ }
2879
+
2880
+ .size-highlight {
2881
+ color: #ff6b03;
2882
+ font-weight: 600;
2883
+ }
2884
+
2885
+ .count-highlight {
2886
+ font-weight: 600;
2887
+ }
2888
+
2889
+ .files-panel {
2890
+ padding: 30px;
2891
+ background:
2892
+ linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 100%);
2893
+ backdrop-filter: blur(25px) saturate(1.2) brightness(1.02);
2894
+ -webkit-backdrop-filter: blur(25px) saturate(1.2) brightness(1.02);
2895
+ position: relative;
2896
+ overflow: hidden;
2897
+ display: flex;
2898
+ flex-direction: column;
2899
+ height: 100%;
2900
+ }
2901
+
2902
+ /* 右上角渐变橙点 */
2903
+ .files-panel::after {
2904
+ content: '';
2905
+ position: absolute;
2906
+ top: -60px;
2907
+ right: -60px;
2908
+ width: 200px;
2909
+ height: 200px;
2910
+ background: linear-gradient(135deg,
2911
+ rgba(255, 107, 3, 0.8) 0%,
2912
+ rgba(255, 131, 51, 0.7) 30%,
2913
+ rgba(255, 155, 99, 0.6) 60%,
2914
+ rgba(255, 179, 147, 0.5) 100%);
2915
+ border-radius: 50%;
2916
+ filter: blur(40px);
2917
+ pointer-events: none;
2918
+ z-index: 0;
2919
+ opacity: 0.8;
2920
+ }
2921
+
2922
+ .files-content {
2923
+ flex: 1;
2924
+ overflow-y: auto;
2925
+ padding-right: 8px;
2926
+ margin-right: -8px;
2927
+ /* 确保内容区域可以滚动,上传按钮固定在底部 */
2928
+ min-height: 0;
2929
+ }
2930
+
2931
+ .empty-state {
2932
+ display: flex;
2933
+ align-items: center;
2934
+ justify-content: center;
2935
+ height: 100%;
2936
+ flex-direction: column;
2937
+ opacity: 0.8;
2938
+ position: relative;
2939
+ }
2940
+
2941
+ .empty-state-content {
2942
+ display: flex;
2943
+ flex-direction: column;
2944
+ align-items: center;
2945
+ justify-content: center;
2946
+ text-align: center;
2947
+ transform: translateY(-20px);
2948
+ }
2949
+
2950
+ .empty-state-icon {
2951
+ font-size: 52px;
2952
+ margin-bottom: 20px;
2953
+ opacity: 0.5;
2954
+ color: #94a3b8;
2955
+ }
2956
+
2957
+ .empty-state-text {
2958
+ font-size: 15px;
2959
+ color: #64748b;
2960
+ font-weight: 500;
2961
+ letter-spacing: 0.3px;
2962
+ line-height: 1.4;
2963
+ }
2964
+
2965
+ .panel-title {
2966
+ font-size: 16px;
2967
+ font-weight: 600;
2968
+ color: #1e293b;
2969
+ text-shadow: 0 0 20px rgba(255, 140, 0, 0.1);
2970
+ margin-bottom: 12px;
2971
+ }
2972
+
2973
+ .file-grid {
2974
+ display: flex;
2975
+ flex-direction: column;
2976
+ gap: 16px;
2977
+ }
2978
+
2979
+ .file-card {
2980
+ background: rgba(255, 255, 255, 1);
2981
+ backdrop-filter: blur(20px) saturate(1.1) brightness(1.02);
2982
+ -webkit-backdrop-filter: blur(20px) saturate(1.1) brightness(1.02);
2983
+ border: 1px solid rgba(255, 255, 255, 0.4);
2984
+ border-radius: 8px;
2985
+ padding: 16px;
2986
+ transition: all 0.3s ease;
2987
+ position: relative;
2988
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.2);
2989
+ }
2990
+
2991
+ .file-card:hover {
2992
+ border-color: #ff6b03;
2993
+ }
2994
+
2995
+ .file-row {
2996
+ display: grid;
2997
+ grid-template-columns: auto 1fr auto;
2998
+ align-items: center;
2999
+ gap: 12px;
3000
+ }
3001
+
3002
+ .file-type {
3003
+ width: 36px;
3004
+ height: 36px;
3005
+ background: #f1f5f8;
3006
+ border-radius: 6px;
3007
+ display: flex;
3008
+ align-items: center;
3009
+ justify-content: center;
3010
+ font-size: 16px;
3011
+ color: #64748b;
3012
+ flex-shrink: 0;
3013
+ }
3014
+
3015
+ .file-type img {
3016
+ width: 16px;
3017
+ height: 16px;
3018
+ display: block;
3019
+ }
3020
+
3021
+ .file-details {
3022
+ min-width: 0;
3023
+ overflow: hidden;
3024
+ }
3025
+
3026
+ .file-title {
3027
+ font-size: 14px;
3028
+ font-weight: 500;
3029
+ color: #1e293b;
3030
+ margin-bottom: 3px;
3031
+ white-space: nowrap;
3032
+ overflow: hidden;
3033
+ text-overflow: ellipsis;
3034
+ cursor: pointer;
3035
+ transition: color 0.2s ease;
3036
+ }
3037
+
3038
+ .file-title:hover {
3039
+ color: #ff6b03;
3040
+ }
3041
+
3042
+ .file-meta {
3043
+ font-size: 11px;
3044
+ color: #64748b;
3045
+ margin-bottom: 0;
3046
+ white-space: nowrap;
3047
+ overflow: hidden;
3048
+ text-overflow: ellipsis;
3049
+ }
3050
+
3051
+ .file-side-panel {
3052
+ display: flex;
3053
+ flex-direction: column;
3054
+ align-items: flex-end;
3055
+ gap: 8px;
3056
+ }
3057
+
3058
+ .file-actions {
3059
+ display: flex;
3060
+ gap: 8px;
3061
+ flex-shrink: 0;
3062
+ width: 100%;
3063
+ justify-content: flex-end;
3064
+ }
3065
+
3066
+ .file-action {
3067
+ background: rgba(255, 255, 255, 0.6);
3068
+ border: 1px solid rgba(226, 232, 240, 0.8);
3069
+ color: #94a3b8;
3070
+ padding: 2px 8px;
3071
+ border-radius: 4px;
3072
+ cursor: pointer;
3073
+ transition: all 0.3s ease;
3074
+ font-size: 11px;
3075
+ font-weight: 500;
3076
+ }
3077
+
3078
+ .file-action:hover {
3079
+ background: rgba(255, 255, 255, 0.9);
3080
+ border-color: rgba(156, 163, 175, 0.6);
3081
+ color: #6b7280;
3082
+ }
3083
+
3084
+ .remove-btn {
3085
+ color: #ef4444;
3086
+ border-color: rgba(239, 68, 68, 0.3);
3087
+ }
3088
+
3089
+ .remove-btn:hover {
3090
+ background: rgba(239, 68, 68, 0.1);
3091
+ border-color: rgba(239, 68, 68, 0.5);
3092
+ color: #dc2626;
3093
+ }
3094
+
3095
+ .file-size {
3096
+ font-size: 11px;
3097
+ color: #64748b;
3098
+ flex-shrink: 0;
3099
+ font-weight: 500;
3100
+ padding: 3px 6px;
3101
+ background: rgba(255, 255, 255, 0.6);
3102
+ border-radius: 4px;
3103
+ border: 1px solid rgba(226, 232, 240, 0.3);
3104
+ text-align: right;
3105
+ white-space: nowrap;
3106
+ }
3107
+
3108
+ .file-progress {
3109
+ margin-top: 10px;
3110
+ }
3111
+
3112
+ .progress-track {
3113
+ width: 100%;
3114
+ height: 5px;
3115
+ background: #e3eaf0;
3116
+ border-radius: 3px;
3117
+ overflow: hidden;
3118
+ margin-bottom: 6px;
3119
+ }
3120
+
3121
+ .progress-bar {
3122
+ height: 100%;
3123
+ background: linear-gradient(90deg, #FF8C00, #ffb84d);
3124
+ border-radius: 3px;
3125
+ transition: width 0.6s ease;
3126
+ }
3127
+
3128
+ .progress-text {
3129
+ display: flex;
3130
+ justify-content: space-between;
3131
+ align-items: center;
3132
+ font-size: 11px;
3133
+ color: #64748b;
3134
+ gap: 8px;
3135
+ }
3136
+
3137
+ .progress-left {
3138
+ display: flex;
3139
+ align-items: center;
3140
+ gap: 6px;
3141
+ flex: 1;
3142
+ }
3143
+
3144
+ .progress-status {
3145
+ color: #64748b;
3146
+ }
3147
+
3148
+ .progress-percent {
3149
+ font-weight: 500;
3150
+ color: #1e293b;
3151
+ }
3152
+
3153
+ .progress-time {
3154
+ flex-shrink: 0;
3155
+ color: #94a3b8;
3156
+ font-size: 10px;
3157
+ }
3158
+
3159
+ .completion-info,
3160
+ .error-info {
3161
+ margin-top: 6px;
3162
+ padding: 5px 8px;
3163
+ border-radius: 4px;
3164
+ font-size: 12px;
3165
+ }
3166
+
3167
+ .completion-info {
3168
+ padding: 4px 0px;
3169
+ }
3170
+
3171
+ .completion-text {
3172
+ color: #10b981;
3173
+ display: flex;
3174
+ align-items: center;
3175
+ }
3176
+
3177
+ .error-info {
3178
+ background: rgba(59, 130, 246, 0.1);
3179
+ border: 1px solid rgba(59, 130, 246, 0.2);
3180
+ cursor: pointer;
3181
+ transition: all 0.3s ease;
3182
+ }
3183
+
3184
+ .error-info:hover {
3185
+ background: rgba(59, 130, 246, 0.15);
3186
+ border-color: rgba(59, 130, 246, 0.3);
3187
+ }
3188
+
3189
+ .error-text {
3190
+ color: #ef4444;
3191
+ font-weight: 500;
3192
+ display: flex;
3193
+ align-items: center;
3194
+ gap: 6px;
3195
+ }
3196
+
3197
+ .retry-button {
3198
+ background: none;
3199
+ border: none;
3200
+ color: #3b82f6;
3201
+ cursor: pointer;
3202
+ font-size: 12px;
3203
+ font-weight: 500;
3204
+ padding: 0;
3205
+ text-decoration: none;
3206
+ transition: all 0.3s ease;
3207
+ padding-bottom: 2px;
3208
+ border-bottom: 1.5px solid;
3209
+ }
3210
+
3211
+ .retry-button:hover {
3212
+ color: #2563eb;
3213
+ }
3214
+
3215
+ .status-icon {
3216
+ width: 16px;
3217
+ height: 16px;
3218
+ vertical-align: text-bottom;
3219
+ margin-right: 6px;
3220
+ display: inline-block;
3221
+ position: relative;
3222
+ top: 0px;
3223
+ }
3224
+
3225
+ .compression-indicator {
3226
+ display: inline-block;
3227
+ background: rgba(34, 197, 94, 0.1);
3228
+ color: #22c55e;
3229
+ font-size: 10px;
3230
+ padding: 2px 6px;
3231
+ border-radius: 3px;
3232
+ margin-left: 6px;
3233
+ font-weight: 500;
3234
+ }
3235
+
3236
+ .file-local-path {
3237
+ margin-top: 4px;
3238
+ font-size: 11px;
3239
+ color: #64748b;
3240
+ display: flex;
3241
+ align-items: center;
3242
+ gap: 4px;
3243
+ }
3244
+
3245
+ .file-local-path .path-label {
3246
+ color: #64748b;
3247
+ font-size: 11px;
3248
+ font-weight: normal;
3249
+ white-space: nowrap;
3250
+ }
3251
+
3252
+ .file-local-path .path-value {
3253
+ color: #1e293b;
3254
+ font-family: 'Courier New', monospace;
3255
+ font-size: 11px;
3256
+ max-width: 200px;
3257
+ white-space: nowrap;
3258
+ overflow: hidden;
3259
+ text-overflow: ellipsis;
3260
+ cursor: help;
3261
+ transition: color 0.2s ease;
3262
+ }
3263
+
3264
+ .file-local-path .path-value:hover {
3265
+ color: #ff6b03;
3266
+ }
3267
+
3268
+ /* Electron环境指示器样式 */
3269
+ .electron-indicator {
3270
+ font-size: 12px;
3271
+ color: #3b82f6;
3272
+ margin-top: 8px;
3273
+ opacity: 0.8;
3274
+ display: flex;
3275
+ align-items: center;
3276
+ gap: 4px;
3277
+ background: rgba(59, 130, 246, 0.1);
3278
+ padding: 4px 8px;
3279
+ border-radius: 4px;
3280
+ border: 1px solid rgba(59, 130, 246, 0.2);
3281
+ }
3282
+
3283
+ .upload-action-area {
3284
+ margin-top: 20px;
3285
+ display: flex;
3286
+ justify-content: center;
3287
+ align-items: center;
3288
+ position: relative;
3289
+ z-index: 1;
3290
+ flex-shrink: 0;
3291
+ /* 确保上传按钮固定在底部,不跟随文件列表滚动 */
3292
+ border-top: 1px solid rgba(226, 232, 240, 0.3);
3293
+ padding-top: 20px;
3294
+ margin-top: 0;
3295
+ padding-bottom: 0;
3296
+ }
3297
+
3298
+ .start-upload-button {
3299
+ background: linear-gradient(90deg, #ff6822, #ff922b);
3300
+ color: white;
3301
+ border: none;
3302
+ padding: 12px 24px;
3303
+ border-radius: 6px;
3304
+ font-size: 14px;
3305
+ cursor: pointer;
3306
+ transition: all 0.3s ease;
3307
+ box-shadow: 0 6px 20px rgba(255, 104, 34, 0.3);
3308
+ position: relative;
3309
+ overflow: hidden;
3310
+ }
3311
+
3312
+ .start-upload-button:hover {
3313
+ background: linear-gradient(90deg, #e55a1c, #ff8520);
3314
+ transform: translateY(-2px);
3315
+ box-shadow: 0 8px 25px rgba(255, 104, 34, 0.4);
3316
+ }
3317
+
3318
+ .start-upload-button:disabled {
3319
+ background: #9ca3af;
3320
+ cursor: not-allowed;
3321
+ transform: none;
3322
+ box-shadow: none;
3323
+ }
3324
+
3325
+ /* 错误弹框样式 */
3326
+ .error-modal {
3327
+ position: fixed;
3328
+ top: 0;
3329
+ left: 0;
3330
+ width: 100%;
3331
+ height: 100%;
3332
+ background: rgba(0, 0, 0, 0.5);
3333
+ display: flex;
3334
+ justify-content: center;
3335
+ align-items: center;
3336
+ z-index: 10000;
3337
+ }
3338
+
3339
+ .error-content {
3340
+ background: white;
3341
+ border-radius: 8px;
3342
+ max-width: 500px;
3343
+ width: 90%;
3344
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
3345
+ }
3346
+
3347
+ .error-header {
3348
+ padding: 20px 20px 0;
3349
+ display: flex;
3350
+ justify-content: space-between;
3351
+ align-items: center;
3352
+ }
3353
+
3354
+ .error-header h3 {
3355
+ margin: 0;
3356
+ color: #ef4444;
3357
+ }
3358
+
3359
+ .close-error {
3360
+ background: none;
3361
+ border: none;
3362
+ font-size: 24px;
3363
+ cursor: pointer;
3364
+ color: #6b7280;
3365
+ padding: 0;
3366
+ width: 30px;
3367
+ height: 30px;
3368
+ display: flex;
3369
+ align-items: center;
3370
+ justify-content: center;
3371
+ }
3372
+
3373
+ .close-error:hover {
3374
+ color: #374151;
3375
+ }
3376
+
3377
+ .error-body {
3378
+ padding: 20px;
3379
+ color: #374151;
3380
+ line-height: 1.5;
3381
+ }
3382
+
3383
+ /* 响应式设计 */
3384
+ @media (max-width: 1440px) {
3385
+ .content-grid {
3386
+ grid-template-columns: 320px 1fr;
3387
+ }
3388
+
3389
+ .upload-panel,
3390
+ .files-panel {
3391
+ padding: 25px;
3392
+ }
3393
+
3394
+ .upload-visual {
3395
+ width: 90px;
3396
+ height: 90px;
3397
+ margin-bottom: 20px;
3398
+ }
3399
+
3400
+ .folder-icon img {
3401
+ width: 50px;
3402
+ height: 50px;
3403
+ }
3404
+ }
3405
+
3406
+ @media (max-width: 1200px) {
3407
+ .content-grid {
3408
+ grid-template-columns: 300px 1fr;
3409
+ }
3410
+
3411
+ .upload-panel,
3412
+ .files-panel {
3413
+ padding: 20px;
3414
+ }
3415
+ }
3416
+
3417
+ @media (max-width: 1024px) {
3418
+ .content-grid {
3419
+ grid-template-columns: 280px 1fr;
3420
+ }
3421
+ }
3422
+ </style>