pk优化版
This commit is contained in:
@@ -4,27 +4,26 @@
|
||||
*/
|
||||
import axios from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ENV } from '@/config'
|
||||
|
||||
// 创建独立的 axios 实例
|
||||
const pkAxios = axios.create({
|
||||
baseURL: 'http://192.168.2.22:8086/',
|
||||
// baseURL: 'https://pk.hanxiaokj.cn/',
|
||||
baseURL: ENV.PK_MINI_API_URL + '/',
|
||||
timeout: 60000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
// 请求拦截器 - 使用主项目的 vvtoken
|
||||
// 请求拦截器 - PK Mini 后端使用 vvtoken 请求头
|
||||
pkAxios.interceptors.request.use((config) => {
|
||||
// 优先使用 vvtoken
|
||||
const vvtoken = localStorage.getItem('token')
|
||||
if (vvtoken) {
|
||||
config.headers['vvtoken'] = vvtoken
|
||||
const token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
config.headers['vvtoken'] = token
|
||||
} else {
|
||||
// 兼容:尝试从 user_data 获取
|
||||
const userData = JSON.parse(localStorage.getItem('user_data') || '{}')
|
||||
if (userData.token) {
|
||||
if (userData.tokenValue) {
|
||||
config.headers['vvtoken'] = userData.tokenValue
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user