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; +}