vue2-client 1.15.63 → 1.15.65

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.
@@ -1,321 +1,320 @@
1
- <template>
2
- <div class="file-list">
3
- <div class="file-grid">
4
- <div v-for="file in files" :key="file.id" class="file-item">
5
- <div class="file-info">
6
- <div class="file-icon-wrapper" :class="getFileTypeClass(file.name)">
7
- <template v-if="isImageType(file.name)">
8
- <img :src="file.url" class="file-thumb" />
9
- </template>
10
- <template v-else>
11
- <a-icon :type="getFileIcon(file.name)" class="file-icon" />
12
- </template>
13
- </div>
14
- <div class="file-content">
15
- <div class="file-header">
16
- <span class="file-name">{{ file.real_name ? file.real_name : file.name }}</span>
17
- <span class="file-type">{{ getFileType(file.name) }}</span>
18
- </div>
19
- <div class="file-footer">
20
- <span class="file-size" v-if="file.size">{{ formatFileSize(file.size) }}</span>
21
- <span class="file-time" v-if="file.upload_time">{{ file.upload_time }}</span>
22
- </div>
23
- </div>
24
- </div>
25
- <div class="file-actions">
26
- <a-tooltip title="预览文件">
27
- <a-button type="link" class="action-btn preview-btn" @click="handlePreview(file.url)">
28
- <a-icon type="eye" />
29
- </a-button>
30
- </a-tooltip>
31
- <a-tooltip v-if="downloadable" title="下载文件">
32
- <a-button type="link" class="action-btn download-btn" @click="download(file)">
33
- <a-icon type="download" />
34
- </a-button>
35
- </a-tooltip>
36
- </div>
37
- </div>
38
- </div>
39
- <!-- 文件预览弹窗 -->
40
- <a-modal
41
- v-model="previewVisible"
42
- :footer="null"
43
- :dialog-style="{ top: '20px' }"
44
- width="85%"
45
- :z-index="1001"
46
- title="文件预览"
47
- @cancel="handlePreviewClose"
48
- >
49
- <file-preview :path="previewPath" />
50
- </a-modal>
51
- </div>
52
- </template>
53
-
54
- <script>
55
- import FilePreview from '@vue2-client/components/FilePreview'
56
-
57
- export default {
58
- name: 'FileImageItem',
59
- components: {
60
- FilePreview
61
- },
62
- props: {
63
- files: {
64
- type: Array,
65
- required: true
66
- },
67
- downloadable: {
68
- type: Boolean,
69
- required: false,
70
- default: true
71
- }
72
- },
73
- data () {
74
- return {
75
- previewVisible: false,
76
- previewPath: ''
77
- }
78
- },
79
- methods: {
80
- handlePreview (path) {
81
- this.previewPath = path
82
- this.previewVisible = true
83
- },
84
- handlePreviewClose () {
85
- this.previewVisible = false
86
- this.previewPath = ''
87
- },
88
- download (file) {
89
- const a = document.createElement('a')
90
- a.href = file.url
91
- a.download = file.name
92
- a.click()
93
- },
94
- formatFileSize (size) {
95
- if (!size) return ''
96
- // 如果小于1M,转换为KB显示
97
- if (size < 1) {
98
- const kbSize = size * 1024
99
- return `${kbSize.toFixed(1)} KB`
100
- }
101
- // 大于等于1M,保持M为单位
102
- return `${size.toFixed(1)} MB`
103
- },
104
- getFileType (filename) {
105
- const ext = filename.split('.').pop().toLowerCase()
106
- const typeMap = {
107
- pdf: 'PDF文档',
108
- doc: 'Word文档',
109
- docx: 'Word文档',
110
- xls: 'Excel表格',
111
- xlsx: 'Excel表格',
112
- ppt: 'PPT演示',
113
- pptx: 'PPT演示',
114
- jpg: '图片',
115
- jpeg: '图片',
116
- png: '图片',
117
- gif: '图片',
118
- txt: '文本文件',
119
- zip: '压缩文件',
120
- rar: '压缩文件'
121
- }
122
- return typeMap[ext] || '文件'
123
- },
124
- getFileIcon (filename) {
125
- const ext = filename.split('.').pop().toLowerCase()
126
- const iconMap = {
127
- pdf: 'file-pdf',
128
- doc: 'file-word',
129
- docx: 'file-word',
130
- xls: 'file-excel',
131
- xlsx: 'file-excel',
132
- ppt: 'file-ppt',
133
- pptx: 'file-ppt',
134
- jpg: 'file-image',
135
- jpeg: 'file-image',
136
- png: 'file-image',
137
- gif: 'file-image',
138
- txt: 'file-text',
139
- zip: 'file-zip',
140
- rar: 'file-zip'
141
- }
142
- return iconMap[ext] || 'file'
143
- },
144
- getFileTypeClass (filename) {
145
- const ext = filename.split('.').pop().toLowerCase()
146
- return `file-type-${ext}`
147
- },
148
- isImageType (filename) {
149
- const ext = filename.split('.').pop().toLowerCase()
150
- return ['jpg', 'jpeg', 'png', 'gif'].includes(ext)
151
- }
152
- }
153
- }
154
- </script>
155
-
156
- <style lang="less" scoped>
157
- .file-list {
158
- .file-grid {
159
- display: grid;
160
- grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
161
- gap: 16px;
162
- }
163
-
164
- .file-item {
165
- display: flex;
166
- align-items: center;
167
- justify-content: space-between;
168
- padding: 16px;
169
- background: #fff;
170
- border-radius: 12px;
171
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
172
- border: 1px solid rgba(0, 0, 0, 0.06);
173
-
174
- &:hover {
175
- transform: translateY(-2px);
176
- border-color: @primary-2;
177
- background: rgba(24, 144, 255, 0.02);
178
- }
179
-
180
- .file-info {
181
- display: flex;
182
- align-items: center;
183
- flex: 1;
184
- min-width: 0;
185
-
186
- .file-icon-wrapper {
187
- display: flex;
188
- align-items: center;
189
- justify-content: center;
190
- width: 48px;
191
- height: 48px;
192
- margin-right: 16px;
193
- border-radius: 12px;
194
- transition: all 0.3s;
195
-
196
- &.file-type-pdf {
197
- background: linear-gradient(135deg, #ff4d4f, #ff7875);
198
- }
199
- &.file-type-doc, &.file-type-docx {
200
- background: linear-gradient(135deg, #1890ff, #69c0ff);
201
- }
202
- &.file-type-xls, &.file-type-xlsx {
203
- background: linear-gradient(135deg, #52c41a, #95de64);
204
- }
205
- &.file-type-ppt, &.file-type-pptx {
206
- background: linear-gradient(135deg, #fa8c16, #ffc069);
207
- }
208
- &.file-type-jpg, &.file-type-jpeg, &.file-type-png, &.file-type-gif {
209
- background: linear-gradient(135deg, #722ed1, #b37feb);
210
- }
211
- &.file-type-txt {
212
- background: linear-gradient(135deg, #13c2c2, #5cdbd3);
213
- }
214
- &.file-type-zip, &.file-type-rar {
215
- background: linear-gradient(135deg, #eb2f96, #ff85c0);
216
- }
217
-
218
- .file-icon {
219
- font-size: 24px;
220
- color: #fff;
221
- }
222
- .file-thumb {
223
- width: 40px;
224
- height: 40px;
225
- object-fit: cover;
226
- border-radius: 8px;
227
- box-shadow: 0 1px 4px rgba(0,0,0,0.08);
228
- }
229
- }
230
-
231
- .file-content {
232
- display: flex;
233
- flex-direction: column;
234
- min-width: 0;
235
- flex: 1;
236
-
237
- .file-header {
238
- display: flex;
239
- align-items: center;
240
- margin-bottom: 4px;
241
-
242
- .file-name {
243
- color: rgba(0, 0, 0, 0.85);
244
- font-size: 15px;
245
- font-weight: 500;
246
- overflow: hidden;
247
- text-overflow: ellipsis;
248
- white-space: nowrap;
249
- margin-right: 8px;
250
- width: 0;
251
- flex: 1;
252
- }
253
-
254
- .file-type {
255
- color: rgba(0, 0, 0, 0.45);
256
- font-size: 12px;
257
- padding: 2px 6px;
258
- background: rgba(0, 0, 0, 0.04);
259
- border-radius: 4px;
260
- }
261
- }
262
-
263
- .file-footer {
264
- display: flex;
265
- align-items: center;
266
- color: rgba(0, 0, 0, 0.45);
267
- font-size: 12px;
268
-
269
- .file-size {
270
- margin-right: 12px;
271
- }
272
-
273
- .file-time {
274
- position: relative;
275
- padding-left: 12px;
276
-
277
- &::before {
278
- content: '';
279
- position: absolute;
280
- left: 0;
281
- top: 50%;
282
- transform: translateY(-50%);
283
- width: 4px;
284
- height: 4px;
285
- background: rgba(0, 0, 0, 0.25);
286
- border-radius: 50%;
287
- }
288
- }
289
- }
290
- }
291
- }
292
-
293
- .file-actions {
294
- display: flex;
295
- align-items: center;
296
- margin-left: 16px;
297
-
298
- .action-btn {
299
- width: 36px;
300
- height: 36px;
301
- padding: 0;
302
- margin-left: 8px;
303
- border-radius: 8px;
304
- color: rgba(0, 0, 0, 0.45);
305
- background: transparent;
306
- transition: all 0.3s;
307
-
308
- &:hover {
309
- color: #fff;
310
- background: @primary-color;
311
- transform: scale(1.05);
312
- }
313
-
314
- .anticon {
315
- font-size: 16px;
316
- }
317
- }
318
- }
319
- }
320
- }
321
- </style>
1
+ <template>
2
+ <div class="file-list">
3
+ <div class="file-grid">
4
+ <div v-for="file in files" :key="file.id" class="file-item">
5
+ <div class="file-info">
6
+ <div v-if="isImageType(file.name)">
7
+ <img :src="file.url" class="file-thumb" />
8
+ </div>
9
+ <div v-else class="file-icon-wrapper" :class="getFileTypeClass(file.name)">
10
+ <a-icon :type="getFileIcon(file.name)" class="file-icon" />
11
+ </div>
12
+ <div class="file-content">
13
+ <div class="file-header">
14
+ <span class="file-name">{{ file.real_name ? file.real_name : file.name }}</span>
15
+ <span class="file-type">{{ getFileType(file.name) }}</span>
16
+ </div>
17
+ <div class="file-footer">
18
+ <span class="file-size" v-if="file.size">{{ formatFileSize(file.size) }}</span>
19
+ <span class="file-time" v-if="file.upload_time">{{ file.upload_time }}</span>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <div class="file-actions">
24
+ <a-tooltip title="预览文件">
25
+ <a-button type="link" class="action-btn preview-btn" @click="handlePreview(file.url)">
26
+ <a-icon type="eye" />
27
+ </a-button>
28
+ </a-tooltip>
29
+ <a-tooltip v-if="downloadable" title="下载文件">
30
+ <a-button type="link" class="action-btn download-btn" @click="download(file)">
31
+ <a-icon type="download" />
32
+ </a-button>
33
+ </a-tooltip>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <!-- 文件预览弹窗 -->
38
+ <a-modal
39
+ v-model="previewVisible"
40
+ :footer="null"
41
+ :dialog-style="{ top: '20px' }"
42
+ width="85%"
43
+ :z-index="1001"
44
+ title="文件预览"
45
+ @cancel="handlePreviewClose"
46
+ >
47
+ <file-preview :path="previewPath" />
48
+ </a-modal>
49
+ </div>
50
+ </template>
51
+
52
+ <script>
53
+ import FilePreview from '@vue2-client/components/FilePreview'
54
+
55
+ export default {
56
+ name: 'FileImageItem',
57
+ components: {
58
+ FilePreview
59
+ },
60
+ props: {
61
+ files: {
62
+ type: Array,
63
+ required: true
64
+ },
65
+ downloadable: {
66
+ type: Boolean,
67
+ required: false,
68
+ default: true
69
+ }
70
+ },
71
+ data () {
72
+ return {
73
+ previewVisible: false,
74
+ previewPath: ''
75
+ }
76
+ },
77
+ methods: {
78
+ handlePreview (path) {
79
+ this.previewPath = path
80
+ this.previewVisible = true
81
+ },
82
+ handlePreviewClose () {
83
+ this.previewVisible = false
84
+ this.previewPath = ''
85
+ },
86
+ download (file) {
87
+ const a = document.createElement('a')
88
+ a.href = file.url
89
+ a.download = file.name
90
+ a.click()
91
+ },
92
+ formatFileSize (size) {
93
+ if (!size) return ''
94
+ // 如果小于1M,转换为KB显示
95
+ if (size < 1) {
96
+ const kbSize = size * 1024
97
+ return `${kbSize.toFixed(1)} KB`
98
+ }
99
+ // 大于等于1M,保持M为单位
100
+ return `${size.toFixed(1)} MB`
101
+ },
102
+ getFileType (filename) {
103
+ const ext = filename.split('.').pop().toLowerCase()
104
+ const typeMap = {
105
+ pdf: 'PDF文档',
106
+ doc: 'Word文档',
107
+ docx: 'Word文档',
108
+ xls: 'Excel表格',
109
+ xlsx: 'Excel表格',
110
+ ppt: 'PPT演示',
111
+ pptx: 'PPT演示',
112
+ jpg: '图片',
113
+ jpeg: '图片',
114
+ png: '图片',
115
+ gif: '图片',
116
+ txt: '文本文件',
117
+ zip: '压缩文件',
118
+ rar: '压缩文件'
119
+ }
120
+ return typeMap[ext] || '文件'
121
+ },
122
+ getFileIcon (filename) {
123
+ const ext = filename.split('.').pop().toLowerCase()
124
+ const iconMap = {
125
+ pdf: 'file-pdf',
126
+ doc: 'file-word',
127
+ docx: 'file-word',
128
+ xls: 'file-excel',
129
+ xlsx: 'file-excel',
130
+ ppt: 'file-ppt',
131
+ pptx: 'file-ppt',
132
+ jpg: 'file-image',
133
+ jpeg: 'file-image',
134
+ png: 'file-image',
135
+ gif: 'file-image',
136
+ txt: 'file-text',
137
+ zip: 'file-zip',
138
+ rar: 'file-zip'
139
+ }
140
+ return iconMap[ext] || 'file'
141
+ },
142
+ getFileTypeClass (filename) {
143
+ const ext = filename.split('.').pop().toLowerCase()
144
+ return `file-type-${ext}`
145
+ },
146
+ isImageType (filename) {
147
+ const ext = filename.split('.').pop().toLowerCase()
148
+ return ['jpg', 'jpeg', 'png', 'gif'].includes(ext)
149
+ }
150
+ }
151
+ }
152
+ </script>
153
+
154
+ <style lang="less" scoped>
155
+ .file-list {
156
+ .file-grid {
157
+ display: grid;
158
+ grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
159
+ gap: 16px;
160
+ }
161
+
162
+ .file-item {
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: space-between;
166
+ padding: 16px;
167
+ background: #fff;
168
+ border-radius: 12px;
169
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
170
+ border: 1px solid rgba(0, 0, 0, 0.06);
171
+
172
+ &:hover {
173
+ transform: translateY(-2px);
174
+ border-color: @primary-2;
175
+ background: rgba(24, 144, 255, 0.02);
176
+ }
177
+
178
+ .file-info {
179
+ display: flex;
180
+ align-items: center;
181
+ flex: 1;
182
+ min-width: 0;
183
+
184
+ .file-icon-wrapper {
185
+ display: flex;
186
+ align-items: center;
187
+ justify-content: center;
188
+ width: 48px;
189
+ height: 48px;
190
+ margin-right: 16px;
191
+ border-radius: 12px;
192
+ transition: all 0.3s;
193
+
194
+ &.file-type-pdf {
195
+ background: linear-gradient(135deg, #ff4d4f, #ff7875);
196
+ }
197
+ &.file-type-doc, &.file-type-docx {
198
+ background: linear-gradient(135deg, #1890ff, #69c0ff);
199
+ }
200
+ &.file-type-xls, &.file-type-xlsx {
201
+ background: linear-gradient(135deg, #52c41a, #95de64);
202
+ }
203
+ &.file-type-ppt, &.file-type-pptx {
204
+ background: linear-gradient(135deg, #fa8c16, #ffc069);
205
+ }
206
+ &.file-type-jpg, &.file-type-jpeg, &.file-type-png, &.file-type-gif {
207
+ background: linear-gradient(135deg, #722ed1, #b37feb);
208
+ }
209
+ &.file-type-txt {
210
+ background: linear-gradient(135deg, #13c2c2, #5cdbd3);
211
+ }
212
+ &.file-type-zip, &.file-type-rar {
213
+ background: linear-gradient(135deg, #eb2f96, #ff85c0);
214
+ }
215
+
216
+ .file-icon {
217
+ font-size: 24px;
218
+ color: #fff;
219
+ }
220
+ }
221
+
222
+ .file-content {
223
+ display: flex;
224
+ flex-direction: column;
225
+ min-width: 0;
226
+ flex: 1;
227
+
228
+ .file-header {
229
+ display: flex;
230
+ align-items: center;
231
+ margin-bottom: 4px;
232
+
233
+ .file-name {
234
+ color: rgba(0, 0, 0, 0.85);
235
+ font-size: 15px;
236
+ font-weight: 500;
237
+ overflow: hidden;
238
+ text-overflow: ellipsis;
239
+ white-space: nowrap;
240
+ margin-right: 8px;
241
+ width: 0;
242
+ flex: 1;
243
+ }
244
+
245
+ .file-type {
246
+ color: rgba(0, 0, 0, 0.45);
247
+ font-size: 12px;
248
+ padding: 2px 6px;
249
+ background: rgba(0, 0, 0, 0.04);
250
+ border-radius: 4px;
251
+ }
252
+ }
253
+
254
+ .file-footer {
255
+ display: flex;
256
+ align-items: center;
257
+ color: rgba(0, 0, 0, 0.45);
258
+ font-size: 12px;
259
+
260
+ .file-size {
261
+ margin-right: 12px;
262
+ }
263
+
264
+ .file-time {
265
+ position: relative;
266
+ padding-left: 12px;
267
+
268
+ &::before {
269
+ content: '';
270
+ position: absolute;
271
+ left: 0;
272
+ top: 50%;
273
+ transform: translateY(-50%);
274
+ width: 4px;
275
+ height: 4px;
276
+ background: rgba(0, 0, 0, 0.25);
277
+ border-radius: 50%;
278
+ }
279
+ }
280
+ }
281
+ }
282
+ }
283
+
284
+ .file-actions {
285
+ display: flex;
286
+ align-items: center;
287
+ margin-left: 16px;
288
+
289
+ .action-btn {
290
+ width: 36px;
291
+ height: 36px;
292
+ padding: 0;
293
+ margin-left: 8px;
294
+ border-radius: 8px;
295
+ color: rgba(0, 0, 0, 0.45);
296
+ background: transparent;
297
+ transition: all 0.3s;
298
+
299
+ &:hover {
300
+ color: #fff;
301
+ background: @primary-color;
302
+ transform: scale(1.05);
303
+ }
304
+
305
+ .anticon {
306
+ font-size: 16px;
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ .file-thumb {
313
+ width: 48px;
314
+ height: 48px;
315
+ object-fit: cover;
316
+ margin-right: 16px;
317
+ border-radius: 12px;
318
+ box-shadow: 0 1px 4px rgba(0,0,0,0.08);
319
+ }
320
+ </style>