From 8fbef715eed1ba1f28d52574d4d86159ecd1d4ab Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 28 Nov 2022 21:28:18 +0800 Subject: [PATCH] feat: set the approvedTime field during approve (#713) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /milestone 2.0 #### What this PR does / why we need it: 评论或者回复审核时设置审核时间。适配:https://github.com/halo-dev/halo/pull/2746 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2738 #### Special notes for your reviewer: 测试方式: 1. Halo 需要切换到 https://github.com/halo-dev/halo/issues/2738 分支。 2. Console 需要 `pnpm install` 3. 在主题端创建若干评论,然后去 Console 端审核通过,检查是否正常设置了审核时间。 #### Does this PR introduce a user-facing change? ```release-note Console 端在评论或者回复审核时设置审核时间。 ``` --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- src/modules/contents/comments/CommentList.vue | 2 ++ .../contents/comments/components/CommentListItem.vue | 8 ++++++-- .../contents/comments/components/ReplyListItem.vue | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index a1c198bb..af65dbc8 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@formkit/themes": "^1.0.0-beta.12", "@formkit/utils": "^1.0.0-beta.12", "@formkit/vue": "^1.0.0-beta.12", - "@halo-dev/api-client": "^0.0.53", + "@halo-dev/api-client": "^0.0.55", "@halo-dev/components": "workspace:*", "@halo-dev/console-shared": "workspace:*", "@halo-dev/richtext-editor": "^0.0.0-alpha.16", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc18ebd2..d60144b2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,7 +12,7 @@ importers: '@formkit/themes': ^1.0.0-beta.12 '@formkit/utils': ^1.0.0-beta.12 '@formkit/vue': ^1.0.0-beta.12 - '@halo-dev/api-client': ^0.0.53 + '@halo-dev/api-client': ^0.0.55 '@halo-dev/components': workspace:* '@halo-dev/console-shared': workspace:* '@halo-dev/richtext-editor': ^0.0.0-alpha.16 @@ -104,7 +104,7 @@ importers: '@formkit/themes': 1.0.0-beta.12-e579559_tailwindcss@3.2.4 '@formkit/utils': 1.0.0-beta.12-e579559 '@formkit/vue': 1.0.0-beta.12-e579559_ior6jr3fpijijuwpr34w2i25va - '@halo-dev/api-client': 0.0.53 + '@halo-dev/api-client': 0.0.55 '@halo-dev/components': link:packages/components '@halo-dev/console-shared': link:packages/shared '@halo-dev/richtext-editor': 0.0.0-alpha.16_vue@3.2.45 @@ -1962,8 +1962,8 @@ packages: - windicss dev: false - /@halo-dev/api-client/0.0.53: - resolution: {integrity: sha512-B3njjXFqTi28FfDhZ9VAVlv6mMQxLgIsBUqTPmMQF/IxWWtfN6cxYi7is+zmw+chFFe38UVaEAPSHORLMxnJ6A==} + /@halo-dev/api-client/0.0.55: + resolution: {integrity: sha512-n/XjFhCgUYYo3mrVsuCa11iyXkbBgcRGIT8fDfdkuLjzfXamxt0eJMFbz8lpH85pTh7O7xTQzCxvi5YIi7zBLw==} dev: false /@halo-dev/richtext-editor/0.0.0-alpha.16_vue@3.2.45: diff --git a/src/modules/contents/comments/CommentList.vue b/src/modules/contents/comments/CommentList.vue index b74169a7..42e2d9c4 100644 --- a/src/modules/contents/comments/CommentList.vue +++ b/src/modules/contents/comments/CommentList.vue @@ -170,6 +170,8 @@ const handleApproveInBatch = async () => { const promises = commentsToUpdate.map((comment) => { const commentToUpdate = comment.comment; commentToUpdate.spec.approved = true; + // TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746 + commentToUpdate.spec.approvedTime = new Date().toISOString(); return apiClient.extension.comment.updatecontentHaloRunV1alpha1Comment( { name: commentToUpdate.metadata.name, diff --git a/src/modules/contents/comments/components/CommentListItem.vue b/src/modules/contents/comments/components/CommentListItem.vue index dbf99efa..857aa581 100644 --- a/src/modules/contents/comments/components/CommentListItem.vue +++ b/src/modules/contents/comments/components/CommentListItem.vue @@ -85,6 +85,8 @@ const handleApproveReplyInBatch = async () => { const promises = repliesToUpdate.map((reply) => { const replyToUpdate = reply.reply; replyToUpdate.spec.approved = true; + // TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746 + replyToUpdate.spec.approvedTime = new Date().toISOString(); return apiClient.extension.reply.updatecontentHaloRunV1alpha1Reply({ name: replyToUpdate.metadata.name, reply: replyToUpdate, @@ -104,6 +106,8 @@ const handleApprove = async () => { try { const commentToUpdate = cloneDeep(props.comment.comment); commentToUpdate.spec.approved = true; + // TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746 + commentToUpdate.spec.approvedTime = new Date().toISOString(); await apiClient.extension.comment.updatecontentHaloRunV1alpha1Comment({ name: commentToUpdate.metadata.name, comment: commentToUpdate, @@ -358,10 +362,10 @@ const subjectRefResult = computed(() => { - + diff --git a/src/modules/contents/comments/components/ReplyListItem.vue b/src/modules/contents/comments/components/ReplyListItem.vue index 56640db1..6cdf6f8d 100644 --- a/src/modules/contents/comments/components/ReplyListItem.vue +++ b/src/modules/contents/comments/components/ReplyListItem.vue @@ -66,6 +66,8 @@ const handleApprove = async () => { try { const replyToUpdate = cloneDeep(props.reply.reply); replyToUpdate.spec.approved = true; + // TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746 + replyToUpdate.spec.approvedTime = new Date().toISOString(); await apiClient.extension.reply.updatecontentHaloRunV1alpha1Reply({ name: replyToUpdate.metadata.name, reply: replyToUpdate, @@ -164,10 +166,10 @@ const isHoveredReply = computed(() => { - +