陈少旭 5 miesięcy temu
rodzic
commit
0f51b03b2d
3 zmienionych plików z 8 dodań i 9 usunięć
  1. 1 2
      .env.development
  2. 6 6
      src/http/index.js
  3. 1 1
      src/utils/request.js

+ 1 - 2
.env.development Wyświetl plik

@@ -1,6 +1,5 @@
1 1
 ## base API 开发环境
2 2
 # VUE_APP_BASE_API = 'sf.sgjyun.com'
3
-# VUE_APP_BASE_API = 'http://127.0.0.1:9788'
4
-
5 3
 # NODE_ENV = 'development' http://127.0.0.1:9788
6 4
 # BASE_URL = "http://localhost:8080/admin-vue/"
5
+

+ 6 - 6
src/http/index.js Wyświetl plik

@@ -6,22 +6,22 @@ import QS from 'qs'
6 6
 // 创建axios实例
7 7
 const service = axios.create({
8 8
   // 'http://127.0.0.1:9788'  process.env.VUE_APP_BASE_API 'sf.sgjyun.com'
9
-    // baseURL: process.env.VUE_APP_BASE_API , //URL地址   环境变量文件 
10
-    baseURL: 'http://127.0.0.1:9788',
9
+    baseURL: process.env.VUE_APP_BASE_API , //URL地址   环境变量文件
10
+    // baseURL: 'http://127.0.0.1:9788',
11 11
     timeout: 5000 ,//超时
12 12
     withCredentials: true,  //跨域时若要发生cookie,需要设置该选项
13 13
 })
14 14
 console.log('service',process.env.VUE_APP_BASE_API);
15 15
 // 请求拦截器
16 16
 service.interceptors.request.use(
17
-  
17
+
18 18
     config => {
19 19
       // sessionStorage.setItem('username',userInfo.account)
20 20
       // sessionStorage.setItem('password',userInfo.password)
21 21
       const username = window.sessionStorage.getItem('username')
22 22
       const password = window.sessionStorage.getItem('password')
23 23
       // console.log('sessionStorage.getItem',username,password,config.url);
24
-     
24
+
25 25
       if (config.method == 'post' ) {
26 26
         config.data = {
27 27
           ...config.data,
@@ -62,7 +62,7 @@ service.interceptors.response.use(
62 62
             //     type: 'error',
63 63
             //     duration: 5*1000
64 64
             // })
65
-        
65
+
66 66
 
67 67
             // 假设 10008 非法令牌  10012 其他客户端已经登陆
68 68
             // if(res.code === 10008 || res.code === 10012){
@@ -99,4 +99,4 @@ service.interceptors.response.use(
99 99
     }
100 100
 )
101 101
 console.log('33333');
102
-export default service;
102
+export default service;

+ 1 - 1
src/utils/request.js Wyświetl plik

@@ -18,7 +18,7 @@ import store from '@/store'
18 18
 
19 19
 // create an axios instance
20 20
 const service = axios.create({
21
-  baseURL: 'http://127.0.0.1:9788', // api的base_url
21
+  baseURL: process.env.VUE_APP_BASE_API, // api的base_url
22 22
   timeout: 3000000, // request timeout
23 23
   withCredentials: true
24 24
 })