feat: 添加用户设置功能,支持修改昵称和邮箱,重构相关路由和组件

This commit is contained in:
2025-12-21 01:11:53 +07:00
parent 2e42bbc278
commit a4034b6b78
22 changed files with 620 additions and 225 deletions

View File

@@ -1 +1,2 @@
export * from "./user";
export * from "./wallet";

25
src/store/user.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { UserData, UserProfileData } from "@/api/types";
import { client, safeClient } from "@/api";
interface State {
userProfile: UserProfileData | null;
session: UserData | null;
}
export const useUserStore = defineStore("user", () => {
const state = reactive<State>({
userProfile: null,
session: null,
});
async function updateProfile() {
const { data } = await safeClient(client.api.user.profile.get(), { silent: true });
state.userProfile = data.value?.userProfile || null;
state.session = data.value?.user || null;
}
return {
state,
updateProfile,
};
});