From c8302cf9eff3e90395c4e89e97a87c5326cf79fd Mon Sep 17 00:00:00 2001 From: ch Date: Wed, 29 Jun 2022 16:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/api/comment.js | 8 ++++++-- plugins/axiosTk.js | 14 ++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/api/comment.js b/plugins/api/comment.js index 3518c85..f34f5cc 100644 --- a/plugins/api/comment.js +++ b/plugins/api/comment.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-06-20 11:38:48 * @LastEditors: ch - * @LastEditTime: 2022-06-29 11:55:10 + * @LastEditTime: 2022-06-29 16:03:36 * @Description: file content */ @@ -30,7 +30,11 @@ export const ApiGetCommentList = (params) => * @param {*} param0 */ export const ApiGetCommentCount = ({productId}) => - ToAsyncAwait(axios.get(`${BASE_URL}/app/comment/getAllCommentCountByProductId/${productId}`)); + ToAsyncAwait(axiosTk.get(`${BASE_URL}/app/comment/getAllCommentCountByProductId/${productId}`,{ + params: { + notVerifyToken : true + } + })); /** * 根据商品获取标签评论总数 * @param {*} param0 diff --git a/plugins/axiosTk.js b/plugins/axiosTk.js index 72ece1d..ad9f4cd 100644 --- a/plugins/axiosTk.js +++ b/plugins/axiosTk.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-05-04 17:11:07 * @LastEditors: ch - * @LastEditTime: 2022-06-29 11:16:31 + * @LastEditTime: 2022-06-29 16:01:55 * @Description: file content */ import { CreateUUID } from "@/plugins/utils"; @@ -23,14 +23,12 @@ export default function ({$axios, store, route, req}, inject) { $axiosTk.defaults.timeout = 3000; $axiosTk.onRequest( config =>{ config.headers.uid = uuid; - if (config.headers.notVerifyToken) { - if(!store.state.token){ - location.href = '/'; - return Promise.reject({message : '要先登录才能操作哦~'}); - } - delete config.headers.notVerifyToken; + if(!store.state.token && !config.headers.notVerifyToken){ + location.href = '/'; + return Promise.reject({message : '要先登录才能操作哦~'}); } - + + delete config.headers.notVerifyToken; config.headers.Authorization = store.state.token; return config; });