Browse Source

host参数

pull/102/head
pengda 4 weeks ago
parent
commit
201569b10a
  1. 3
      .env.development
  2. 3
      .env.production
  3. 2
      src/main.js
  4. 4
      src/utils/loginRefresh.js
  5. 3
      src/utils/request.js

3
.env.development

@ -1 +1,2 @@
VUE_APP_BASE_API=http://agentnew.pengda.checkcopy.com/api
VUE_APP_BASE_API=http://agentnew.pengda.checkcopy.com/api
VUE_APP_HOST=//agentnew.pengda.checkcopy.com

3
.env.production

@ -1 +1,2 @@
VUE_APP_BASE_API=http://admin.kuailelunwen.com/api
VUE_APP_BASE_API=//admin.kuailelunwen.com/api
VUE_APP_HOST=//admin.kuailelunwen.com

2
src/main.js

@ -24,8 +24,6 @@ Vue.prototype.$copy = modernCopyToClipboard;
Vue.prototype.$loadingFn = LoadingService;
Vue.config.productionTip = false;
// 请求
import { host } from '@/config/host';
Vue.prototype.$host = host
Vue.prototype.$http = request;
Vue.prototype.$token = ''
Vue.use(ElementUI);

4
src/utils/loginRefresh.js

@ -1,5 +1,3 @@
import { host } from '@/config/host';
let isRefreshing = false
let refreshSubscribers = []
@ -42,7 +40,7 @@ export async function handleTokenRefresh(originalRequest, instance) {
isRefreshing = false
refreshSubscribers = []
localStorage.removeItem('token')
window.location.href = host;
window.location.href = process.env.VUE_APP_BASE_API;
return Promise.reject(err)
}
}

3
src/utils/request.js

@ -1,7 +1,6 @@
// src/utils/request.js
import axios from "axios";
import { handleTokenRefresh } from '@/utils/loginRefresh';
import { host } from '@/config/host';
// 创建 axios 实例
const service = axios.create({
@ -53,7 +52,7 @@ service.interceptors.response.use(
switch (error.response.status) {
case 401:
// 未授权,跳转到登录页
window.location.href = host;
window.location.href = process.env.VUE_APP_HOST;
break;
case 402:
// token失效

Loading…
Cancel
Save