From e4f1c535a746e4ffe20772dc9fc42a19e2bb54cf Mon Sep 17 00:00:00 2001 From: zhangyahui Date: Thu, 28 May 2026 11:27:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=82=AE=E7=AE=B1=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 38 ++++- src/lang/en.ts | 8 +- src/lang/zh-cn.ts | 6 + .../setting/components/SecuritySection.vue | 4 +- .../setting/components/SettingsActions.vue | 7 +- src/views/setting/index.vue | 5 +- src/views/setting/useSettingsForm.ts | 154 +++++++++++++----- 7 files changed, 163 insertions(+), 59 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index 986aa49..815fac8 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -63,15 +63,6 @@ export const fetchDownloadItemsByGet = (params: Download): Promise }) } -export interface UserProfile { - firstName: string - lastName: string - username: string - roles: string[] - region: string - language: string - email: string -} // 获取用户信息 export const fetchUserProfile = (): Promise => { return request({ @@ -81,6 +72,18 @@ export const fetchUserProfile = (): Promise => { } // 设置用户信息 +export interface UserProfile { + firstName: string + lastName: string + username: string + roles: string[] + region: string + language: string + email: string + oldPassword?: string + newPassword?: string + verifyCode?: string +} export const updateUserProfile = (data: UserProfile): Promise => { return request({ url: '/buyer/profile/setProfile', @@ -88,3 +91,20 @@ export const updateUserProfile = (data: UserProfile): Promise => { data }) } + +// 获取设置页验证码 +export const fetchVerifyCode = (): Promise => { + return request({ + url: '/buyer/profile/sendEmailChangeCode', + method: 'post' + }) +} + +// 验证设置页验证码 +export const verifyEmailCode = (verifyCode: string): Promise => { + return request({ + url: '/buyer/profile/verifyEmailChangeCode', + method: 'post', + data: { verifyCode } + }) +} diff --git a/src/lang/en.ts b/src/lang/en.ts index f081c3f..6dca4c0 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -107,6 +107,7 @@ export default { discard: 'DISCARD', edit: 'EDIT', saveChange: 'SAVE CHANGE', + verifyEmail: 'VERIFY EMAIL', saving: 'SAVING...' }, dialog: { @@ -117,7 +118,7 @@ export default { resendCodeIn: 'Resend Code in {time}' }, messages: { - enterNewEmailFirst: 'Please enter your new email address first', + enterNewEmailFirst: 'Please enter your email address first', invalidEmail: 'Please enter a valid email address', sameEmail: 'Please enter a different email address', alreadyVerified: 'This email has already been verified', @@ -125,6 +126,11 @@ export default { enterVerificationCode: 'Please enter the 6-digit verification code', verificationCompleted: 'Email verification completed', verifyEmailBeforeSave: 'Please verify your new email before saving', + currentPasswordRequired: 'Please enter your current password', + passwordLengthError: 'Password length must be between {min} and {max} characters', + passwordSpecial: 'Password must contain special characters', + passwordCase: 'Password must include upper/lowercase letters and numbers', + passwordNotSameAsOld: 'New password cannot be the same as current password', settingsUpdated: 'Settings updated' }, roles: { diff --git a/src/lang/zh-cn.ts b/src/lang/zh-cn.ts index b77df76..0016d87 100644 --- a/src/lang/zh-cn.ts +++ b/src/lang/zh-cn.ts @@ -104,6 +104,7 @@ export default { discard: '放弃', edit: '编辑', saveChange: '保存更改', + verifyEmail: '验证邮箱', saving: '保存中...' }, dialog: { @@ -122,6 +123,11 @@ export default { enterVerificationCode: '请输入 6 位验证码', verificationCompleted: '邮箱验证完成', verifyEmailBeforeSave: '请先完成新邮箱验证再保存', + currentPasswordRequired: '请输入当前密码', + passwordLengthError: '密码长度必须在 {min} 到 {max} 个字符之间', + passwordSpecial: '密码必须包含特殊符号', + passwordCase: '密码必须包含大小写字母和数字', + passwordNotSameAsOld: '新密码不能与旧密码相同', settingsUpdated: '设置已更新' }, roles: { diff --git a/src/views/setting/components/SecuritySection.vue b/src/views/setting/components/SecuritySection.vue index 5fea7a3..6c73d08 100644 --- a/src/views/setting/components/SecuritySection.vue +++ b/src/views/setting/components/SecuritySection.vue @@ -32,9 +32,9 @@ {{ isEmailVerified ? t('Settings.security.verified') : t('Settings.security.verify') }} --> -
+
diff --git a/src/views/setting/components/SettingsActions.vue b/src/views/setting/components/SettingsActions.vue index d4fa7a5..69ed412 100644 --- a/src/views/setting/components/SettingsActions.vue +++ b/src/views/setting/components/SettingsActions.vue @@ -1,7 +1,10 @@