wl-design-mobile 0.8.19 → 0.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/api/doc.js +25 -25
- package/api/x1.js +56 -56
- package/btn/components/lambo-info-btn.vue +123 -123
- package/btn/components/lambo-primary-btn.vue +117 -117
- package/btn/components/lambo-text-btn.vue +116 -116
- package/btn/lambo-btn-divide.vue +35 -120
- package/btn/lambo-btn-group.vue +46 -46
- package/btn/lambo-btn-split-line.vue +41 -41
- package/btn/lambo-btn.vue +68 -68
- package/btn/lambo-extend-btn.vue +121 -121
- package/btn/lambo-icon-btn.vue +82 -82
- package/card-item/card-row-icon.vue +71 -71
- package/card-item/filtrate-row.vue +73 -73
- package/card-item/lambo-card-footer.vue +40 -40
- package/card-item/lambo-card-head.vue +66 -66
- package/card-item/lambo-card-row.vue +59 -59
- package/collapse/lambo-collapse.vue +93 -93
- package/config/config.js +14 -14
- package/detail/lambo-detail-grid.vue +58 -58
- package/detail/lambo-detail-row.vue +59 -59
- package/doc/file/compoents/lambo-file-list.vue +42 -42
- package/doc/file/compoents/lambo-file-row.vue +77 -77
- package/doc/file/lambo-file-upload-collapse.vue +107 -107
- package/doc/file-type/file-type.js +286 -286
- package/doc/img/comonents/lambo-img-grid.vue +109 -109
- package/doc/img/lambo-img-upload-collapse.vue +107 -107
- package/doc/img/styles/css/index.css +3 -3
- package/edit/list/Lambo-edit-list.vue +87 -87
- package/edit/list/lambo-edit-card-group.vue +100 -100
- package/edit/list/styles/css/index.css +39 -39
- package/edit/select/lambo-edit-date-range.vue +147 -147
- package/edit/select/lambo-edit-date-time.vue +122 -122
- package/edit/select/lambo-edit-date.vue +120 -120
- package/edit/select/lambo-edit-input-textarea.vue +91 -91
- package/edit/select/lambo-edit-input.vue +91 -91
- package/edit/select/lambo-edit-multi-select.vue +168 -168
- package/edit/select/lambo-edit-search-single-select.vue +186 -186
- package/edit/select/lambo-edit-single-select.vue +162 -162
- package/edit/select/styles/css/index.css +133 -133
- package/flow/approval/flow-approval.vue +552 -552
- package/flow/comps/flow-attachment-list.vue +230 -230
- package/flow/comps/flow-attachment-modal.vue +194 -194
- package/flow/comps/flow-copy-users.vue +358 -358
- package/flow/comps/flow-node-card.vue +150 -150
- package/flow/comps/flow-node-header.vue +172 -172
- package/flow/comps/flow-util.js +156 -156
- package/flow/comps/icons/approved.svg +11 -11
- package/flow/comps/icons/canceled.svg +11 -11
- package/flow/comps/icons/rejected.svg +11 -11
- package/flow/comps/icons/underway.svg +11 -11
- package/flow/detail/flow-detail.vue +467 -467
- package/flow/index.js +51 -51
- package/flow/lambo-flow-detail.vue +912 -912
- package/flow/lambo-flow-edit.vue +15 -15
- package/flow/submit/flow-submit.vue +383 -383
- package/icon/lambo-required-red-star.vue +47 -47
- package/icon/lambo-vector-icon.vue +71 -71
- package/list/lambo-list.vue +412 -413
- package/nav/lambo-top-nav.vue +81 -81
- package/order/comps/icons/approved.svg +10 -10
- package/order/comps/icons/underway.svg +10 -10
- package/order/comps/order-attachment-list.vue +228 -228
- package/order/comps/order-attachment-modal.vue +194 -194
- package/order/comps/order-node-card.vue +126 -126
- package/order/comps/order-node-header.vue +133 -133
- package/order/comps/order-util.js +132 -132
- package/order/detail/order-detail.vue +432 -432
- package/order/handle/order-handle.vue +517 -517
- package/order/index.js +33 -33
- package/package.json +38 -37
- package/search/lambo-date-range-page.vue +196 -196
- package/search/lambo-date-range.vue +111 -111
- package/search/lambo-date.vue +105 -105
- package/search/lambo-input.vue +74 -74
- package/search/lambo-multi-select.vue +129 -129
- package/search/lambo-org-select-page.vue +109 -109
- package/search/lambo-search-box.vue +61 -61
- package/search/lambo-search-single-select.vue +152 -152
- package/search/lambo-single-select.vue +123 -123
- package/search/lambo-week-date-select.vue +521 -521
- package/search/styles/css/index.css +138 -138
- package/styles/base.less +77 -77
- package/styles/components/btn.less +7 -7
- package/styles/components/search.less +33 -33
- package/styles/components/tag.less +181 -181
- package/styles/index.less +4 -4
- package/table/lambo-ag-table.vue +227 -227
- package/tag/lambo-tag.vue +23 -23
- package/title/lambo-title1.vue +151 -151
- package/title/lambo-title2.vue +37 -37
- package/title/lambo-title3.vue +77 -77
- package/util/assist.js +43 -43
- package/util/axios/cacheconf.js +19 -19
- package/util/axios/index.js +11 -11
- package/util/axios/interceptors.js +101 -101
- package/util/bus.js +4 -4
- package/util/jssdk-sczy.js +104 -104
- package/util/jssdk.js +608 -565
- package/util/math.js +76 -76
- package/util/token.js +36 -36
|
@@ -1,286 +1,286 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通用文件类型工具
|
|
3
|
-
* 提供文件类型识别、图标路径获取等功能
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 获取文件扩展名
|
|
8
|
-
* @param {string} fileName - 文件名
|
|
9
|
-
* @returns {string} 小写扩展名(含点号)
|
|
10
|
-
*/
|
|
11
|
-
export function getFileExt(fileName) {
|
|
12
|
-
if (!fileName) return ''
|
|
13
|
-
const lastDot = fileName.lastIndexOf('.')
|
|
14
|
-
return lastDot >= 0 ? fileName.substring(lastDot).toLowerCase() : ''
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 获取文件类型分类
|
|
19
|
-
* 支持的类型:document, spreadsheet, presentation, pdf, image, audio, video, archive, code, text, design, default
|
|
20
|
-
* @param {string} fileName - 文件名
|
|
21
|
-
* @returns {string} 文件类型分类
|
|
22
|
-
*/
|
|
23
|
-
export function getFileType(fileName) {
|
|
24
|
-
const ext = getFileExt(fileName)
|
|
25
|
-
const typeMap = {
|
|
26
|
-
// 文档
|
|
27
|
-
'.doc': 'document',
|
|
28
|
-
'.docx': 'document',
|
|
29
|
-
'.pages': 'document',
|
|
30
|
-
'.rtf': 'document',
|
|
31
|
-
'.odt': 'document',
|
|
32
|
-
// 表格
|
|
33
|
-
'.xls': 'spreadsheet',
|
|
34
|
-
'.xlsx': 'spreadsheet',
|
|
35
|
-
'.numbers': 'spreadsheet',
|
|
36
|
-
'.csv': 'spreadsheet',
|
|
37
|
-
'.ods': 'spreadsheet',
|
|
38
|
-
// 演示
|
|
39
|
-
'.ppt': 'presentation',
|
|
40
|
-
'.pptx': 'presentation',
|
|
41
|
-
'.key': 'presentation',
|
|
42
|
-
'.odp': 'presentation',
|
|
43
|
-
// PDF
|
|
44
|
-
'.pdf': 'pdf',
|
|
45
|
-
// 图片
|
|
46
|
-
'.jpg': 'image',
|
|
47
|
-
'.jpeg': 'image',
|
|
48
|
-
'.png': 'image',
|
|
49
|
-
'.gif': 'image',
|
|
50
|
-
'.bmp': 'image',
|
|
51
|
-
'.webp': 'image',
|
|
52
|
-
'.svg': 'image',
|
|
53
|
-
'.tiff': 'image',
|
|
54
|
-
'.ico': 'image',
|
|
55
|
-
// 音频
|
|
56
|
-
'.mp3': 'audio',
|
|
57
|
-
'.wav': 'audio',
|
|
58
|
-
'.flac': 'audio',
|
|
59
|
-
'.aac': 'audio',
|
|
60
|
-
'.ogg': 'audio',
|
|
61
|
-
'.m4a': 'audio',
|
|
62
|
-
'.wma': 'audio',
|
|
63
|
-
// 视频
|
|
64
|
-
'.mp4': 'video',
|
|
65
|
-
'.avi': 'video',
|
|
66
|
-
'.mov': 'video',
|
|
67
|
-
'.wmv': 'video',
|
|
68
|
-
'.flv': 'video',
|
|
69
|
-
'.mkv': 'video',
|
|
70
|
-
'.webm': 'video',
|
|
71
|
-
'.m4v': 'video',
|
|
72
|
-
// 压缩包
|
|
73
|
-
'.zip': 'archive',
|
|
74
|
-
'.rar': 'archive',
|
|
75
|
-
'.7z': 'archive',
|
|
76
|
-
'.tar': 'archive',
|
|
77
|
-
'.gz': 'archive',
|
|
78
|
-
'.bz2': 'archive',
|
|
79
|
-
'.xz': 'archive',
|
|
80
|
-
// 代码
|
|
81
|
-
'.js': 'code',
|
|
82
|
-
'.ts': 'code',
|
|
83
|
-
'.jsx': 'code',
|
|
84
|
-
'.tsx': 'code',
|
|
85
|
-
'.html': 'code',
|
|
86
|
-
'.css': 'code',
|
|
87
|
-
'.scss': 'code',
|
|
88
|
-
'.less': 'code',
|
|
89
|
-
'.java': 'code',
|
|
90
|
-
'.py': 'code',
|
|
91
|
-
'.go': 'code',
|
|
92
|
-
'.c': 'code',
|
|
93
|
-
'.cpp': 'code',
|
|
94
|
-
'.h': 'code',
|
|
95
|
-
'.php': 'code',
|
|
96
|
-
'.rb': 'code',
|
|
97
|
-
'.swift': 'code',
|
|
98
|
-
'.kt': 'code',
|
|
99
|
-
'.rs': 'code',
|
|
100
|
-
'.vue': 'code',
|
|
101
|
-
'.json': 'code',
|
|
102
|
-
'.xml': 'code',
|
|
103
|
-
'.jsp': 'code',
|
|
104
|
-
// 文本
|
|
105
|
-
'.txt': 'text',
|
|
106
|
-
'.md': 'text',
|
|
107
|
-
'.log': 'text',
|
|
108
|
-
// 设计
|
|
109
|
-
'.psd': 'design',
|
|
110
|
-
'.ai': 'design',
|
|
111
|
-
'.fig': 'design',
|
|
112
|
-
'.sketch': 'design',
|
|
113
|
-
'.xd': 'design',
|
|
114
|
-
// 电子书
|
|
115
|
-
'.epub': 'ebook',
|
|
116
|
-
'.mobi': 'ebook',
|
|
117
|
-
'.azw': 'ebook',
|
|
118
|
-
// 安装包
|
|
119
|
-
'.msi': 'installer',
|
|
120
|
-
'.exe': 'installer',
|
|
121
|
-
'.dmg': 'installer',
|
|
122
|
-
'.pkg': 'installer',
|
|
123
|
-
'.deb': 'installer',
|
|
124
|
-
'.rpm': 'installer',
|
|
125
|
-
// 原始文件
|
|
126
|
-
'.raw': 'raw',
|
|
127
|
-
'.cr2': 'raw',
|
|
128
|
-
'.nef': 'raw',
|
|
129
|
-
'.arw': 'raw'
|
|
130
|
-
}
|
|
131
|
-
return typeMap[ext] || 'default'
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 获取文件图标类型(用于匹配图标文件名)
|
|
136
|
-
* @param {string} fileName - 文件名
|
|
137
|
-
* @returns {string} 图标类型标识
|
|
138
|
-
*/
|
|
139
|
-
export function getFileIconType(fileName) {
|
|
140
|
-
const ext = getFileExt(fileName)
|
|
141
|
-
const iconMap = {
|
|
142
|
-
// 文档
|
|
143
|
-
'.doc': 'word',
|
|
144
|
-
'.docx': 'word',
|
|
145
|
-
// 表格
|
|
146
|
-
'.xls': 'excel',
|
|
147
|
-
'.xlsx': 'excel',
|
|
148
|
-
// 演示
|
|
149
|
-
'.ppt': 'ppt',
|
|
150
|
-
'.pptx': 'ppt',
|
|
151
|
-
// PDF
|
|
152
|
-
'.pdf': 'pdf',
|
|
153
|
-
// 图片
|
|
154
|
-
'.jpg': 'png',
|
|
155
|
-
'.jpeg': 'png',
|
|
156
|
-
'.png': 'png',
|
|
157
|
-
'.gif': 'gif',
|
|
158
|
-
'.bmp': 'png',
|
|
159
|
-
'.webp': 'png',
|
|
160
|
-
// 音频
|
|
161
|
-
'.mp3': 'mp3',
|
|
162
|
-
'.wav': 'mp3',
|
|
163
|
-
// 视频
|
|
164
|
-
'.mp4': 'avi',
|
|
165
|
-
'.avi': 'avi',
|
|
166
|
-
'.mov': 'avi',
|
|
167
|
-
'.flv': 'flv',
|
|
168
|
-
// 压缩包
|
|
169
|
-
'.zip': 'rar',
|
|
170
|
-
'.rar': 'rar',
|
|
171
|
-
'.7z': 'rar',
|
|
172
|
-
'.tar': 'rar',
|
|
173
|
-
'.gz': 'rar',
|
|
174
|
-
// 代码
|
|
175
|
-
'.js': 'js',
|
|
176
|
-
'.java': 'java',
|
|
177
|
-
'.jsp': 'jsp',
|
|
178
|
-
'.html': 'html',
|
|
179
|
-
// 文本
|
|
180
|
-
'.txt': 'txt',
|
|
181
|
-
// 设计
|
|
182
|
-
'.ai': 'ai',
|
|
183
|
-
'.psd': 'psd',
|
|
184
|
-
// 电子书
|
|
185
|
-
'.epub': 'epub',
|
|
186
|
-
// 安装包
|
|
187
|
-
'.msi': 'msi',
|
|
188
|
-
// 原始文件
|
|
189
|
-
'.raw': 'raw'
|
|
190
|
-
}
|
|
191
|
-
return iconMap[ext] || 'default'
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 获取文件图标路径
|
|
196
|
-
* @param {string} fileName - 文件名
|
|
197
|
-
* @returns {string} 图标资源路径
|
|
198
|
-
*/
|
|
199
|
-
export function getFileIconPath(fileName) {
|
|
200
|
-
const iconType = getFileIconType(fileName)
|
|
201
|
-
try {
|
|
202
|
-
return require(`./icons/icon-file-${iconType}.svg`)
|
|
203
|
-
} catch (e) {
|
|
204
|
-
return require(`./icons/icon-file-default.svg`)
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* 格式化文件大小
|
|
210
|
-
* @param {number} size - 文件大小(字节)
|
|
211
|
-
* @returns {string} 格式化后的大小字符串
|
|
212
|
-
*/
|
|
213
|
-
export function formatFileSize(size) {
|
|
214
|
-
if (!size) return '-'
|
|
215
|
-
if (size < 1024) return size + ' B'
|
|
216
|
-
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + ' KB'
|
|
217
|
-
if (size < 1024 * 1024 * 1024) return (size / (1024 * 1024)).toFixed(2) + ' MB'
|
|
218
|
-
return (size / (1024 * 1024 * 1024)).toFixed(2) + ' GB'
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* 判断是否是图片文件
|
|
223
|
-
* @param {string} fileName - 文件名
|
|
224
|
-
* @returns {boolean}
|
|
225
|
-
*/
|
|
226
|
-
export function isImageFile(fileName) {
|
|
227
|
-
return getFileType(fileName) === 'image'
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 判断是否是视频文件
|
|
232
|
-
* @param {string} fileName - 文件名
|
|
233
|
-
* @returns {boolean}
|
|
234
|
-
*/
|
|
235
|
-
export function isVideoFile(fileName) {
|
|
236
|
-
return getFileType(fileName) === 'video'
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* 判断是否是可预览的文件类型
|
|
241
|
-
* @param {string} fileName - 文件名
|
|
242
|
-
* @returns {boolean}
|
|
243
|
-
*/
|
|
244
|
-
export function isPreviewable(fileName) {
|
|
245
|
-
const type = getFileType(fileName)
|
|
246
|
-
return ['image', 'pdf', 'video'].includes(type)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* 获取文件类型的中文名称
|
|
251
|
-
* @param {string} fileName - 文件名
|
|
252
|
-
* @returns {string} 类型名称
|
|
253
|
-
*/
|
|
254
|
-
export function getFileTypeName(fileName) {
|
|
255
|
-
const type = getFileType(fileName)
|
|
256
|
-
const nameMap = {
|
|
257
|
-
document: '文档',
|
|
258
|
-
spreadsheet: '表格',
|
|
259
|
-
presentation: '演示文稿',
|
|
260
|
-
pdf: 'PDF',
|
|
261
|
-
image: '图片',
|
|
262
|
-
audio: '音频',
|
|
263
|
-
video: '视频',
|
|
264
|
-
archive: '压缩包',
|
|
265
|
-
code: '代码',
|
|
266
|
-
text: '文本',
|
|
267
|
-
design: '设计文件',
|
|
268
|
-
ebook: '电子书',
|
|
269
|
-
installer: '安装包',
|
|
270
|
-
raw: '原始文件',
|
|
271
|
-
default: '文件'
|
|
272
|
-
}
|
|
273
|
-
return nameMap[type] || nameMap.default
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export default {
|
|
277
|
-
getFileExt,
|
|
278
|
-
getFileType,
|
|
279
|
-
getFileIconType,
|
|
280
|
-
getFileIconPath,
|
|
281
|
-
formatFileSize,
|
|
282
|
-
isImageFile,
|
|
283
|
-
isVideoFile,
|
|
284
|
-
isPreviewable,
|
|
285
|
-
getFileTypeName
|
|
286
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 通用文件类型工具
|
|
3
|
+
* 提供文件类型识别、图标路径获取等功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 获取文件扩展名
|
|
8
|
+
* @param {string} fileName - 文件名
|
|
9
|
+
* @returns {string} 小写扩展名(含点号)
|
|
10
|
+
*/
|
|
11
|
+
export function getFileExt(fileName) {
|
|
12
|
+
if (!fileName) return ''
|
|
13
|
+
const lastDot = fileName.lastIndexOf('.')
|
|
14
|
+
return lastDot >= 0 ? fileName.substring(lastDot).toLowerCase() : ''
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取文件类型分类
|
|
19
|
+
* 支持的类型:document, spreadsheet, presentation, pdf, image, audio, video, archive, code, text, design, default
|
|
20
|
+
* @param {string} fileName - 文件名
|
|
21
|
+
* @returns {string} 文件类型分类
|
|
22
|
+
*/
|
|
23
|
+
export function getFileType(fileName) {
|
|
24
|
+
const ext = getFileExt(fileName)
|
|
25
|
+
const typeMap = {
|
|
26
|
+
// 文档
|
|
27
|
+
'.doc': 'document',
|
|
28
|
+
'.docx': 'document',
|
|
29
|
+
'.pages': 'document',
|
|
30
|
+
'.rtf': 'document',
|
|
31
|
+
'.odt': 'document',
|
|
32
|
+
// 表格
|
|
33
|
+
'.xls': 'spreadsheet',
|
|
34
|
+
'.xlsx': 'spreadsheet',
|
|
35
|
+
'.numbers': 'spreadsheet',
|
|
36
|
+
'.csv': 'spreadsheet',
|
|
37
|
+
'.ods': 'spreadsheet',
|
|
38
|
+
// 演示
|
|
39
|
+
'.ppt': 'presentation',
|
|
40
|
+
'.pptx': 'presentation',
|
|
41
|
+
'.key': 'presentation',
|
|
42
|
+
'.odp': 'presentation',
|
|
43
|
+
// PDF
|
|
44
|
+
'.pdf': 'pdf',
|
|
45
|
+
// 图片
|
|
46
|
+
'.jpg': 'image',
|
|
47
|
+
'.jpeg': 'image',
|
|
48
|
+
'.png': 'image',
|
|
49
|
+
'.gif': 'image',
|
|
50
|
+
'.bmp': 'image',
|
|
51
|
+
'.webp': 'image',
|
|
52
|
+
'.svg': 'image',
|
|
53
|
+
'.tiff': 'image',
|
|
54
|
+
'.ico': 'image',
|
|
55
|
+
// 音频
|
|
56
|
+
'.mp3': 'audio',
|
|
57
|
+
'.wav': 'audio',
|
|
58
|
+
'.flac': 'audio',
|
|
59
|
+
'.aac': 'audio',
|
|
60
|
+
'.ogg': 'audio',
|
|
61
|
+
'.m4a': 'audio',
|
|
62
|
+
'.wma': 'audio',
|
|
63
|
+
// 视频
|
|
64
|
+
'.mp4': 'video',
|
|
65
|
+
'.avi': 'video',
|
|
66
|
+
'.mov': 'video',
|
|
67
|
+
'.wmv': 'video',
|
|
68
|
+
'.flv': 'video',
|
|
69
|
+
'.mkv': 'video',
|
|
70
|
+
'.webm': 'video',
|
|
71
|
+
'.m4v': 'video',
|
|
72
|
+
// 压缩包
|
|
73
|
+
'.zip': 'archive',
|
|
74
|
+
'.rar': 'archive',
|
|
75
|
+
'.7z': 'archive',
|
|
76
|
+
'.tar': 'archive',
|
|
77
|
+
'.gz': 'archive',
|
|
78
|
+
'.bz2': 'archive',
|
|
79
|
+
'.xz': 'archive',
|
|
80
|
+
// 代码
|
|
81
|
+
'.js': 'code',
|
|
82
|
+
'.ts': 'code',
|
|
83
|
+
'.jsx': 'code',
|
|
84
|
+
'.tsx': 'code',
|
|
85
|
+
'.html': 'code',
|
|
86
|
+
'.css': 'code',
|
|
87
|
+
'.scss': 'code',
|
|
88
|
+
'.less': 'code',
|
|
89
|
+
'.java': 'code',
|
|
90
|
+
'.py': 'code',
|
|
91
|
+
'.go': 'code',
|
|
92
|
+
'.c': 'code',
|
|
93
|
+
'.cpp': 'code',
|
|
94
|
+
'.h': 'code',
|
|
95
|
+
'.php': 'code',
|
|
96
|
+
'.rb': 'code',
|
|
97
|
+
'.swift': 'code',
|
|
98
|
+
'.kt': 'code',
|
|
99
|
+
'.rs': 'code',
|
|
100
|
+
'.vue': 'code',
|
|
101
|
+
'.json': 'code',
|
|
102
|
+
'.xml': 'code',
|
|
103
|
+
'.jsp': 'code',
|
|
104
|
+
// 文本
|
|
105
|
+
'.txt': 'text',
|
|
106
|
+
'.md': 'text',
|
|
107
|
+
'.log': 'text',
|
|
108
|
+
// 设计
|
|
109
|
+
'.psd': 'design',
|
|
110
|
+
'.ai': 'design',
|
|
111
|
+
'.fig': 'design',
|
|
112
|
+
'.sketch': 'design',
|
|
113
|
+
'.xd': 'design',
|
|
114
|
+
// 电子书
|
|
115
|
+
'.epub': 'ebook',
|
|
116
|
+
'.mobi': 'ebook',
|
|
117
|
+
'.azw': 'ebook',
|
|
118
|
+
// 安装包
|
|
119
|
+
'.msi': 'installer',
|
|
120
|
+
'.exe': 'installer',
|
|
121
|
+
'.dmg': 'installer',
|
|
122
|
+
'.pkg': 'installer',
|
|
123
|
+
'.deb': 'installer',
|
|
124
|
+
'.rpm': 'installer',
|
|
125
|
+
// 原始文件
|
|
126
|
+
'.raw': 'raw',
|
|
127
|
+
'.cr2': 'raw',
|
|
128
|
+
'.nef': 'raw',
|
|
129
|
+
'.arw': 'raw'
|
|
130
|
+
}
|
|
131
|
+
return typeMap[ext] || 'default'
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 获取文件图标类型(用于匹配图标文件名)
|
|
136
|
+
* @param {string} fileName - 文件名
|
|
137
|
+
* @returns {string} 图标类型标识
|
|
138
|
+
*/
|
|
139
|
+
export function getFileIconType(fileName) {
|
|
140
|
+
const ext = getFileExt(fileName)
|
|
141
|
+
const iconMap = {
|
|
142
|
+
// 文档
|
|
143
|
+
'.doc': 'word',
|
|
144
|
+
'.docx': 'word',
|
|
145
|
+
// 表格
|
|
146
|
+
'.xls': 'excel',
|
|
147
|
+
'.xlsx': 'excel',
|
|
148
|
+
// 演示
|
|
149
|
+
'.ppt': 'ppt',
|
|
150
|
+
'.pptx': 'ppt',
|
|
151
|
+
// PDF
|
|
152
|
+
'.pdf': 'pdf',
|
|
153
|
+
// 图片
|
|
154
|
+
'.jpg': 'png',
|
|
155
|
+
'.jpeg': 'png',
|
|
156
|
+
'.png': 'png',
|
|
157
|
+
'.gif': 'gif',
|
|
158
|
+
'.bmp': 'png',
|
|
159
|
+
'.webp': 'png',
|
|
160
|
+
// 音频
|
|
161
|
+
'.mp3': 'mp3',
|
|
162
|
+
'.wav': 'mp3',
|
|
163
|
+
// 视频
|
|
164
|
+
'.mp4': 'avi',
|
|
165
|
+
'.avi': 'avi',
|
|
166
|
+
'.mov': 'avi',
|
|
167
|
+
'.flv': 'flv',
|
|
168
|
+
// 压缩包
|
|
169
|
+
'.zip': 'rar',
|
|
170
|
+
'.rar': 'rar',
|
|
171
|
+
'.7z': 'rar',
|
|
172
|
+
'.tar': 'rar',
|
|
173
|
+
'.gz': 'rar',
|
|
174
|
+
// 代码
|
|
175
|
+
'.js': 'js',
|
|
176
|
+
'.java': 'java',
|
|
177
|
+
'.jsp': 'jsp',
|
|
178
|
+
'.html': 'html',
|
|
179
|
+
// 文本
|
|
180
|
+
'.txt': 'txt',
|
|
181
|
+
// 设计
|
|
182
|
+
'.ai': 'ai',
|
|
183
|
+
'.psd': 'psd',
|
|
184
|
+
// 电子书
|
|
185
|
+
'.epub': 'epub',
|
|
186
|
+
// 安装包
|
|
187
|
+
'.msi': 'msi',
|
|
188
|
+
// 原始文件
|
|
189
|
+
'.raw': 'raw'
|
|
190
|
+
}
|
|
191
|
+
return iconMap[ext] || 'default'
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 获取文件图标路径
|
|
196
|
+
* @param {string} fileName - 文件名
|
|
197
|
+
* @returns {string} 图标资源路径
|
|
198
|
+
*/
|
|
199
|
+
export function getFileIconPath(fileName) {
|
|
200
|
+
const iconType = getFileIconType(fileName)
|
|
201
|
+
try {
|
|
202
|
+
return require(`./icons/icon-file-${iconType}.svg`)
|
|
203
|
+
} catch (e) {
|
|
204
|
+
return require(`./icons/icon-file-default.svg`)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 格式化文件大小
|
|
210
|
+
* @param {number} size - 文件大小(字节)
|
|
211
|
+
* @returns {string} 格式化后的大小字符串
|
|
212
|
+
*/
|
|
213
|
+
export function formatFileSize(size) {
|
|
214
|
+
if (!size) return '-'
|
|
215
|
+
if (size < 1024) return size + ' B'
|
|
216
|
+
if (size < 1024 * 1024) return (size / 1024).toFixed(2) + ' KB'
|
|
217
|
+
if (size < 1024 * 1024 * 1024) return (size / (1024 * 1024)).toFixed(2) + ' MB'
|
|
218
|
+
return (size / (1024 * 1024 * 1024)).toFixed(2) + ' GB'
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 判断是否是图片文件
|
|
223
|
+
* @param {string} fileName - 文件名
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
*/
|
|
226
|
+
export function isImageFile(fileName) {
|
|
227
|
+
return getFileType(fileName) === 'image'
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 判断是否是视频文件
|
|
232
|
+
* @param {string} fileName - 文件名
|
|
233
|
+
* @returns {boolean}
|
|
234
|
+
*/
|
|
235
|
+
export function isVideoFile(fileName) {
|
|
236
|
+
return getFileType(fileName) === 'video'
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 判断是否是可预览的文件类型
|
|
241
|
+
* @param {string} fileName - 文件名
|
|
242
|
+
* @returns {boolean}
|
|
243
|
+
*/
|
|
244
|
+
export function isPreviewable(fileName) {
|
|
245
|
+
const type = getFileType(fileName)
|
|
246
|
+
return ['image', 'pdf', 'video'].includes(type)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 获取文件类型的中文名称
|
|
251
|
+
* @param {string} fileName - 文件名
|
|
252
|
+
* @returns {string} 类型名称
|
|
253
|
+
*/
|
|
254
|
+
export function getFileTypeName(fileName) {
|
|
255
|
+
const type = getFileType(fileName)
|
|
256
|
+
const nameMap = {
|
|
257
|
+
document: '文档',
|
|
258
|
+
spreadsheet: '表格',
|
|
259
|
+
presentation: '演示文稿',
|
|
260
|
+
pdf: 'PDF',
|
|
261
|
+
image: '图片',
|
|
262
|
+
audio: '音频',
|
|
263
|
+
video: '视频',
|
|
264
|
+
archive: '压缩包',
|
|
265
|
+
code: '代码',
|
|
266
|
+
text: '文本',
|
|
267
|
+
design: '设计文件',
|
|
268
|
+
ebook: '电子书',
|
|
269
|
+
installer: '安装包',
|
|
270
|
+
raw: '原始文件',
|
|
271
|
+
default: '文件'
|
|
272
|
+
}
|
|
273
|
+
return nameMap[type] || nameMap.default
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export default {
|
|
277
|
+
getFileExt,
|
|
278
|
+
getFileType,
|
|
279
|
+
getFileIconType,
|
|
280
|
+
getFileIconPath,
|
|
281
|
+
formatFileSize,
|
|
282
|
+
isImageFile,
|
|
283
|
+
isVideoFile,
|
|
284
|
+
isPreviewable,
|
|
285
|
+
getFileTypeName
|
|
286
|
+
}
|