1.链接接口联调

sws 2024-08-20
v1.0.0
sws 2024-08-20 18:46:11 +08:00
parent ebc44e37b6
commit 10ed9418ef
2 changed files with 3 additions and 1 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ node_modules
dist
src/types/auto-imports.d.ts
src/types/components.d.ts
src/types/temp.d.ts
dist-ssr
coverage
*.local

View File

@ -1,6 +1,7 @@
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
import { ElMessage, ElMessageBox } from 'element-plus';
import { get_cookie } from './index';
import temp_token from '@/types/temp.d';
// 创建 axios 实例
const index = window.location.href.lastIndexOf('?s=');
const pro_url = window.location.href.substring(0, index);
@ -15,7 +16,7 @@ service.interceptors.request.use(
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
const cookie = get_cookie('admin_info');
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
config.url = config.url + '?token=' + 'e1bd7d4c5e94c2680c359a982896e524';
config.url = config.url + '?token=' + temp_token;
} else {
if (cookie) {
config.url = config.url + '&token=' + JSON.parse(cookie).token;