feat(login): 删除还没有账号? 注册
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m19s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m19s
This commit is contained in:
@@ -12,16 +12,8 @@ import { HOME_PAGE } from '@/router/routesAlias'
|
||||
import AppConfig from '@/config'
|
||||
import { AuthService } from '@/api/authApi'
|
||||
import { ApiStatus } from '@/utils/http/status'
|
||||
import {
|
||||
MOCK_ACCOUNTS,
|
||||
mockLogin,
|
||||
mockGetUserInfo,
|
||||
type MockAccount
|
||||
} from '@/mock/auth'
|
||||
import {
|
||||
saveCredentials,
|
||||
getRememberedCredentials
|
||||
} from '@/utils/auth/rememberPassword'
|
||||
import { MOCK_ACCOUNTS, mockLogin, mockGetUserInfo, type MockAccount } from '@/mock/auth'
|
||||
import { saveCredentials, getRememberedCredentials } from '@/utils/auth/rememberPassword'
|
||||
import { usernameRules, passwordRules } from '@/utils/auth/loginValidation'
|
||||
import { getRedirectPath } from '@/router/guards/permission'
|
||||
|
||||
@@ -84,9 +76,7 @@ export function useLogin() {
|
||||
|
||||
// 如果使用 Mock,尝试匹配 Mock 账号
|
||||
if (USE_MOCK) {
|
||||
const matchedAccount = MOCK_ACCOUNTS.find(
|
||||
(acc) => acc.username === remembered.username
|
||||
)
|
||||
const matchedAccount = MOCK_ACCOUNTS.find((acc) => acc.username === remembered.username)
|
||||
if (matchedAccount) {
|
||||
formData.account = matchedAccount.key
|
||||
}
|
||||
@@ -142,7 +132,10 @@ export function useLogin() {
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('登录失败:', error)
|
||||
ElMessage.error(error.message || t('login.error.loginFailed'))
|
||||
// 从后端响应中提取错误消息
|
||||
const errorMessage =
|
||||
error.response?.data?.msg || error.message || t('login.error.loginFailed')
|
||||
ElMessage.error(errorMessage)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user