From 5fc82743ef135f029cc9cf0bf8894ce6b08cfcf7 Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Tue, 26 Dec 2023 10:47:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.ts | 6 +++++- src/views/user/login.vue | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index c1b70d1..15627e2 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -68,7 +68,11 @@ function createAxios>( // 自动携带token if (config.headers) { const token = adminInfo.getToken() - if (token) (config.headers as anyObj).Authorization = token + if (token) { + ;(config.headers as anyObj).Authorization = token + } else { + config.headers.Authorization = 'Basic bmpjbnRlc3Q6bmpjbnBxcw==' + } } return config diff --git a/src/views/user/login.vue b/src/views/user/login.vue index e2b1415..f1c265f 100644 --- a/src/views/user/login.vue +++ b/src/views/user/login.vue @@ -130,22 +130,23 @@ const onSubmit = async (formEl: FormInstance | undefined) => { grant_type: 'captcha', imageCode: '', verifyCode: 0 - }).then(res => { - if (res.code == 'A0000') { - // window.localStorage.setItem('token', '123') + }) + .then(res => { + console.log('🚀 ~ file: login.vue:134 ~ gongkey ~ res:', res) + useInfo.setToken(res.data.token_type + ' ' + res.data.access_token, 'auth') - state.submitLoading = false + // state.submitLoading = false router.push({ path: 'admin/dashboard' }) - } else { - ElMessage({ - message: res.message, - type: 'warning' - }) - state.submitLoading = false - } - }) + }) + // .catch(res => { + // ElMessage({ + // message: res.message, + // type: 'warning' + // }) + // }) + // state.submitLoading = false }) } })