This commit is contained in:
fengchenchen
2023-08-14 17:10:11 +08:00
commit 37f6ec895d
1145 changed files with 437754 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
import { getFileAccessHttpUrl } from '@/api/manage'
const getFileName = (path) => {
if (path.lastIndexOf('\\') >= 0) {
const reg = new RegExp('\\\\', 'g')
path = path.replace(reg, '/')
}
return path.substring(path.lastIndexOf('/') + 1)
}
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
const getFilePaths = (uploadFiles) => {
const arr = []
if (!uploadFiles) {
return ''
}
for (let a = 0; a < uploadFiles.length; a++) {
arr.push(uploadFiles[a].response.message)
}
if (arr && arr.length > 0) {
return arr.join(',')
}
return ''
}
const getUploadFileList = (paths) => {
if (!paths) {
return []
}
const fileList = []
const arr = paths.split(',')
for (let a = 0; a < arr.length; a++) {
if (!arr[a]) {
continue
} else {
fileList.push({
uid: uidGenerator(),
name: getFileName(arr[a]),
status: 'done',
url: getFileAccessHttpUrl(arr[a]),
response: {
status: 'history',
message: arr[a]
}
})
}
}
return fileList
}
export { getFilePaths, getUploadFileList }