fix:注册界面及相关功能
This commit is contained in:
@@ -7,6 +7,7 @@ import { localStg } from '@/utils/storage';
|
||||
import { $t } from '@/locales';
|
||||
import { useRouteStore } from '../route';
|
||||
import { clearAuthStorage, emptyInfo, getToken } from './shared';
|
||||
import {sendCaptcha} from "@/service/api/auth";
|
||||
|
||||
export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
||||
const routeStore = useRouteStore();
|
||||
@@ -121,6 +122,34 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Register new user
|
||||
*/
|
||||
async function register(registerForm: Api.Auth.RegisterBody) {
|
||||
startLoading();
|
||||
|
||||
const { error } = await fetchRegister(registerForm);
|
||||
|
||||
if (!error) {
|
||||
$message?.success($t('page.login.common.registerSuccess'));
|
||||
// 注册成功后跳转到登录页
|
||||
await toLogin();
|
||||
}
|
||||
|
||||
endLoading();
|
||||
return !error;
|
||||
}
|
||||
async function captcha(email:string){
|
||||
if (!email) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await sendCaptcha({ email }); // 这里调用后端接口发送验证码
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
token,
|
||||
@@ -131,6 +160,8 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
||||
resetStore,
|
||||
permissions,
|
||||
login,
|
||||
refreshUserInfo
|
||||
refreshUserInfo,
|
||||
register,
|
||||
captcha,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user