优化代码,提高安全性
This commit is contained in:
@@ -4,8 +4,8 @@ import request from '@/utils/request'
|
||||
export function getAudioList(params) {
|
||||
return request({
|
||||
url: '/audioManagement/list',
|
||||
method: 'get',
|
||||
params: {
|
||||
method: 'post',
|
||||
data: {
|
||||
current: params.current || 1,
|
||||
size: params.size || 20,
|
||||
recordingName: params.recordingName,
|
||||
|
||||
@@ -2,9 +2,12 @@ import request from '@/utils/request'
|
||||
import { AUTH_API } from './config'
|
||||
|
||||
export function login(data) {
|
||||
// 转换参数名称以匹配后端接口要求
|
||||
const account = (data.username || '').trim()
|
||||
// 同时传常见字段名,兼容不同后端 DTO(userName / username / loginAccount)
|
||||
const loginData = {
|
||||
userName: data.username, // 后端需要 userName 而不是 username
|
||||
userName: account,
|
||||
username: account,
|
||||
loginAccount: account,
|
||||
password: data.password
|
||||
}
|
||||
return request({
|
||||
|
||||
@@ -107,9 +107,21 @@ service.interceptors.response.use(
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error) // for debug
|
||||
console.error('请求失败:', error.response?.status, error.response?.data || error.message)
|
||||
let msg = error.message || '请求失败'
|
||||
if (error.response) {
|
||||
const rd = error.response.data
|
||||
if (typeof rd === 'string' && rd) {
|
||||
msg = rd
|
||||
} else if (rd && typeof rd === 'object') {
|
||||
msg = rd.message || rd.msg || rd.error || msg
|
||||
}
|
||||
if (error.response.status === 500 && msg === error.message) {
|
||||
msg = '服务器内部错误(500),请检查后端服务与数据库是否正常,或查看后端日志'
|
||||
}
|
||||
}
|
||||
Message({
|
||||
message: error.message,
|
||||
message: msg,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
|
||||
@@ -57,8 +57,8 @@ module.exports = {
|
||||
proxy: {
|
||||
'/api': {
|
||||
// 可以通过环境变量 VUE_APP_API_BASE_URL 来配置后端地址
|
||||
// 例如: VUE_APP_API_BASE_URL=http://localhost:8090 npm run dev
|
||||
target: process.env.VUE_APP_API_BASE_URL || 'http://localhost:8090', // 本地后端服务器地址
|
||||
// 例如: VUE_APP_API_BASE_URL=http://localhost:8091 npm run dev
|
||||
target: process.env.VUE_APP_API_BASE_URL || 'http://localhost:8091', // 本地后端服务器地址
|
||||
// target: 'https://api.huayang-star.com/', // 生产环境后端地址
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
|
||||
Reference in New Issue
Block a user