Kaynağa Gözat

Merge branch 'xiaohb' into scene_conversion_ms

James 4 yıl önce
ebeveyn
işleme
ee24bf3bcb
3 değiştirilmiş dosya ile 23 ekleme ve 3 silme
  1. 1 1
      package.json
  2. 3 1
      src/pages/list/index.vue
  3. 19 1
      src/util/http.js

+ 1 - 1
package.json

@@ -5,7 +5,7 @@
   "author": "zhibin <854556519@qq.com>",
   "private": true,
   "scripts": {
-    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
+    "dev": "webpack-dev-server --inline --progress --host 0.0.0.0 --config build/webpack.dev.conf.js",
     "start": "npm run dev",
     "unit": "jest --config test/unit/jest.conf.js --coverage",
     "e2e": "node test/e2e/runner.js",

+ 3 - 1
src/pages/list/index.vue

@@ -285,15 +285,17 @@ export default {
       });
     },
     sceneCodeSendHttp() {
-      let { sceneCode, description } = this.form;
+      let { sceneCode, description,sceneTitle } = this.form;
       let body = {
         description,
         sceneCode,
+        sceneTitle
       };
       this.$http.post("/manage/scene/download", body).then((res) => {
         this.$message(res["msg"]);
         if (res["code"] === 0) {
           console.log("下载成功");
+          this.getScenes()
           this.dialogFormVisible = false;
         } else {
         }

+ 19 - 1
src/util/http.js

@@ -7,13 +7,31 @@ const serverName = isProduction ? '' : ''
 // const serverName = isProduction ? '' : 'http://192.168.0.135:8105'
 
 const vue = new Vue()
-
+const notTokenApis = ['/api/sso/user/login']
 axios.defaults.baseURL = serverName
 axios.defaults.headers['X-Requested-with'] = 'XMLHttpRequest'
 
 // 拦截请求,做登陆,或head处理
 axios.interceptors.request.use(
   function (config) {
+    const token = localStorage.getItem('cjt_token')
+  if (token) {
+    config.headers['token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
+  } 
+  else if(notTokenApis.includes(config.url)) {
+    console.log('不用token校验的api')
+  }
+  else{
+    vue.$alert('登录状态失效,请重新登录', '提示', {
+      confirmButtonText: '确定',
+      callback: function () {
+        window.localStorage.setItem('userInfo', '')
+        router.push('/login')
+      }
+    })
+  }
+
+
     if (config.method === 'post') {
       config.data.rnd = Math.random()
     }