修正开发环境和远程生产环境切换的bug。
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* 自动添加 tenantId、token 等公共参数
|
||||
*/
|
||||
|
||||
import { getApiUrl } from './config.js'
|
||||
import { getApiUrl, getApiEnv } from './config.js'
|
||||
|
||||
/**
|
||||
* 获取 tenantId(从本地存储)
|
||||
@@ -55,6 +55,11 @@ export function request(options = {}) {
|
||||
|
||||
// 处理 URL(自动添加 baseUrl)
|
||||
const fullUrl = url.startsWith('http') ? url : getApiUrl(url)
|
||||
const apiEnv = typeof getApiEnv === 'function' ? getApiEnv() : ''
|
||||
|
||||
// 每次请求打印完整 URL,格式示例:
|
||||
// H5环境(local)直接使用完整URL: http://localhost:8090/api/audioManagement/list
|
||||
console.log(`H5环境(${apiEnv})直接使用完整URL: ${fullUrl}`)
|
||||
|
||||
// 构建请求头
|
||||
const requestHeader = {
|
||||
@@ -88,7 +93,7 @@ export function request(options = {}) {
|
||||
// 发起请求
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: finalUrl,
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
data: requestData,
|
||||
header: requestHeader,
|
||||
@@ -99,7 +104,7 @@ export function request(options = {}) {
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[Request] 请求失败:', {
|
||||
url: finalUrl,
|
||||
url: fullUrl,
|
||||
method: method.toUpperCase(),
|
||||
error: err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user