瀏覽代碼

修改环境变量

yangbifan 2 年之前
父節點
當前提交
430c0a988a
共有 5 個文件被更改,包括 50 次插入51 次删除
  1. 1 4
      public/index.html
  2. 3 4
      src/assets/js/http.js
  3. 2 3
      src/config/dev.js
  4. 44 32
      src/http/index.js
  5. 0 8
      vue.config.js

+ 1 - 4
public/index.html

@@ -31,10 +31,7 @@
   <div id="app"></div>
   <!-- built files will be auto injected -->
   <script type="text/javascript">
-    // window.staticHost = 'http://10.230.26.15:8000/mkt'; // 正式
-    // window.staticHost = 'http://10.149.85.91:8000/spfm'; // 测试
-    // window.staticHost = 'http://192.168.0.103:9600/';
-    window.staticHost = 'http://43.138.50.94:9600/';
+
 
     // document.title = "hello";
   </script>

+ 3 - 4
src/assets/js/http.js

@@ -1,4 +1,4 @@
-
+
 import axios from 'axios'
 import common from "./common.js";
 import vue from '../../components/common/bus';
@@ -9,13 +9,12 @@ axios.defaults.headers.post['Content-Type'] = 'application/json';//'multipart/fo
 // http response 拦截器
 axios.interceptors.response.use(
   response => {
-    console.log(123);
+    console.log('奇奇怪怪的网络请求');
     //vue.$store.commit('endLoading');
     if(response.config.url.indexOf('8880')!=-1 || response.config.url.indexOf('8099')!=-1){
-      console.log(response);
+
       return response.data;
     }else{
-      console.log(response);
       return response;
       
     }

+ 2 - 3
src/config/dev.js

@@ -2,13 +2,13 @@
 let devs = {
     TITLE:'本地环境',
     BASE_URL:"http://43.138.50.94:9600/", //本地环境
-    BASE_API:"http://43.138.50.94:8888",//工作流本地环境
+    BASE_API:"http://43.138.50.94:8880",//工作流本地环境
     EXCEL_URL:"http://43.138.50.94:7777" //本地excel路径
 }
 let dev = {
     TITLE:'本地环境',
     BASE_URL:"http://127.0.0.1:8080", //本地环境
-    BASE_API:"http://43.138.50.94:8888",//工作流本地环境
+    BASE_API:"http://43.138.50.94:8880",//工作流本地环境
     EXCEL_URL:"http://43.138.50.94:7777" //本地excel路径
 }
 let test = {
@@ -24,7 +24,6 @@ let prod = {
     EXCEL_URL:"http://10.230.26.15:7777" //线上excel路径
 }
 export const getConfig  = () =>{
-    console.log(process.env.NODE_ENV === 'development');
     switch(process.env.NODE_ENV){
         case "development":
             return dev;

+ 44 - 32
src/http/index.js

@@ -3,6 +3,12 @@ import axios from 'axios';
 import VueAxios from 'vue-axios';
 import getConfig from '../config/dev.js'
 let list = getConfig()
+const status = (res) => {
+    let regexp = /8880/
+    let r = regexp.test(res)
+
+    return r;
+}
 // axios.defaults.headers.post['Content-Type'] = 'application/json';
 axios.defaults.transformRequest = [function (data) {
     if (data instanceof Object && !(data instanceof FormData)) {
@@ -11,41 +17,47 @@ axios.defaults.transformRequest = [function (data) {
     return data;
 }],
 
-axios.defaults.baseURL = list.BASE_URL
-    // 添加请求拦截器
-    axios.interceptors.request.use(function (config) {
-        // console.log('[ axios.config ] >', config)
-        // if (config.url.startsWith("http")) {
-        //     return config;
-        // }
-        // let localhost = ''
-        // if (process.env.NODE_ENV == "production") {
-        //     localhost = window.staticHost ? window.staticHost : "/spfm/"
-        // }
-        // console.log('[ axios.localhost ] >', localhost)
-        // config.url = localhost + config.url
-        // let url = localhost + config.url
-        // console.log('[ axios.url ] >', url)
-        console.log(list.BASE_URL);
-        if (list.BASE_URL.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && list.BASE_URL.indexOf('/sysmgr/sys/login/auth/token') == -1) {
-            let token = window.sessionStorage.agileauthtoken;
-            if (token != undefined && token != 'undefined') {
-                token = JSON.parse(token);
+    axios.defaults.baseURL = list.BASE_URL
+// 添加请求拦截器
+axios.interceptors.request.use(function (config) {
+
+    var n = status(config.url)
+
+    // console.log('[ axios.config ] >', config)
+    // if (config.url.startsWith("http")) {
+    //     return config;
+    // }
+    // let localhost = ''
+    // if (process.env.NODE_ENV == "production") {
+    //     localhost = window.staticHost ? window.staticHost : "/spfm/"
+    // }
+    // console.log('[ axios.localhost ] >', localhost)
+    // config.url = localhost + config.url
+    // let url = localhost + config.url
+    // console.log('[ axios.url ] >', url)
+
+    if (list.BASE_URL.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && list.BASE_URL.indexOf('/sysmgr/sys/login/auth/token') == -1) {
+        let token = window.sessionStorage.agileauthtoken;
+        if (token != undefined && token != 'undefined') {
+            token = JSON.parse(token);
+            if (n === false) {
                 config.headers['agileauthtoken'] = token
-            } else {
-                global.$vm.$notify.error({
-                    title: '提示',
-                    message: '登录超时'
-                })
-                global.$vm.$router.push('/login')
             }
+
+        } else {
+            global.$vm.$notify.error({
+                title: '提示',
+                message: '登录超时'
+            })
+            global.$vm.$router.push('/login')
         }
-        // 在发送请求之前做些什么
-        return config;
-    }, function (error) {
-        // 对请求错误做些什么
-        return Promise.reject(error);
-    });
+    }
+    // 在发送请求之前做些什么
+    return config;
+}, function (error) {
+    // 对请求错误做些什么
+    return Promise.reject(error);
+});
 
 
 // // 添加响应拦截器

+ 0 - 8
vue.config.js

@@ -124,14 +124,6 @@ module.exports = {
                     "^/market": "",
                 },
             },
-            "/api": {
-                target: "http://43.138.50.94:8888",
-                ws: false,
-                changeOrigin: true,
-                pathRewrite: {
-                    "^/api": "",
-                },
-            },
             // 开发环境变化可注释 ⬆️⬆️
             "/": {
                 // target: 'http://192.168.2.145:9600/spfm',