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({
- +

还没有帐号?立即注册.