vue2-client 1.16.27 → 1.16.29

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,320 +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 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>
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>