From 882d80f6d44392e8c8a2ce50ac98d306d77e51e4 Mon Sep 17 00:00:00 2001 From: Zyronon Date: Mon, 10 Nov 2025 16:57:28 +0000 Subject: [PATCH] save --- src/apis/auth.ts | 95 ++++ src/apis/index.ts | 3 + src/assets/css/style.scss | 3 + src/components/base/BaseInput.vue | 27 +- src/config/auth.ts | 52 ++ src/main.ts | 7 +- src/pages/setting/Setting.vue | 94 ++++ src/pages/user/index.vue | 138 ++++- src/pages/user/login.vue | 801 +++++++++++++++++++++++++++++- src/router.ts | 26 +- src/stores/auth.ts | 168 +++++++ src/utils/validation.ts | 166 +++++++ 12 files changed, 1538 insertions(+), 42 deletions(-) create mode 100644 src/apis/auth.ts create mode 100644 src/config/auth.ts create mode 100644 src/stores/auth.ts create mode 100644 src/utils/validation.ts diff --git a/src/apis/auth.ts b/src/apis/auth.ts new file mode 100644 index 00000000..f557cd50 --- /dev/null +++ b/src/apis/auth.ts @@ -0,0 +1,95 @@ +import http from '@/utils/http.ts' +// 用户登录接口 +export interface LoginParams { + email?: string + phone?: string + password?: string + code?: string + type: 'email' | 'phone' | 'wechat' +} + +export interface LoginResponse { + token: string + user: { + id: string + email?: string + phone?: string + nickname?: string + avatar?: string + } +} + +// 用户注册接口 +export interface RegisterParams { + email?: string + phone: string + password: string + code: string + nickname?: string +} + +export interface RegisterResponse { + token: string + user: { + id: string + email?: string + phone: string + nickname?: string + avatar?: string + } +} + +// 发送验证码接口 +export interface SendCodeParams { + email?: string + phone: string + type: 'login' | 'register' | 'reset_password' +} + +// 重置密码接口 +export interface ResetPasswordParams { + email?: string + phone: string + code: string + newPassword: string +} + +// 微信登录接口 +export interface WechatLoginParams { + code: string + state?: string +} + +// API 函数定义 +export function login(params: LoginParams) { + return http('auth/login', params, null, 'post') +} + +export function register(params: RegisterParams) { + return http('auth/register', params, null, 'post') +} + +export function sendCode(params: SendCodeParams) { + return http('auth/sendCode', params, null, 'post') +} + +export function resetPassword(params: ResetPasswordParams) { + return http('auth/resetPassword', params, null, 'post') +} + +export function wechatLogin(params: WechatLoginParams) { + return http('auth/wechatLogin', params, null, 'post') +} + +export function logout() { + return http('auth/logout', null, null, 'post') +} + +export function refreshToken() { + return http<{ token: string }>('auth/refreshToken', null, null, 'post') +} + +// 获取用户信息 +export function getUserInfo() { + return http('auth/userInfo', null, null, 'get') +} diff --git a/src/apis/index.ts b/src/apis/index.ts index 4215fc31..6b61335d 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -59,3 +59,6 @@ export function uploadImportData(data,onUploadProgress) { onUploadProgress }) } + +// 导出认证相关API +export * from './auth' diff --git a/src/assets/css/style.scss b/src/assets/css/style.scss index b78ab1de..6f357ea5 100644 --- a/src/assets/css/style.scss +++ b/src/assets/css/style.scss @@ -219,6 +219,9 @@ a { text-decoration: none; } +.cp{ + @apply cursor-pointer; +} @supports selector(::-webkit-scrollbar) { ::-webkit-scrollbar { diff --git a/src/components/base/BaseInput.vue b/src/components/base/BaseInput.vue index c08d6e37..5088bf0f 100644 --- a/src/components/base/BaseInput.vue +++ b/src/components/base/BaseInput.vue @@ -21,6 +21,11 @@ const props = defineProps({ default: false, }, maxLength: Number, + size: { + type: String, + default: 'normal', + validator: (value: string) => ['normal', 'large'].includes(value) + }, }); const emit = defineEmits(['update:modelValue', 'input', 'change', 'focus', 'blur', 'validation']); @@ -96,7 +101,7 @@ const vFocus = {