- 新增User模型字段:username(用户名)、wechat(微信号)、notes(备注) - 扩展用户搜索功能,支持通过用户名和微信号搜索 - 添加用户个人资料更新功能,用户可自行编辑用户名和微信号 - 管理员用户列表新增用户名、微信号、备注显示列 - 备注字段仅对管理员可见,增强数据安全性 - 完善中英文国际化翻译 - 修复国际化文件中重复属性的TypeScript错误 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
/**
|
|
* User API endpoints
|
|
* Handles user profile management and password changes
|
|
*/
|
|
|
|
import { apiClient } from './client';
|
|
import type { User, ChangePasswordRequest } from '@/types';
|
|
|
|
/**
|
|
* Get current user profile
|
|
* @returns User profile data
|
|
*/
|
|
export async function getProfile(): Promise<User> {
|
|
const { data } = await apiClient.get<User>('/user/profile');
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* Update current user profile
|
|
* @param profile - Profile data to update
|
|
* @returns Updated user profile data
|
|
*/
|
|
export async function updateProfile(profile: {
|
|
username?: string;
|
|
wechat?: string;
|
|
}): Promise<User> {
|
|
const { data } = await apiClient.put<User>('/user', profile);
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* Change current user password
|
|
* @param passwords - Old and new password
|
|
* @returns Success message
|
|
*/
|
|
export async function changePassword(
|
|
oldPassword: string,
|
|
newPassword: string
|
|
): Promise<{ message: string }> {
|
|
const payload: ChangePasswordRequest = {
|
|
old_password: oldPassword,
|
|
new_password: newPassword,
|
|
};
|
|
|
|
const { data } = await apiClient.put<{ message: string }>('/user/password', payload);
|
|
return data;
|
|
}
|
|
|
|
export const userAPI = {
|
|
getProfile,
|
|
updateProfile,
|
|
changePassword,
|
|
};
|
|
|
|
export default userAPI;
|