feat: 添加用户个人资料编辑功能,优化页面布局与导航
1. 后端新增用户资料更新接口,支持修改昵称、头像、邮箱和签名 2. 前端新增资料编辑表单页面,适配响应式布局 3. 优化帖子详情页布局与移动端适配逻辑 4. 重构首页侧边栏导航,使用卡片式板块展示 5. 移除全局板块缓存,调整Header导航移除板块菜单 6. 补充用户签名展示功能,完善用户信息返回字段
This commit is contained in:
@@ -26,6 +26,9 @@ export interface User {
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
role: string;
|
||||
// 仅 /api/me 与 /api/profile 响应中返回(用户自身敏感信息)
|
||||
email?: string;
|
||||
signature?: string;
|
||||
}
|
||||
|
||||
// /api/me 响应:用户信息 + 未读通知数(SSR layout 一次请求直出)
|
||||
@@ -206,6 +209,7 @@ export interface UserProfile {
|
||||
username: string;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
signature: string;
|
||||
role: string;
|
||||
created_at: string;
|
||||
};
|
||||
@@ -510,6 +514,21 @@ export async function apiChangePassword(oldPassword: string, newPassword: string
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// 更新当前用户资料(昵称、头像、邮箱、签名)
|
||||
export async function apiUpdateProfile(data: {
|
||||
nickname: string;
|
||||
avatar?: string;
|
||||
email?: string;
|
||||
signature?: string;
|
||||
}): Promise<{ user?: User; error?: string }> {
|
||||
const res = await fetchWithRefresh("/api/profile", {
|
||||
method: "PUT",
|
||||
headers: clientHeaders({ "Content-Type": "application/json" }),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function apiToggleLike(postId: string) {
|
||||
const res = await fetchWithRefresh(`/api/posts/${postId}/like`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user