Skip to content

添加评论回复的楼中楼功能,移除过时的评论赏金功能#37

Open
wangzh12023 wants to merge 14 commits intoShanghaitechGeekPie:masterfrom
wangzh12023:nested-comments-mock-v
Open

添加评论回复的楼中楼功能,移除过时的评论赏金功能#37
wangzh12023 wants to merge 14 commits intoShanghaitechGeekPie:masterfrom
wangzh12023:nested-comments-mock-v

Conversation

@wangzh12023
Copy link

新功能

  • 实现评论回复的楼中楼功能
    • 支持对评论的评论,实现二级嵌套结构

移除内容

  • 删除了原有的评论赏金功能:
    • 移除前端赏金 UI 展示

待确认

  • 评论回复的api接口以及数据传输格式的定义,详见useCommentReply.js,部分mock数据参考/src/composables/global/usePhantomData.js

Copy link
Member

@HeZeBang HeZeBang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 所有的在子页面 patch 的 mock 都是没有必要的,太过于侵入了。最佳实践是在各种 use... 获取数据的时候进行 patch,或更不侵入的应该是直接在用 useMuation 或者 useFetcher 这些接口调用的时候,做字符串网址匹配,并且 phantom 或者别的样例返回
  • 常量应该放到统一的地方,例如 environment.js
  • login 等可以根据你的 Mock 来判断是否应该用真实数据,而不是强制写入
  • CommentCard 的底部由于新增了按钮,在响应式设计的时候在窄屏幕会有溢出问题,可以修改断点比例
  • 新增的回复 UI 在回复楼中楼的时候有暗黑模式适应问题
  • 评论回复缺少 mock,不能复现期望的结果
  • TeacherAll 少许粗糙,缺少分页,不过没关系

Comment on lines +119 to +125

// 使用 mock 数据
if (mockDataManager.isEnabled()) {
status.profileLoading = false;
status.commentLoading = false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除

Comment on lines +138 to +143

// 使用 mock 数据
if (mockDataManager.isEnabled()) {
status.loading = false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 使用 mock 数据
if (mockDataManager.isEnabled()) {
status.loading = false;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除

Comment on lines +84 to +90

// 使用mock数据
if (mockDataManager.isEnabled()) {
commentText.value = mockDataManager.getData('comments');
status.commentLoading = false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要

Suggested change
// 使用mock数据
if (mockDataManager.isEnabled()) {
commentText.value = mockDataManager.getData('comments');
status.commentLoading = false;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除

Comment on lines +184 to +189

// 使用 mock 数据
if (mockDataManager.isEnabled()) {
courseText.value = mockDataManager.getData('courses');
status.loading = false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要

Suggested change
// 使用 mock 数据
if (mockDataManager.isEnabled()) {
courseText.value = mockDataManager.getData('courses');
status.loading = false;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除

Comment on lines +155 to +163

// 使用 mock 数据
if (mockDataManager.isEnabled()) {
const mockActiveData = mockDataManager.getData('activeData');
status.loading = mockActiveData.loading;
status.errorMessage = mockActiveData.errorMessage;
status.success = mockActiveData.success;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移除

Comment on lines +4 to +14
<div v-if="!showAll && replies.length > displayLimit" class="mb-2">
<v-btn
text
small
color="primary"
@click="showAll = true"
>
查看全部 {{ replies.length }} 条回复
<v-icon small class="ml-1">{{ mdiChevronDown }}</v-icon>
</v-btn>
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

位置有点反直觉,我期望的是这个显示在最下面,否则有点反直觉。并且最下面有个最好渐隐的效果,可以用 css 中的 mask 或者 filter 实现。可以参考 CSDN 那种读到一半然后让你付费解锁那种的设计(x

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

位置已更新

isError: false,
});

const replyMutation = useMutation('/comment/reply/post', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少 mock,无法验证行为

Comment on lines +10 to +21
// mock数据
if (mockManager.shouldUseMock()) {
if (address.includes('/comment/recent')) {
return await mockManager.mockSuccess(mockManager.getMockData('comments'));
} else if (address.includes('/course/all')) {
return await mockManager.mockSuccess(mockManager.getMockData('courses'));
} else if (address.includes('/teacher/')) {
return await mockManager.mockSuccess(mockManager.getMockData('teachers')[0]);
}
// 默认返回空数据
return await mockManager.mockSuccess([]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尝试把所有的 mock 都写到一个文件里,不要侵入别的文件,并且做好匹配(例如使用字典而不是连环的 if)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移到mockService.js

Comment on lines +94 to +106
// mock数据
if (mockDataManager.isEnabled()) {
const id = parseInt(route.params.id);
const mockUser = mockDataManager.getData('users').find(user => user.id === id) || mockDataManager.getData('userProfile');
useRefCopy(mockUser, userProfile);
userProfile.nickname = useUserName(userProfile);
userProfile.grade = gradeItems[userProfile.grade];
userProfile.year = userProfile.year === 0 ? '暂不透露' : userProfile.year;
status.profileLoading = false;
return;
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用统一的 mock

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已移到mockService.js

@@ -1,7 +1,123 @@
<template>
<v-container></v-container>
<div style="min-height: 100%">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

少许粗糙,缺少分页,不过没关系

@wangzh12023 wangzh12023 requested a review from HeZeBang July 13, 2025 04:14
Copy link
Author

@wangzh12023 wangzh12023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 对于mock数据已移动到mockService.js同一管理,全局变量放入environments.js统一管理
  • 修改了展开回复和收起回复的位置
  • 修改了replyList的背景颜色
  • unresolved: 深色主题背景测试未测试(没看到怎么调深色背景,无法测试)
  • unresolved: api修改验证行为,目前待商榷如何验证

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants