From 2461320047b685ffc71d9a8e358668a0ad6a96b4 Mon Sep 17 00:00:00 2001 From: besscroft Date: Sat, 9 Sep 2023 20:52:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=20load?= =?UTF-8?q?ing=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heming-web/pages/login.vue | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/heming-web/pages/login.vue b/heming-web/pages/login.vue index 94ac3ef..b6a927a 100644 --- a/heming-web/pages/login.vue +++ b/heming-web/pages/login.vue @@ -5,6 +5,7 @@ import ky from 'ky' const user = useUserStore() const router = useRouter() +const loading = ref(false) const toast = useToast() const nuxtApp = useNuxtApp() @@ -29,17 +30,23 @@ const handUserInfo = async () => { } const handleSubmitClick = async () => { - const json = await ky.post('/@fast-api/user/login', { - json: {username: loginForm.username, password: loginForm.password} - }).json(); - if (json.code === 200) { - user.setToken(json.data.tokenValue) - user.setTokenName(json.data.tokenName) - toast.add({ title: '登录成功!', timeout: 1000, ui: { width: 'w-full sm:w-96' }}) - await handUserInfo() - } else { - console.log(json.message) + loading.value = true + try { + const json = await ky.post('/@fast-api/user/login', { + json: {username: loginForm.username, password: loginForm.password} + }).json(); + if (json.code === 200) { + user.setToken(json.data.tokenValue) + user.setTokenName(json.data.tokenName) + toast.add({ title: '登录成功!', timeout: 1000, ui: { width: 'w-full sm:w-96' }}) + await handUserInfo() + } else { + console.log(json.message) + } + } catch (e) { + loading.value = false } + loading.value = false } const keyDown = (e) => { @@ -100,11 +107,13 @@ definePageMeta({
- +

还没有帐号?立即注册.