fix: 严格按后端account字段修复记住账号

This commit is contained in:
2026-02-06 15:53:35 +08:00
parent c8b63cf0f5
commit a5080912b5
2 changed files with 9 additions and 11 deletions

View File

@@ -14,9 +14,8 @@ export namespace AuthApi {
/** 登录接口参数 */
export interface LoginParams {
account?: string;
password?: string;
username?: string;
account: string;
password: string;
}
/** 登录接口返回值 */
@@ -45,9 +44,8 @@ export namespace AuthApi {
* 登录
*/
export async function loginApi(data: AuthApi.LoginParams) {
const account = data.account ?? data.username;
return requestClient.post<AuthApi.LoginResult>('/auth/login', {
account,
account: data.account,
password: data.password,
});
}

View File

@@ -58,11 +58,11 @@ const [Form, formApi] = useVbenForm(
);
const router = useRouter();
const REMEMBER_ME_KEY = `REMEMBER_ME_USERNAME_${location.hostname}`;
const REMEMBER_ME_KEY = `REMEMBER_ME_ACCOUNT_${location.hostname}`;
const localUsername = localStorage.getItem(REMEMBER_ME_KEY) || '';
const localAccount = localStorage.getItem(REMEMBER_ME_KEY) || '';
const rememberMe = ref(!!localUsername);
const rememberMe = ref(!!localAccount);
async function handleSubmit() {
const { valid } = await formApi.validate();
@@ -70,7 +70,7 @@ async function handleSubmit() {
if (valid) {
localStorage.setItem(
REMEMBER_ME_KEY,
rememberMe.value ? values?.username : '',
rememberMe.value ? values?.account : '',
);
emit('submit', values);
}
@@ -81,8 +81,8 @@ function handleGo(path: string) {
}
onMounted(() => {
if (localUsername) {
formApi.setFieldValue('username', localUsername);
if (localAccount) {
formApi.setFieldValue('account', localAccount);
}
});