From c4bd70f83214f77f3f5baa620a8570a60e09fbe3 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 30 Sep 2025 11:39:21 +0800 Subject: [PATCH] Refactor thumbnail size handling to use enum Replaced string literals for thumbnail sizes with GetThumbnailByUriSizeEnum throughout the codebase for improved type safety and consistency. Updated generateThumbnailUrl to accept the enum and added a width map for local URLs. Improved attachment thumbnail display and link formatting. --- .../AttachmentSingleThumbnailItem.vue | 3 +-- .../contents/pages/DeletedSinglePageList.vue | 11 ++++++++-- .../components/entity-fields/CoverField.vue | 12 +++++++++-- .../contents/posts/DeletedPostList.vue | 13 ++++++++++-- .../components/entity-fields/CoverField.vue | 12 +++++++++-- ui/src/utils/thumbnail.ts | 20 ++++++++++++++++++- .../posts/components/PostListItem.vue | 9 +++++++-- 7 files changed, 67 insertions(+), 13 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/components/AttachmentSingleThumbnailItem.vue b/ui/console-src/modules/contents/attachments/components/AttachmentSingleThumbnailItem.vue index e8e3ef669..1056b635f 100644 --- a/ui/console-src/modules/contents/attachments/components/AttachmentSingleThumbnailItem.vue +++ b/ui/console-src/modules/contents/attachments/components/AttachmentSingleThumbnailItem.vue @@ -17,7 +17,6 @@ const { size, permalink } = withDefaults( @@ -29,7 +28,7 @@ const { size, permalink } = withDefaults( {{ permalink }} diff --git a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue index cb2ce45b5..5e828c365 100644 --- a/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue +++ b/ui/console-src/modules/contents/pages/DeletedSinglePageList.vue @@ -4,7 +4,11 @@ import { formatDatetime, relativeTimeTo } from "@/utils/date"; import { usePermission } from "@/utils/permission"; import { generateThumbnailUrl } from "@/utils/thumbnail"; import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client"; -import { consoleApiClient, coreApiClient } from "@halo-dev/api-client"; +import { + consoleApiClient, + coreApiClient, + GetThumbnailByUriSizeEnum, +} from "@halo-dev/api-client"; import { Dialog, IconAddCircle, @@ -315,7 +319,10 @@ watch( diff --git a/ui/console-src/modules/contents/pages/components/entity-fields/CoverField.vue b/ui/console-src/modules/contents/pages/components/entity-fields/CoverField.vue index 81a47065b..23fe00e3e 100644 --- a/ui/console-src/modules/contents/pages/components/entity-fields/CoverField.vue +++ b/ui/console-src/modules/contents/pages/components/entity-fields/CoverField.vue @@ -1,6 +1,9 @@