feat: 项目管理添加评论数和最后修改时间

This commit is contained in:
caiyuchao
2025-08-12 11:05:35 +08:00
parent f5c159d43d
commit 307172d5d7
4 changed files with 47 additions and 5 deletions

View File

@@ -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"
}

View File

@@ -20,5 +20,7 @@
"name": "项目名称",
"envInfoFile": "环境信息附件",
"list": "项目列表",
"progress": "进展"
"progress": "进展",
"updateTime": "最后修改时间",
"commentNum": "评论数"
}

View File

@@ -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;
}
</script>
<template>
<div id="article-comment" style="padding: 5px">
@@ -30,7 +57,7 @@ const sortByTime = () => {
{{ $t('comment.hotComment') }}
</span>
<span style="padding: 0 15px 0 5px; color: #9499a0">{{
comments?.length ?? 0
getCommentCount(comments)
}}</span>
</span>
<span

View File

@@ -422,11 +422,22 @@ export function useGridColumns(
visible: false,
minWidth: 120,
},
{
field: 'commentNum',
title: $t('project.commentNum'),
minWidth: 70,
},
{
field: 'updateTime',
title: $t('project.updateTime'),
minWidth: 130,
sortable: true,
formatter: 'formatDateTime',
},
{
field: 'createTime',
title: $t('project.creationTime'),
// visible: false,
minWidth: 120,
minWidth: 130,
formatter: 'formatDateTime',
},
{