刘琳琳 преди 4 месеца
родител
ревизия
338655de93
променени са 5 файла, в които са добавени 36 реда и са изтрити 30 реда
  1. 1 4
      public/config.js
  2. 5 1
      src/utils/getWebSocket.js
  3. 17 17
      src/utils/request.js
  4. 1 1
      src/views/white_list/index.vue
  5. 12 7
      vue.config.js

+ 1 - 4
public/config.js

@@ -1,6 +1,3 @@
 window.g = {
-  // ApiUrl: 'https://test.hz-hanghui.com:18890/yx-fyzd', //测试
-  // ApiUrl: 'https://tx.hz-hanghui.com:8088/yx-fyzd', //线上
-  ApiUrl: 'http://192.168.77.65:9100/yx-fyzd', //本地
-  wsPath: 'wss://test.hz-hanghui.com:18890/websocket?token=',
+  ApiUrl: '/yx-fyzd', //本地
 }

+ 5 - 1
src/utils/getWebSocket.js

@@ -2,7 +2,11 @@ import { getToken } from '@/utils/auth'
 import store from '../store'
 import { Message } from 'element-ui'
 // let server = "wss://hhomc.hz-hanghui.com:18096/websocket?token=" + getToken();
-const server = window.g.wsPath + getToken() + '&source=TQ'
+let wsServer = `${location.protocol === 'https' ? 'wss' : 'ws'}://${location.hostname}:18089/websocket`
+// window.g.wsPath 端口
+// wss://test.hz-hanghui.com:18890/websocket?token=
+console.log(wsServer)
+const server = wsServer + '?token=' + getToken() + '&source=TQ'
 export let ws = {}
 let lockReconnect = false // 避免ws重复连接
 let count = 0 // 记录计数

+ 17 - 17
src/utils/request.js

@@ -4,17 +4,17 @@ import store from '@/store'
 import { getToken } from '@/utils/auth'
 import { waitLogOut } from '@/utils/waitLogOut'
 
-let start = 0;
+let start = 0
 function showErr(res, duration) {
-    let now = Date.now();
-    if(now - start > duration) {
-      start = now
-      Message({
-        message: res.msg || '出错啦~',
-        type: 'error',
-        duration: 5 * 1000
-      })
-    }
+  const now = Date.now()
+  if (now - start > duration) {
+    start = now
+    Message({
+      message: res.msg || '出错啦~',
+      type: 'error',
+      duration: 5 * 1000
+    })
+  }
 }
 
 const baseURLStr = window.g.ApiUrl
@@ -24,7 +24,7 @@ const service = axios.create({
   baseURL: baseURLStr, // url = base url + request url
   // baseURL:process.env.VUE_APP_BASE_API,
   // withCredentials: true, // send cookies when cross-domain requests
-  timeout:5* 60*60*60*1000 // request timeout
+  timeout: 5 * 60 * 60 * 60 * 1000 // request timeout
   // timeout: 200000 // request timeout
 })
 
@@ -32,7 +32,7 @@ const service = axios.create({
 service.interceptors.request.use(
   config => {
     // 超过三十分钟无操作自动退出登录
-    waitLogOut();
+    waitLogOut()
 
     // do something before request is sent
 
@@ -68,7 +68,7 @@ service.interceptors.response.use(
     const res = response.data
 
     // if the custom code is not 20000, it is judged as an error.
-    if (res.code&&res.code !== 200) {
+    if (res.code && res.code !== 200) {
       if (res.code === 401) {
         // to re-login
         MessageBox.confirm('您的登录状态已经过期啦,请重新登录吧~', '温馨提示', {
@@ -86,7 +86,7 @@ service.interceptors.response.use(
       return Promise.reject(new Error(res.msg || '出错啦~'))
     } else {
       return res
-    };
+    }
   },
   error => {
     console.log('err' + error) // for debug
@@ -100,13 +100,13 @@ service.interceptors.response.use(
 )
 
 function showErrorMessage(res) {
-  return function () {
+  return function() {
     Message({
-      message: '出错啦'||res.msg || '出错啦~',
+      message: '出错啦' || res.msg || '出错啦~',
       type: 'error',
       duration: 5 * 1000
     })
   }
-};
+}
 
 export default service

+ 1 - 1
src/views/white_list/index.vue

@@ -463,7 +463,7 @@
           {{ scope.row.createTime | matchNull }}
         </template>
       </el-table-column>-->
-      <el-table-column v-if="!multipleChoice" key="action" align="center" prop="" label="操作区" width="260">
+      <el-table-column v-if="!multipleChoice" key="action" align="center" prop="" label="操作区" width="380">
         <template slot-scope="scope">
           <el-button
             v-if="checkRole([1, 2, 5, 99])"

+ 12 - 7
vue.config.js

@@ -22,18 +22,23 @@ module.exports = {
    * In most cases please use '/' !!!
    * Detail: https://cli.vuejs.org/config/#publicpath
    */
-  publicPath:'',// '/ywjl-fyzd/back',// '/yx-fyzd/back',
+  publicPath: '', // '/ywjl-fyzd/back',// '/yx-fyzd/back',
   outputDir: 'back',
   assetsDir: 'static',
   lintOnSave: process.env.NODE_ENV === 'development',
   productionSourceMap: false,
   devServer: {
-    port: port,
+    // port: port,
     open: true,
-    overlay: {
-      warnings: false,
-      errors: true
-    },
+    // overlay: {
+    //   warnings: false,
+    //   errors: true
+    // },
+    proxy: {
+      '/yx-fyzd': {
+        target: 'https://tx.hz-hanghui.com:8088'
+      }
+    }
     // 关闭mock
     // before: require('./mock/mock-server.js')
   },
@@ -44,7 +49,7 @@ module.exports = {
     name: name,
     resolve: {
       alias: {
-        '@': resolve('src'),
+        '@': resolve('src')
       }
     }
   },