修改部分预览,数据完整性,暂态列表等bug调整

This commit is contained in:
sjl
2025-12-24 10:41:04 +08:00
parent a52021572a
commit dbb6a9f72b
10 changed files with 100 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
import { downloadFile } from '@/api/system-boot/file'
// 下载文件
export const download = (urls: any) => {
console.log('下载',urls)
downloadFile({ filePath: urls }).then((res: any) => {
let blob = new Blob([res], {
type: urls.includes('.pdf')
@@ -40,3 +40,36 @@ function removeLastDotSuffix(str: string) {
// 如果存在 .,截取到 . 之前的部分;否则返回原字符串
return lastDotIndex !== -1 ? str.slice(0, lastDotIndex) : str
}
// 预览文件
export const previewFile = async (urls: any) => {
console.log('预览',urls)
let url = ''
await downloadFile({ filePath: urls }).then((res: any) => {
let blob = new Blob([res], {
type: urls.includes('.pdf')
? 'application/pdf'
: urls.includes('.zip')
? 'application/zip'
: urls.includes('.doc')
? 'application/msword'
: urls.includes('.docx')
? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
: urls.includes('.xls')
? 'application/vnd.ms-excel'
: urls.includes('.xlsx')
? 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
: urls.includes('.png')
? 'image/png'
: urls.includes('.jpeg')
? 'image/jpeg'
: urls.includes('.jpg')
? 'image/jpg'
: ''
})
url = window.URL.createObjectURL(blob)
})
console.log('url',url)
return url
}