feat: 添加用户设置功能,支持修改昵称和邮箱,重构相关路由和组件
This commit is contained in:
@@ -1 +1,2 @@
|
||||
export * from "./user";
|
||||
export * from "./wallet";
|
||||
|
||||
25
src/store/user.ts
Normal file
25
src/store/user.ts
Normal 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,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user