feat: 更新登录模块

This commit is contained in:
2025-06-11 20:04:01 +08:00
parent 2fcc2453cf
commit 38efe4483d
2 changed files with 12 additions and 8 deletions

View File

@@ -48,7 +48,7 @@
<div /> <div />
<el-button type="primary" style="width: 100%;" <el-button type="primary" style="width: 100%;"
:disabled="!authStore.isVerified" :disabled="!authStore.isVerified"
:loading="authStore.loginLoading" :loading="authStore.loginAdminLoading"
@click.prevent="handleLogin('admin')">登录管理系统 @click.prevent="handleLogin('admin')">登录管理系统
</el-button> </el-button>
@@ -85,7 +85,7 @@ import { onMounted, reactive, ref } from 'vue'
import { loginRules } from '@/utils/element/elRules' import { loginRules } from '@/utils/element/elRules'
import { getLocalStorage, setLocalStorage } from 'vue3-common/utils/storageUtil' import { getLocalStorage, setLocalStorage } from 'vue3-common/utils/storageUtil'
import { ILoginType } from '@/types/auth' import { ILoginType } from '@/types/auth'
import {isMobile} from "vue3-common/utils/layoutUtil"; import { isMobile } from 'vue3-common/utils/layoutUtil'
const rules = reactive<FormRules>(loginRules) const rules = reactive<FormRules>(loginRules)
const authStore = useAuthStore() const authStore = useAuthStore()
@@ -104,20 +104,22 @@ onMounted(() => {
const handleLogin = async (type: ILoginType) => { const handleLogin = async (type: ILoginType) => {
loginFormRef.value.validate(async (valid: any) => { loginFormRef.value.validate(async (valid: any) => {
if (valid) { if (valid) {
authStore.loginLoading = true
if (type === 'common' && !isMobile()) { if (type === 'common' && !isMobile()) {
ElMessage.error("目前只支持移动端") ElMessage.error('目前只支持移动端')
authStore.loginLoading = false
return return
} }
if (type === 'admin' && isMobile()) { if (type === 'admin' && isMobile()) {
ElMessage.error("目前只支持PC端") ElMessage.error('目前只支持PC端')
authStore.loginLoading = false
return return
} }
if (type === 'common') {
authStore.loginLoading = true
} else {
authStore.loginAdminLoading = true
}
try { try {
await authStore.handleLogin(type) await authStore.handleLogin(type)
userStore.handleSession(authStore.homeSession) userStore.handleSession(authStore.homeSession)
@@ -134,6 +136,7 @@ const handleLogin = async (type: ILoginType) => {
} }
} finally { } finally {
authStore.loginLoading = false authStore.loginLoading = false
authStore.loginAdminLoading = false
} }
} else { } else {
ElMessage.error('请输入正确的信息') ElMessage.error('请输入正确的信息')

View File

@@ -21,6 +21,7 @@ export const useAuthStore = defineStore('auth', {
}, },
loginType: 'common' as ILoginType, loginType: 'common' as ILoginType,
loginLoading: false, loginLoading: false,
loginAdminLoading: false,
isVerified: false, isVerified: false,
isGettingCode: false, isGettingCode: false,
getCodeCountdown: 60, getCodeCountdown: 60,