From 85f7f28dc4e793d5e1cc48311339fae430bb2ef2 Mon Sep 17 00:00:00 2001 From: XiaoDaiGua-Ray <443547225@qq.com> Date: Sun, 7 Apr 2024 17:14:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=97=B6=E5=85=A8=E5=B1=8F=E5=8A=A0=E8=BD=BD=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E7=9A=84=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/components/Signing/index.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/views/login/components/Signing/index.tsx b/src/views/login/components/Signing/index.tsx index 77a9fc1a..68edb172 100644 --- a/src/views/login/components/Signing/index.tsx +++ b/src/views/login/components/Signing/index.tsx @@ -3,7 +3,6 @@ import { NForm, NFormItem, NInput, NButton } from 'naive-ui' import { setStorage } from '@/utils' import { useI18n, useAppRoot } from '@/hooks' import { APP_CATCH_KEY } from '@/app-config' -import { setVariable, getVariableToRefs } from '@/global-variable' import { useSigningActions } from '@/store' import type { FormInst } from 'naive-ui' @@ -16,7 +15,7 @@ export default defineComponent({ const { t } = useI18n() const { signing } = useSigningActions() const { getRootPath } = useAppRoot() - const globalSpinning = getVariableToRefs('globalSpinning') + const loading = ref(false) const useSigningForm = () => ({ name: 'Ray Admin', @@ -43,20 +42,20 @@ export default defineComponent({ const handleLogin = () => { loginFormRef.value?.validate((valid) => { if (!valid) { - setVariable('globalSpinning', true) + loading.value = true signing(signingForm.value) .then((res) => { if (res.code === 0) { setTimeout(() => { - setVariable('globalSpinning', false) - window.$message.success(`欢迎${signingForm.value.name}登陆~`) setStorage(APP_CATCH_KEY.token, 'tokenValue') setStorage(APP_CATCH_KEY.signing, res.data) router.push(getRootPath.value) + + loading.value = false }, 2 * 1000) } }) @@ -72,11 +71,11 @@ export default defineComponent({ loginFormRef, handleLogin, rules, - globalSpinning, + loading, } }, render() { - const { $t, globalSpinning } = this + const { $t, loading } = this return ( @@ -98,7 +97,7 @@ export default defineComponent({ style={['width: 100%', 'margin-to: 18px']} type="primary" onClick={this.handleLogin.bind(this)} - loading={globalSpinning} + loading={loading} > {$t('views.login.index.Login')}