auth page enhancement

This commit is contained in:
2026-03-18 18:04:41 +08:00
parent b6abf43075
commit 58e1c34b69
8 changed files with 640 additions and 2 deletions
+18
View File
@@ -6,6 +6,7 @@ export interface UserInfo {
email: string
role: string
status: number
ext?: Record<string, unknown> | null
}
export const useUserStore = defineStore('user', () => {
@@ -71,6 +72,21 @@ export const useUserStore = defineStore('user', () => {
}
}
async function updateProfile(data: { email?: string; ext?: Record<string, unknown> }) {
const result = await api.put<UserInfo>('/api/v1/me/profile', data)
setUser(result)
return result
}
async function changePassword(data: {
old_password: string
new_password: string
new_password_confirmation: string
}) {
await api.put('/api/v1/me/password', data)
logout()
}
return {
token,
refreshToken,
@@ -82,5 +98,7 @@ export const useUserStore = defineStore('user', () => {
setUser,
fetchCurrentUser,
logout,
updateProfile,
changePassword,
}
})