diff --git a/src/api/user/index.ts b/src/api/user/index.ts index 32b2b660..1b098fd0 100644 --- a/src/api/user/index.ts +++ b/src/api/user/index.ts @@ -108,3 +108,17 @@ export async function getUserCommentApi( return response } + +// 根据用户邮箱重置密码 +export async function updateUserPasswordByEmailApi( + request: User.UserResetPasswordByEmailRequestData +): Promise { + const url = `/auth/password/reset` + + const response = fetchPost( + url, + request + ) + + return response +} diff --git a/src/api/user/types/user.ts b/src/api/user/types/user.ts index 69f36009..f8c645ad 100644 --- a/src/api/user/types/user.ts +++ b/src/api/user/types/user.ts @@ -77,6 +77,13 @@ export interface UserGetUserCommentRequestData { cidArray: number[] } +// 用户验证邮箱重置密码,不根据密码重置 +export interface UserResetPasswordByEmailRequestData { + email: string + code: string + newPassword: string +} + export type UserInfoResponseData = KUNGalgameResponseData export type UserUpdateBioResponseData = KUNGalgameResponseData<{}> @@ -98,3 +105,5 @@ export type UserGetUserReplyResponseData = KUNGalgameResponseData export type UserGetUserCommentResponseData = KUNGalgameResponseData< UserComment[] > + +export type UserResetPasswordByEmailResponseData = KUNGalgameResponseData<{}> diff --git a/src/language/en.ts b/src/language/en.ts index 92d3e64c..cf841c9b 100644 --- a/src/language/en.ts +++ b/src/language/en.ts @@ -248,6 +248,7 @@ export default { }, code: { code: `The verification code has been sent. You can check it in your email. Please check your spam folder. If you haven't received the email, you can try to resend the email verification code after 30 seconds.`, + password: 'Are you sure you want to change the password?', }, }, } diff --git a/src/language/zh.ts b/src/language/zh.ts index 60940d87..64fe5252 100644 --- a/src/language/zh.ts +++ b/src/language/zh.ts @@ -245,6 +245,7 @@ export default { }, code: { code: '验证码已发送,您可以在邮箱中查看,注意查看垃圾邮件,如果未收到邮件,您可以在 30 秒后尝试重新发送邮箱验证码', + password: '确定更改密码吗?', }, }, } diff --git a/src/store/modules/kungalgamer.ts b/src/store/modules/kungalgamer.ts index e6280ba7..5e373b98 100644 --- a/src/store/modules/kungalgamer.ts +++ b/src/store/modules/kungalgamer.ts @@ -32,6 +32,8 @@ import type { UserGetUserReplyResponseData, UserGetUserCommentRequestData, UserGetUserCommentResponseData, + UserResetPasswordByEmailRequestData, + UserResetPasswordByEmailResponseData, } from '@/api' import { @@ -44,6 +46,7 @@ import { getUserTopicApi, getUserReplyApi, getUserCommentApi, + updateUserPasswordByEmailApi, } from '@/api' // kungalgame store 类型 @@ -217,5 +220,19 @@ export const useKUNGalgameUserStore = defineStore({ } return getUserCommentApi(requestData) }, + + // 根据用户邮箱重置密码 + async updatePasswordByEmail( + email: string, + code: string, + newPassword: string + ): Promise { + const requestData: UserResetPasswordByEmailRequestData = { + email: email, + code: code, + newPassword: newPassword, + } + return updateUserPasswordByEmailApi(requestData) + }, }, }) diff --git a/src/types/kungalgame.api.d.ts b/src/types/kungalgame.api.d.ts index 23279b07..f3c27632 100644 --- a/src/types/kungalgame.api.d.ts +++ b/src/types/kungalgame.api.d.ts @@ -1,4 +1,5 @@ -/** 所有 api 接口的响应数据都为该格式 */ +// 所有 api 接口的响应数据都为该格式 + interface KUNGalgameResponseData { code: number message: string diff --git a/src/views/Home/content/aside/components/Aside.vue b/src/views/Home/content/aside/components/Aside.vue index 4853a398..120f92c7 100644 --- a/src/views/Home/content/aside/components/Aside.vue +++ b/src/views/Home/content/aside/components/Aside.vue @@ -1,6 +1,6 @@