|
@@ -2,7 +2,7 @@
|
|
import axios from 'axios'
|
|
import axios from 'axios'
|
|
import { message } from 'antd'
|
|
import { message } from 'antd'
|
|
import { beforeRequest, handleRequestError, handleResponseSuccess, handleResponseError } from '@/apis/hook'
|
|
import { beforeRequest, handleRequestError, handleResponseSuccess, handleResponseError } from '@/apis/hook'
|
|
-import { auth } from '@/conf/config'
|
|
|
|
|
|
+import { dc } from '@/conf/config'
|
|
import getRealUrl from '@/utils/getRealUrl'
|
|
import getRealUrl from '@/utils/getRealUrl'
|
|
|
|
|
|
function getPrefix () {
|
|
function getPrefix () {
|
|
@@ -13,6 +13,19 @@ function getPrefix () {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 截取路径
|
|
|
|
+function getPathFromUrl (str, keyword = '/') {
|
|
|
|
+ let index = str.indexOf(keyword)
|
|
|
|
+ let num = 0
|
|
|
|
+ while (index !== -1 && num < 2) {
|
|
|
|
+ // console.log(index)//打印出a的索引
|
|
|
|
+ num++// 记录出现的次数
|
|
|
|
+ index = str.indexOf(keyword, index + 1)
|
|
|
|
+ }
|
|
|
|
+ // return index
|
|
|
|
+ return str.slice(index)
|
|
|
|
+}
|
|
|
|
+
|
|
export const request = axios.create({
|
|
export const request = axios.create({
|
|
baseURL: `${getPrefix()}`,
|
|
baseURL: `${getPrefix()}`,
|
|
timeout: 5000,
|
|
timeout: 5000,
|
|
@@ -66,7 +79,7 @@ async function authRequest ({ method, url, params, data }) {
|
|
}
|
|
}
|
|
} = await request({
|
|
} = await request({
|
|
method: 'get',
|
|
method: 'get',
|
|
- url: `${auth}/common/token?url=${encodeURIComponent(getRealUrl(url))}`,
|
|
|
|
|
|
+ url: `${dc}/api/common/token?url=${encodeURIComponent(getPathFromUrl(getRealUrl(url)))}`,
|
|
params: {}
|
|
params: {}
|
|
})
|
|
})
|
|
if (code === 0) {
|
|
if (code === 0) {
|