소스 검색

fix:处理token失效后无法退出问题

chenjiaxin 2 주 전
부모
커밋
0e6e9ed2a1
5개의 변경된 파일57개의 추가작업 그리고 57개의 파일을 삭제
  1. 5 4
      src/utils/request.js
  2. 6 3
      src/utils/requestAuth.js
  3. 5 4
      src/utils/requestSys.js
  4. 40 21
      src/views/video/oral-video.vue
  5. 1 25
      vue.config.js

+ 5 - 4
src/utils/request.js

@@ -1,7 +1,8 @@
 import axios from 'axios'
 import { Message, MessageBox } from 'element-ui'
 import store from '../store'
-import { getToken } from '@/utils/auth'
+import { getToken, removeToken } from '@/utils/auth'
+import { resetRouter } from '@/router'
 
 // 创建axios实例
 const service = axios.create({
@@ -46,9 +47,9 @@ service.interceptors.response.use(
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          store.dispatch('FedLogOut').then(() => {
-            location.reload() // 为了重新实例化vue-router对象 避免bug
-          })
+          removeToken();
+          resetRouter();
+          location.reload()
         })
       } else {
         return Promise.reject('error');

+ 6 - 3
src/utils/requestAuth.js

@@ -1,7 +1,8 @@
 import axios from 'axios'
 import { Message, MessageBox } from 'element-ui'
 import store from '../store'
-import { getToken } from '@/utils/auth'
+import { getToken, removeToken } from '@/utils/auth'
+import { resetRouter } from '@/router'
 
 //忽略报错的连接
 const ignoreMessage = ["/autoparts/pimCatentry/getProductAttr"];
@@ -45,7 +46,6 @@ service.interceptors.response.use(
       if (typeof (res) == "string") {
         res = JSON.parse(res)
       }
-      //console.log(res);
       // 用户模块
       if (res.code === 401) {
         Message.closeAll();
@@ -54,7 +54,10 @@ service.interceptors.response.use(
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          store.dispatch('user/logout').then(() => { location.reload() })
+          removeToken();
+          resetRouter();
+          location.reload()
+          // store.dispatch('user/logout').then(() => { location.reload() })
         })
       } else {
         return Promise.reject(response.data);

+ 5 - 4
src/utils/requestSys.js

@@ -1,7 +1,8 @@
 import axios from 'axios'
 import { Message, MessageBox } from 'element-ui'
 import store from '../store'
-import { getToken } from '@/utils/auth'
+import { getToken, removeToken } from '@/utils/auth'
+import { resetRouter } from '@/router'
 
 // 创建axios实例
 const service = axios.create({
@@ -46,9 +47,9 @@ service.interceptors.response.use(
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          store.dispatch('FedLogOut').then(() => {
-            location.reload() // 为了重新实例化vue-router对象 避免bug
-          })
+          removeToken();
+          resetRouter();
+          location.reload()
         })
       } else {
         return Promise.reject('error');

+ 40 - 21
src/views/video/oral-video.vue

@@ -83,13 +83,22 @@
           prop="videoCoverImageUrl"
         >
           <template slot-scope="scope">
-            <div v-if="scope.row.videoCoverImageUrl" class="video" @click="handlePlay(scope.row)">
+            <div
+              v-if="scope.row.videoCoverImageUrl"
+              class="video"
+              @click="handlePlay(scope.row)"
+            >
               <img :src="scope.row.videoCoverImageUrl" class="video-img" />
               <i class="el-icon-video-play" />
             </div>
           </template>
         </el-table-column>
-        <el-table-column label="SKU" min-width="100" align="center" prop="sku" />
+        <el-table-column
+          label="SKU"
+          min-width="100"
+          align="center"
+          prop="sku"
+        />
 
         <el-table-column
           label="SKUID"
@@ -103,12 +112,15 @@
           align="center"
           prop="reviewStatus"
         >
-         <template slot-scope="scope">
-            <span class="status-tag" :class="{
-              'status-pending': scope.row.reviewStatus === 0,
-              'status-success': scope.row.reviewStatus === 1,
-              'status-error': scope.row.reviewStatus === 2
-            }"></span>
+          <template slot-scope="scope">
+            <span
+              class="status-tag"
+              :class="{
+                'status-pending': scope.row.reviewStatus === 0,
+                'status-success': scope.row.reviewStatus === 1,
+                'status-error': scope.row.reviewStatus === 2
+              }"
+            ></span>
             {{ getValueByKey(scope.row.reviewStatus, auditStatus) }}
           </template>
         </el-table-column>
@@ -132,11 +144,14 @@
           prop="publishStatus"
         >
           <template slot-scope="scope">
-            <span class="status-tag" :class="{
-              'status-pending': scope.row.publishStatus === 0,
-              'status-success': scope.row.publishStatus === 1,
-              'status-error': scope.row.publishStatus === 2
-            }"></span>
+            <span
+              class="status-tag"
+              :class="{
+                'status-pending': scope.row.publishStatus === 0,
+                'status-success': scope.row.publishStatus === 1,
+                'status-error': scope.row.publishStatus === 2
+              }"
+            ></span>
             {{ getValueByKey(scope.row.publishStatus, auditStatus) }}
           </template>
         </el-table-column>
@@ -202,7 +217,7 @@
           label="操作"
           align="center"
           min-width="250"
-          v-bind="device !== 'mobile' ? {fixed: 'right'} : {  }"
+          v-bind="device !== 'mobile' ? { fixed: 'right' } : {}"
         >
           <template slot-scope="scope">
             <div class="button">
@@ -278,7 +293,7 @@ export default {
     VideoPlayer
   },
   computed: {
-    ...mapGetters(['device']) // 从 vuex 中获取设备类型
+    ...mapGetters(["device"]) // 从 vuex 中获取设备类型
   },
   data() {
     return {
@@ -290,7 +305,7 @@ export default {
       downloadingRows: {},
       listQuery: {
         page: 1,
-        limit: 20,
+        limit: 10,
         videoTitle: null
       },
       currentVideoUrl: null,
@@ -392,6 +407,14 @@ export default {
   display: flex;
   align-content: center;
   justify-content: center;
+  &:hover {
+    i {
+      opacity: 1;
+    }
+    .video-img {
+      opacity: 0.6;
+    }
+  }
   &-img {
     width: 60px;
     height: 60px;
@@ -408,12 +431,9 @@ export default {
     transform: translate(-50%, -50%);
     font-size: 20px;
     font-weight: bold;
-    color: #ae8877;
+    color: #fff;
     opacity: 0;
     cursor: pointer;
-    &:hover {
-      opacity: 1;
-    }
   }
 }
 
@@ -437,4 +457,3 @@ export default {
   background-color: #f56c6c;
 }
 </style>
-</style>

+ 1 - 25
vue.config.js

@@ -19,7 +19,6 @@ module.exports = {
   productionSourceMap: false, // 生产环境是否生成 sourceMap 文件
   devServer: {
     port: port,
-    // host: "swings.pim.com",
     // open: true,
     overlay: {
       warnings: false,
@@ -27,30 +26,7 @@ module.exports = {
     },
     public: "0.0.0.0:9557", //可以实现热部署
     proxy: {
-      // [process.env.VUE_APP_OAUTH_API]: {
-      //   target: `http://localhost:19090/sso`,
-      //   changeOrigin: true,
-      //   // logLevel: 'debug', //打印日志
-      //   pathRewrite: {
-      //     ['^' + process.env.VUE_APP_OAUTH_API]: ''
-      //   }
-      // },
-      // [process.env.VUE_APP_PIM_API]: {
-      //   target: `http://localhost:18080/pim`,
-      //   changeOrigin: true,
-      //   // logLevel: 'debug', //打印日志
-      //   pathRewrite: {
-      //     ['^' + process.env.VUE_APP_PIM_API]: ''
-      //   }
-      // },
-      // [process.env.VUE_APP_OMS_API]: {
-      //   target: `http://localhost:18081/oms`,
-      //   changeOrigin: true,
-      //   // logLevel: 'debug', //打印日志
-      //   pathRewrite: {
-      //     ['^' + process.env.VUE_APP_OMS_API]: ''
-      //   }
-      // }
+
       "/": {
         // target: "http://10.41.3.106:9093",
         target: "https://portal.gloria.com.cn",