feat: 增加登录管理系统

This commit is contained in:
2025-06-10 20:01:56 +08:00
parent 829df0b1d1
commit 5bf38c2f1a
10 changed files with 34 additions and 26 deletions

View File

@@ -43,7 +43,13 @@
<el-button type="primary" style="width: 100%;"
:disabled="!authStore.isVerified"
:loading="authStore.loginLoading"
@click.prevent="handleLogin()">登录
@click.prevent="handleLogin('common')">登录
</el-button>
<div />
<el-button type="primary" style="width: 100%;"
:disabled="!authStore.isVerified"
:loading="authStore.loginLoading"
@click.prevent="handleLogin('admin')">登录管理系统
</el-button>
<div class="login-type">
@@ -79,6 +85,7 @@ import { onMounted, reactive, ref } from 'vue'
import { loginRules } from '@/utils/element/elRules'
import { isMobile } from 'vue3-common/utils/layoutUtil'
import { getLocalStorage, setLocalStorage } from 'vue3-common/utils/storageUtil'
import { ILoginType } from '@/types/auth'
const rules = reactive<FormRules>(loginRules)
const authStore = useAuthStore()
@@ -94,13 +101,13 @@ onMounted(() => {
}
})
const handleLogin = async () => {
const handleLogin = async (type: ILoginType) => {
loginFormRef.value.validate(async (valid: any) => {
if (valid) {
authStore.loginLoading = true
try {
await authStore.handleLogin('common')
await authStore.handleLogin(type)
userStore.handleSession(authStore.homeSession)
// 2. 存储账户密码到localStorage中
@@ -110,8 +117,10 @@ const handleLogin = async () => {
if (isMobile()) {
await router.push('/mobile-home')
} else {
} else if (type === 'common') {
await router.push('/home')
} else {
await router.push('/admin')
}
} finally {
authStore.loginLoading = false