修复: 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:
DevOps
2025-12-26 13:18:22 +08:00
parent 012f641daa
commit d0b39a0319
3 changed files with 34 additions and 33 deletions

View File

@@ -12,13 +12,13 @@ const development = {
// 测试环境配置 // 测试环境配置
const test = { const test = {
baseURL: 'http://test-api.yourdomain.com', baseURL: 'https://martial-api.aitisai.com',
timeout: 30000 timeout: 30000
} }
// 生产环境配置 // 生产环境配置
const production = { const production = {
baseURL: 'https://api.yourdomain.com', baseURL: 'https://martial-api.aitisai.com',
timeout: 30000 timeout: 30000
} }

View File

@@ -195,6 +195,28 @@ export default {
* 下载文件 * 下载文件
*/ */
downloadFile(file) { 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({ uni.showLoading({
title: '准备下载' title: '准备下载'
}) })
@@ -210,7 +232,7 @@ export default {
// 打开文档 // 打开文档
uni.openDocument({ uni.openDocument({
filePath: filePath, filePath: filePath,
fileType: file.fileType, fileType: fileExt,
success: () => { success: () => {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@@ -238,6 +260,7 @@ export default {
}) })
} }
}) })
// #endif
}, },
/** /**

View File

@@ -1,50 +1,28 @@
/**
* Vue CLI 配置文件
* 用于配置开发服务器代理,解决跨域问题
*/
module.exports = { module.exports = {
// 输出目录
outputDir: 'dist/build/h5', outputDir: 'dist/build/h5',
// 静态资源目录
assetsDir: 'static', assetsDir: 'static',
// 公共路径 - 部署到服务器时的基础路径
// 如果部署在根目录,使用 '/'
// 如果部署在子目录,使用 '/子目录名/'
publicPath: './', publicPath: './',
productionSourceMap: false,
css: {
extract: true
},
devServer: { devServer: {
host: '0.0.0.0', host: '0.0.0.0',
port: 8084, port: 8084,
disableHostCheck: true,
proxy: { proxy: {
// 代理所有 /api 开头的请求
'/api': { '/api': {
target: 'http://localhost:8123', // 后端服务地址 target: 'http://localhost:8123',
changeOrigin: true, // 改变请求源 changeOrigin: true,
ws: true, // 支持websocket ws: true,
pathRewrite: { pathRewrite: {
// 将 /api 重写为空,因为后端没有 /api 前缀
'^/api': '' '^/api': ''
} }
} }
} }
}, },
// 确保 transpileDependencies 配置正确
transpileDependencies: [], transpileDependencies: [],
// 生产环境配置
productionSourceMap: false,
// 禁用 gzip 大小报告,避免构建时的文件读取问题
css: {
extract: true
},
chainWebpack: config => { chainWebpack: config => {
// 禁用 gzip 大小报告
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
config.performance.hints(false) config.performance.hints(false)
} }