Reduce noisy runtime logging in frontend flows.

This keeps chat, notification, and post interactions cleaner in production while preserving error-level visibility.
This commit is contained in:
2026-03-09 22:18:47 +08:00
parent 3968660048
commit 63e32b15a3
21 changed files with 14 additions and 284 deletions

View File

@@ -275,8 +275,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 点赞帖子 - 乐观更新
likePost: async (postId: string) => {
console.log('[userStore] likePost called:', postId);
// 先乐观更新本地状态
set(state => ({
posts: state.posts.map(p =>
@@ -288,7 +286,6 @@ export const useUserStore = create<UserState>((set, get) => ({
try {
const updatedPost = await postService.likePost(postId);
if (updatedPost) {
console.log('[userStore] likePost success, updated post:', updatedPost);
// 使用后端返回的更新后数据更新状态
set(state => ({
posts: state.posts.map(p =>
@@ -316,8 +313,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 取消点赞 - 乐观更新
unlikePost: async (postId: string) => {
console.log('[userStore] unlikePost called:', postId);
// 先乐观更新本地状态
set(state => ({
posts: state.posts.map(p =>
@@ -329,7 +324,6 @@ export const useUserStore = create<UserState>((set, get) => ({
try {
const updatedPost = await postService.unlikePost(postId);
if (updatedPost) {
console.log('[userStore] unlikePost success, updated post:', updatedPost);
// 使用后端返回的更新后数据更新状态
set(state => ({
posts: state.posts.map(p =>
@@ -357,8 +351,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 收藏帖子 - 乐观更新
favoritePost: async (postId: string) => {
console.log('[userStore] favoritePost called:', postId);
// 先乐观更新本地状态
set(state => ({
posts: state.posts.map(p =>
@@ -370,7 +362,6 @@ export const useUserStore = create<UserState>((set, get) => ({
try {
const updatedPost = await postService.favoritePost(postId);
if (updatedPost) {
console.log('[userStore] favoritePost success, updated post:', updatedPost);
// 使用后端返回的更新后数据更新状态
set(state => ({
posts: state.posts.map(p =>
@@ -398,8 +389,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 取消收藏 - 乐观更新
unfavoritePost: async (postId: string) => {
console.log('[userStore] unfavoritePost called:', postId);
// 先乐观更新本地状态
set(state => ({
posts: state.posts.map(p =>
@@ -411,7 +400,6 @@ export const useUserStore = create<UserState>((set, get) => ({
try {
const updatedPost = await postService.unfavoritePost(postId);
if (updatedPost) {
console.log('[userStore] unfavoritePost success, updated post:', updatedPost);
// 使用后端返回的更新后数据更新状态
set(state => ({
posts: state.posts.map(p =>
@@ -439,7 +427,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 点赞评论
likeComment: async (commentId: string) => {
console.log('[userStore] likeComment called:', commentId);
// 先更新本地状态更新posts中的帖子的评论点赞状态
set(state => ({
posts: state.posts.map(p => ({
@@ -453,7 +440,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 调用API
try {
await commentService.likeComment(commentId);
console.log('[userStore] likeComment success:', commentId);
} catch (error) {
console.error('点赞评论失败:', error);
// 失败回滚状态
@@ -470,7 +456,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 取消点赞评论
unlikeComment: async (commentId: string) => {
console.log('[userStore] unlikeComment called:', commentId);
// 先更新本地状态
set(state => ({
posts: state.posts.map(p => ({
@@ -484,7 +469,6 @@ export const useUserStore = create<UserState>((set, get) => ({
// 调用API
try {
await commentService.unlikeComment(commentId);
console.log('[userStore] unlikeComment success:', commentId);
} catch (error) {
console.error('取消点赞评论失败:', error);
// 失败回滚状态