yangbifan 2 rokov pred
rodič
commit
236f467777

+ 4 - 1
.env.development

@@ -1,2 +1,5 @@
 VUE_APP_FILE_API = http://192.168.1.9:9114
-VUE_APP_GRID_API = http://192.168.1.19:9114
+VUE_APP_GRID_API = http://192.168.1.19:9114
+NODE_ENV = 'development'
+
+VUE_APP_ENV = 'development'

+ 5 - 1
.env.production

@@ -1,2 +1,6 @@
 VUE_APP_FILE_API =
-VUE_APP_GRID_API =
+VUE_APP_GRID_API =
+
+NODE_ENV = 'production'
+
+VUE_APP_ENV = 'production'

+ 3 - 0
.env.test

@@ -0,0 +1,3 @@
+NODE_ENV = 'test'
+
+VUE_APP_ENV = 'test'

+ 0 - 0
config/config.js


+ 5 - 2
package.json

@@ -3,8 +3,11 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build",
+    "serve": "vue-cli-service serve --mode development", 
+    "serve:test": "vue-cli-service serve --mode test", 
+    "build": "vue-cli-service build  --mode development", 
+    "build:test": "vue-cli-service build  --mode test",
+    "build:next": "vue-cli-service build  --mode production", 
     "lint": "vue-cli-service lint",
     "analyz": "vue-cli-service build"
   },

+ 1 - 1
public/index.html

@@ -31,7 +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.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/';

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

@@ -9,11 +9,15 @@ axios.defaults.headers.post['Content-Type'] = 'application/json';//'multipart/fo
 // http response 拦截器
 axios.interceptors.response.use(
   response => {
+    console.log(123);
     //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;
+      
     }
   },
   error => {

+ 32 - 0
src/config/dev.js

@@ -0,0 +1,32 @@
+'use strict'
+let dev = {
+    TITLE:'本地环境',
+    BASE_URL:"http://43.138.50.94:9600/", //本地环境
+    BASE_API:"http://43.138.50.94:8880",//工作流本地环境
+}
+let test = {
+    TITLE:'测试环境',
+    BASE_URL:"http://10.149.85.91:8000/spfm", //测试环境
+    BASE_API:"http://10.149.85.91:8000",//工作流测试环境
+}
+let prod = {
+    TITLE:'线上环境',
+    BASE_URL:"http://10.230.26.15:8000/mkt", //线上环境
+    BASE_API:"http://10.230.26.15:8000",//工作流线上环境
+}
+export const getConfig  = () =>{
+    console.log(process.env.NODE_ENV === 'development');
+    switch(process.env.NODE_ENV){
+        case "development":
+            return dev;
+        case 'test':
+            return test;
+        case 'production':
+            return prod
+    }
+}
+export default getConfig;
+
+// 根据环境引入不同配置 process.env.ENV_CONFIG  ex:dev.conf.js
+
+// module.exports = config

+ 18 - 10
src/http/index.js

@@ -1,6 +1,8 @@
 import Vue from 'vue';
 import axios from 'axios';
 import VueAxios from 'vue-axios';
+import getConfig from '../config/dev.js'
+let list = getConfig()
 // axios.defaults.headers.post['Content-Type'] = 'application/json';
 axios.defaults.transformRequest = [function (data) {
     if (data instanceof Object && !(data instanceof FormData)) {
@@ -8,18 +10,24 @@ axios.defaults.transformRequest = [function (data) {
     }
     return data;
 }],
+
+axios.defaults.baseURL = list.BASE_URL
     // 添加请求拦截器
     axios.interceptors.request.use(function (config) {
-        if (config.url.startsWith("http")) {
-            return config;
-        }
-        let localhost = ''
-        if (process.env.NODE_ENV == "production") {
-            localhost = window.staticHost ? window.staticHost : "/spfm/"
-        }
-        config.url = localhost + config.url
-        let url = localhost + config.url
-        if (url.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && url.indexOf('/sysmgr/sys/login/auth/token') == -1) {
+        // 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);

+ 1 - 0
src/pages/main/leader/demand/demandHome.vue

@@ -139,6 +139,7 @@
   </div>
 </template>
 <script>
+
 import Workflow from "../../../../components/workflow";
 import WorkflowEntrance from "../../../../components/workflowEntrance";
 import FormTable from "../components/formTable.vue";

+ 2 - 0
src/pages/main/leader/leaderHome.vue

@@ -53,6 +53,7 @@
   </div>
 </template>
 <script>
+import {getConfig} from '../../../../config/config.js'
 import ProcessingInstruction from "./leaderHprocess.vue";
 import hometask from "./leaderhomeTask.vue";
 import numberhits from "./numberHits.vue";
@@ -208,6 +209,7 @@ export default {
     },
   },
   mounted() {
+    this.getConfig()
     this.getpeo();
     this.getNotice();
     this.getTags();

+ 4 - 0
src/pages/main/leader/leaderhomeTask.vue

@@ -278,6 +278,7 @@
   </div>
 </template>
 <script>
+import { getConfig } from '../../../config/dev.js'
 export default {
   components: {},
   // props:["tableDatayj","niticList"],
@@ -658,6 +659,9 @@ export default {
     },
   },
   mounted() {
+    let list = getConfig()
+    console.log(list);
+    
     this.daiban({}, 1);
     this.getListyj({}, 1);
     this.getOPlist({}, 1);

+ 1 - 1
src/plugins/element-ui.js

@@ -131,7 +131,7 @@ Vue.use(Alert)
 Vue.use(InputNumber)
 Vue.use(Rate)
 Vue.use(Progress)
-Vue.prototype.$confirm = MessageBox.confirm;
+// Vue.prototype.$confirm = MessageBox.confirm;
 Vue.prototype.$prompt = MessageBox.prompt;
 Vue.prototype.$notify = Notification;
 Vue.prototype.$message = Message;