feat: 添加日志

This commit is contained in:
zdl
2025-10-18 08:08:58 +08:00
parent 36558e0715
commit b46ee4a18e
5 changed files with 74 additions and 45 deletions

View File

@@ -43,6 +43,7 @@ import {
} from '@chakra-ui/react';
import { EditIcon, CheckIcon, CloseIcon, AddIcon } from '@chakra-ui/icons';
import { useAuth } from '../../contexts/AuthContext';
import { logger } from '../../utils/logger';
export default function ProfilePage() {
const { user, updateUser } = useAuth();
@@ -86,12 +87,15 @@ export default function ProfilePage() {
creator_tags: formData.creator_tags.join(',')
};
logger.debug('ProfilePage', '保存个人资料', { userId: user?.id });
// 模拟API调用
await new Promise(resolve => setTimeout(resolve, 1000));
updateUser(updatedData);
setIsEditing(false);
// ✅ 保留关键操作提示
toast({
title: "个人资料更新成功",
status: "success",
@@ -99,6 +103,9 @@ export default function ProfilePage() {
isClosable: true,
});
} catch (error) {
logger.error('ProfilePage', 'handleSaveProfile', error, { userId: user?.id });
// ✅ 保留错误提示
toast({
title: "更新失败",
description: error.message,
@@ -114,10 +121,14 @@ export default function ProfilePage() {
const handleAvatarUpload = (event) => {
const file = event.target.files[0];
if (file) {
logger.debug('ProfilePage', '上传头像', { fileName: file.name, fileSize: file.size });
// 这里应该上传文件到服务器
const reader = new FileReader();
reader.onload = (e) => {
updateUser({ avatar_url: e.target.result });
// ✅ 保留关键操作提示
toast({
title: "头像更新成功",
status: "success",