From cf1ee9cbb03fb4c6829ca44512897cb38e31bee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=98=89=E6=82=A6?= Date: Tue, 3 Jun 2025 17:52:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/auth/index.ts | 8 +- src/api/auth/types.ts | 28 +++ .../components/FormLogin/AccountPassword.vue | 26 ++- .../components/FormLogin/RegistrationForm.vue | 200 ++++++++++++++++++ src/components/LoginDialog/index.vue | 32 ++- src/hooks/useWindowWidthObserver.ts | 6 +- src/routers/index.ts | 4 - src/stores/modules/loginForm.ts | 18 ++ types/components.d.ts | 5 +- 9 files changed, 305 insertions(+), 22 deletions(-) create mode 100644 src/components/LoginDialog/components/FormLogin/RegistrationForm.vue create mode 100644 src/stores/modules/loginForm.ts diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index 4177edb..bcfaaf7 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -1,4 +1,10 @@ -import type { LoginDTO, LoginVO } from './types'; +import type { EmailCodeDTO, LoginDTO, LoginVO, RegisterDTO } from './types'; import { post } from '@/utils/request'; export const login = (data: LoginDTO) => post('/auth/login', data); + +// 邮箱验证码 +export const emailCode = (data: EmailCodeDTO) => post('/resource/email/code', data); + +// 注册账号 +export const register = (data: RegisterDTO) => post('/auth/register', data); diff --git a/src/api/auth/types.ts b/src/api/auth/types.ts index a5e6035..645ee46 100644 --- a/src/api/auth/types.ts +++ b/src/api/auth/types.ts @@ -1,6 +1,9 @@ export interface LoginDTO { username: string; password: string; + code?: string; + // 二次确认密码 + confirmPassword?: string; } export interface LoginVO { @@ -116,3 +119,28 @@ export interface RoleDTO { */ roleName?: string; } + +// 邮箱验证码 +export interface EmailCodeDTO { + username?: string; +} + +// 邮箱注册 +export interface RegisterDTO { + /** + * 邮箱 + */ + username: string; + /** + * 密码 + */ + password: string; + /** + * 验证码 + */ + code: string; + /** + * 确认密码 + */ + confirmPassword?: string; +} diff --git a/src/components/LoginDialog/components/FormLogin/AccountPassword.vue b/src/components/LoginDialog/components/FormLogin/AccountPassword.vue index fb90185..5e21884 100644 --- a/src/components/LoginDialog/components/FormLogin/AccountPassword.vue +++ b/src/components/LoginDialog/components/FormLogin/AccountPassword.vue @@ -6,10 +6,12 @@ import { reactive, ref } from 'vue'; import { useRouter } from 'vue-router'; import { login } from '@/api'; import { useUserStore } from '@/stores'; +import { useLoginFromStore } from '@/stores/modules/loginFrom'; import { useSessionStore } from '@/stores/modules/session'; const userStore = useUserStore(); const sessionStore = useSessionStore(); +const loginFromStore = useLoginFromStore(); const formRef = ref(); @@ -45,9 +47,15 @@ async function handleSubmit() {