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