修复: API配置和文件下载问题
- 修复生产环境API地址配置 (api.config.js) - 修复event-rules页面下载文件无后缀问题,H5环境使用a标签download属性 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -195,6 +195,28 @@ export default {
|
||||
* 下载文件
|
||||
*/
|
||||
downloadFile(file) {
|
||||
// 获取文件后缀
|
||||
const fileExt = file.fileType || this.getFileType(file.fileName) || 'pdf'
|
||||
|
||||
// #ifdef H5
|
||||
// H5环境:直接使用a标签下载,确保文件名带后缀
|
||||
const link = document.createElement('a')
|
||||
link.href = file.fileUrl
|
||||
link.download = file.fileName // 设置下载文件名(带后缀)
|
||||
link.target = '_blank'
|
||||
link.style.display = 'none'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
uni.showToast({
|
||||
title: '开始下载',
|
||||
icon: 'success'
|
||||
})
|
||||
return
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
// 非H5环境
|
||||
uni.showLoading({
|
||||
title: '准备下载'
|
||||
})
|
||||
@@ -210,7 +232,7 @@ export default {
|
||||
// 打开文档
|
||||
uni.openDocument({
|
||||
filePath: filePath,
|
||||
fileType: file.fileType,
|
||||
fileType: fileExt,
|
||||
success: () => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
@@ -238,6 +260,7 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user