From 3fa6532d9b3c55abe6fce07368c2d60af5f6e4b4 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 9 Jun 2025 23:02:34 +0800 Subject: [PATCH] refactor: convert post publish dates to human-readable format (#7526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind improvement /milestone 2.21.x #### What this PR does / why we need it: image #### Does this PR introduce a user-facing change? ```release-note 将 Console 端文章列表的发布时间改为语义化时间 ``` --- .../contents/pages/DeletedSinglePageList.vue | 13 ++- .../pages/components/SinglePageListItem.vue | 13 ++- .../contents/posts/DeletedPostList.vue | 13 ++- .../posts/components/PostListItem.vue | 1 + .../entity-fields/PublishTimeField.vue | 9 +- .../presets/posts/RecentPublishedWidget.vue | 76 ++-------------- .../presets/posts/components/PostListItem.vue | 91 +++++++++++++++++++ ui/src/locales/en.yaml | 1 - ui/src/locales/zh-CN.yaml | 1 - ui/src/locales/zh-TW.yaml | 1 - .../posts/components/PostListItem.vue | 9 +- 11 files changed, 130 insertions(+), 98 deletions(-) create mode 100644 ui/console-src/modules/dashboard/widgets/presets/posts/components/PostListItem.vue diff --git a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue index 2c62e865e..85ce24d89 100644 --- a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue +++ b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue @@ -1,6 +1,6 @@ + + diff --git a/ui/src/locales/en.yaml b/ui/src/locales/en.yaml index f9517825b..cb2ae898e 100644 --- a/ui/src/locales/en.yaml +++ b/ui/src/locales/en.yaml @@ -66,7 +66,6 @@ core: title: Recent Posts visits: "{visits} Visits" comments: "{comments} Comments" - publishTime: Publish Time {publishTime} notification: title: Notifications empty: diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml index 6ddc2a192..6f8c5bc6e 100644 --- a/ui/src/locales/zh-CN.yaml +++ b/ui/src/locales/zh-CN.yaml @@ -64,7 +64,6 @@ core: title: 最近文章 visits: 访问量 {visits} comments: 评论 {comments} - publishTime: 发布日期 {publishTime} notification: title: 通知 empty: diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml index be3312ff8..1f8d9c768 100644 --- a/ui/src/locales/zh-TW.yaml +++ b/ui/src/locales/zh-TW.yaml @@ -64,7 +64,6 @@ core: title: 最近文章 visits: 訪問量 {visits} comments: 留言 {comments} - publishTime: 發佈日期 {publishTime} notification: title: 通知 empty: diff --git a/ui/uc-src/modules/contents/posts/components/PostListItem.vue b/ui/uc-src/modules/contents/posts/components/PostListItem.vue index 88b074f64..95b5ad781 100644 --- a/ui/uc-src/modules/contents/posts/components/PostListItem.vue +++ b/ui/uc-src/modules/contents/posts/components/PostListItem.vue @@ -3,7 +3,7 @@ import StatusDotField from "@/components/entity-fields/StatusDotField.vue"; import HasPermission from "@/components/permission/HasPermission.vue"; import PostContributorList from "@/components/user/PostContributorList.vue"; import { postLabels } from "@/constants/labels"; -import { formatDatetime } from "@/utils/date"; +import { formatDatetime, relativeTimeTo } from "@/utils/date"; import PostTag from "@console/modules/contents/posts/tags/components/PostTag.vue"; import type { ListedPost } from "@halo-dev/api-client"; import { ucApiClient } from "@halo-dev/api-client"; @@ -238,8 +238,11 @@ function handleDelete() {