From 307172d5d7546adbb0ac34825cb928cf262f2585 Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Tue, 12 Aug 2025 11:05:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=E6=95=B0=E5=92=8C=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/locales/langs/en-US/project.json | 4 ++- .../src/locales/langs/zh-CN/project.json | 4 ++- .../views/license/project/comment/index.vue | 29 ++++++++++++++++++- .../src/views/license/project/data.ts | 15 ++++++++-- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/apps/web-antd/src/locales/langs/en-US/project.json b/apps/web-antd/src/locales/langs/en-US/project.json index 166d038..e8804ca 100644 --- a/apps/web-antd/src/locales/langs/en-US/project.json +++ b/apps/web-antd/src/locales/langs/en-US/project.json @@ -20,5 +20,7 @@ "name": "Project Name", "envInfoFile": "Environment Info Attachment", "list": "Project List", - "progress": "Progress" + "progress": "Progress", + "updateTime": "Last Modified Time", + "commentNum": "Comment Count" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/project.json b/apps/web-antd/src/locales/langs/zh-CN/project.json index 31a2bbe..40bdba9 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/project.json +++ b/apps/web-antd/src/locales/langs/zh-CN/project.json @@ -20,5 +20,7 @@ "name": "项目名称", "envInfoFile": "环境信息附件", "list": "项目列表", - "progress": "进展" + "progress": "进展", + "updateTime": "最后修改时间", + "commentNum": "评论数" } diff --git a/apps/web-antd/src/views/license/project/comment/index.vue b/apps/web-antd/src/views/license/project/comment/index.vue index 8ef991f..691f420 100644 --- a/apps/web-antd/src/views/license/project/comment/index.vue +++ b/apps/web-antd/src/views/license/project/comment/index.vue @@ -21,6 +21,33 @@ const sortByTime = () => { isSortAsc.value = !isSortAsc.value; emit('getCommentByProjectId', props.projectId, isSortAsc.value); }; + +function countNodes(tree: CommentApi.Comment) { + if (tree === null) { + return 0; + } + let count = 1; // 当前节点 + if (!tree.children || tree.children.length === 0 || (tree?.depth ?? 0) > 1) { + return count; // 如果没有子节点,直接返回当前节点数量 + } + for (let i = 0; i < tree.children.length; i++) { + if (tree.children[i] !== undefined) { + count += countNodes(tree.children[i] as CommentApi.Comment); // 递归计算子节点的数量 + } + } + return count; +} + +function getCommentCount(comments?: CommentApi.Comment[]) { + if (!comments || comments.length === 0) { + return 0; + } + let count = 0; + for (const comment of comments) { + count += countNodes(comment); + } + return count; +}