diff --git a/src/modules/Comment/index.vue b/src/modules/Comment/index.vue
index 4621391..4d59740 100644
--- a/src/modules/Comment/index.vue
+++ b/src/modules/Comment/index.vue
@@ -145,17 +145,32 @@
-
+
-
-
+
+
+
展开 {{ item.childrenCount }} 条回复
-
- 收起
-
+ 更多
+ {{ item.childrenCount - item.children.length }} 条回复
+
+
+
+
+
+ 收起
+
@@ -247,7 +262,7 @@ const commentData = ref([
name: "李星倩",
avatar: "",
},
- childrenCount: 3,
+ childrenCount: 10,
children: [
{
id: 101,
@@ -295,7 +310,6 @@ const commentData = ref([
// 回复
const openReply = (target, group) => {
-
// 1. 设置回复的目标关系
activeReply.groupId = group.id; // 根评论ID
activeReply.parentId = target.id; // 直接父级ID
@@ -303,7 +317,7 @@ const openReply = (target, group) => {
// 2. 沿用 @ 逻辑:自动在输入框插入 @某人
const mentionStr = `@${target.employee.name} `;
-
+
// 如果输入框里已经有内容了,在前面追加,否则直接赋值
if (!mainInput.value.includes(mentionStr)) {
mainInput.value = mentionStr + mainInput.value;
@@ -311,7 +325,7 @@ const openReply = (target, group) => {
// 3. 聚焦到输入框
nextTick(() => {
- const textarea = document.querySelector('.fixed-publisher textarea');
+ const textarea = document.querySelector(".fixed-publisher textarea");
textarea?.focus();
// 飞书细节:光标移到最后
textarea.selectionStart = textarea.value.length;
@@ -348,7 +362,7 @@ const cancelReply = () => {
activeReply.parentId = null;
activeReply.targetName = "";
activeReply.groupId = null;
- mainInput.value = '';
+ mainInput.value = "";
};
// @圈人的操作
@@ -368,7 +382,7 @@ const onUserMentioned = (user) => {
* @param {string} type - 'main' (主评论) 或 'reply' (回复)
*/
const handleSendComment = async () => {
- const type = activeReply.parentId ? 'reply' : 'main';
+ const type = activeReply.parentId ? "reply" : "main";
const isReply = type === "reply";
let rawText = mainInput.value;
@@ -455,13 +469,16 @@ const updateUIAfterSend = (type, params) => {
}
};
-// TODO:展开更多-收起
-const handleExpand = async (item) => {
+// TODO:展开
+const loadingReply = ref(false);
+const loadReplies = async (item) => {
+ if(!loadingReply.value) return;
+ loadingReply.value = true;
try {
// 后端获取最终的数据信息
// const res = await xxxxxx()
const res = [];
- const combined = [...(item.localReplies || []), ...res];
+ const combined = [...(item.localReplies || []), ...res, ...item.children];
item.children = combined.filter(
(v, i, a) => a.findIndex((t) => t.id === v.id) === i
);
@@ -469,9 +486,17 @@ const handleExpand = async (item) => {
item.showAllReplies = true;
} catch (error) {
console.log("error", error);
+ } finally {
+ loading.value = false;
}
};
+// 收起
+const collapseReplies = (item) => {
+ item.showAllReplies = false;
+ // nextTick(() => scrollIntoView(item.id));
+};
+
/**
* @param {string} text - 原始文本
* @param {Array} atUsers - 这条评论真正圈到的人员列表