From fe44252b206dbd3d91fb801bdbb70751a7f5362b Mon Sep 17 00:00:00 2001 From: PeterAlbus Date: Tue, 8 Aug 2023 10:45:05 +0800 Subject: [PATCH] remove a ts-ignore and change it to a more reasonable way. --- src/main.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4708c4b..33610cc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,9 +29,8 @@ axios.defaults.baseURL='https://www.peteralbus.com:8089/' axios.interceptors.request.use( config => { - if (localStorage.getItem("token")) { //判断token是否存在 - // @ts-ignore - config.headers.satoken_peteralbus_blog = localStorage.getItem("token"); //将token设置成请求头 + if (localStorage.getItem("token") && config.headers ) { //判断token是否存在 + config.headers['satoken_peteralbus_blog'] = localStorage.getItem("token")||''; //将token设置成请求头 } return config; },