feat: 更新登录模块
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
<div />
|
||||
<el-button type="primary" style="width: 100%;"
|
||||
:disabled="!authStore.isVerified"
|
||||
:loading="authStore.loginLoading"
|
||||
:loading="authStore.loginAdminLoading"
|
||||
@click.prevent="handleLogin('admin')">登录管理系统
|
||||
</el-button>
|
||||
|
||||
@@ -85,7 +85,7 @@ import { onMounted, reactive, ref } from 'vue'
|
||||
import { loginRules } from '@/utils/element/elRules'
|
||||
import { getLocalStorage, setLocalStorage } from 'vue3-common/utils/storageUtil'
|
||||
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 authStore = useAuthStore()
|
||||
@@ -104,20 +104,22 @@ onMounted(() => {
|
||||
const handleLogin = async (type: ILoginType) => {
|
||||
loginFormRef.value.validate(async (valid: any) => {
|
||||
if (valid) {
|
||||
authStore.loginLoading = true
|
||||
|
||||
if (type === 'common' && !isMobile()) {
|
||||
ElMessage.error("目前只支持移动端")
|
||||
authStore.loginLoading = false
|
||||
ElMessage.error('目前只支持移动端')
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'admin' && isMobile()) {
|
||||
ElMessage.error("目前只支持PC端")
|
||||
authStore.loginLoading = false
|
||||
ElMessage.error('目前只支持PC端')
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'common') {
|
||||
authStore.loginLoading = true
|
||||
} else {
|
||||
authStore.loginAdminLoading = true
|
||||
}
|
||||
|
||||
try {
|
||||
await authStore.handleLogin(type)
|
||||
userStore.handleSession(authStore.homeSession)
|
||||
@@ -134,6 +136,7 @@ const handleLogin = async (type: ILoginType) => {
|
||||
}
|
||||
} finally {
|
||||
authStore.loginLoading = false
|
||||
authStore.loginAdminLoading = false
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('请输入正确的信息')
|
||||
|
||||
@@ -21,6 +21,7 @@ export const useAuthStore = defineStore('auth', {
|
||||
},
|
||||
loginType: 'common' as ILoginType,
|
||||
loginLoading: false,
|
||||
loginAdminLoading: false,
|
||||
isVerified: false,
|
||||
isGettingCode: false,
|
||||
getCodeCountdown: 60,
|
||||
|
||||
Reference in New Issue
Block a user