From 057bd335d6d2e6a653c5a6eac06d19aea74189a8 Mon Sep 17 00:00:00 2001 From: skytek_xinliang Date: Wed, 16 Sep 2026 09:29:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=80=E5=BE=8C=E9=87=8F=E6=B8=AC?= =?UTF-8?q?=E6=99=82=E9=96=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/physical-fitness.ts | 6 +++--- app/citizen-frontend/src/api/types.ts | 6 ++++++ .../src/components/PhysicalFitnessSummary.vue | 19 ++++++++++++++++++- app/citizen-frontend/src/pages/index.vue | 7 ++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/citizen-frontend/src/api/physical-fitness.ts b/app/citizen-frontend/src/api/physical-fitness.ts index ebbbd52..c60a525 100644 --- a/app/citizen-frontend/src/api/physical-fitness.ts +++ b/app/citizen-frontend/src/api/physical-fitness.ts @@ -1,16 +1,16 @@ import type { GeneratePhysicalFitnessResponse, - PhysicalFitnessItem, + PhysicalFitnessResponse, } from "./types"; import { api } from "./client"; /** 取得指定使用者的 11 項最新體適能測驗成績。 */ export function fetchPhysicalFitness( userID: string, -): Promise { +): Promise { return api .get(`v1/physical-fitness/${encodeURIComponent(userID)}`) - .json(); + .json(); } /** 產生指定使用者的體適能評級。 */ diff --git a/app/citizen-frontend/src/api/types.ts b/app/citizen-frontend/src/api/types.ts index 047e455..e4232b7 100644 --- a/app/citizen-frontend/src/api/types.ts +++ b/app/citizen-frontend/src/api/types.ts @@ -12,6 +12,12 @@ export interface PhysicalFitnessItem { fitnessScore: string | null; } +/** PhysicalFitnessController 回傳的最新體適能測驗資料。 */ +export interface PhysicalFitnessResponse { + results: PhysicalFitnessItem[]; + ReceivedAt: string | null; +} + /** PhysicalFitnessController 產生評級的回應。 */ export interface GeneratePhysicalFitnessResponse { message: string; diff --git a/app/citizen-frontend/src/components/PhysicalFitnessSummary.vue b/app/citizen-frontend/src/components/PhysicalFitnessSummary.vue index bb367a2..fd6cd5e 100644 --- a/app/citizen-frontend/src/components/PhysicalFitnessSummary.vue +++ b/app/citizen-frontend/src/components/PhysicalFitnessSummary.vue @@ -19,7 +19,7 @@ - 顯示目前帳號各測驗項目的最新成績。 + 最後量測時間:{{ formattedReceivedAt }} (); defineEmits<{ @@ -125,6 +126,22 @@ const displayItems = computed(() => const completedCount = computed( () => displayItems.value.filter((item) => item.fitnessScore !== null).length, ); + +const formattedReceivedAt = computed(() => { + if (!props.receivedAt) { + return "無資料"; + } + + const receivedAt = new Date(props.receivedAt); + if (Number.isNaN(receivedAt.getTime())) { + return "無資料"; + } + + return new Intl.DateTimeFormat("zh-TW", { + dateStyle: "medium", + timeStyle: "short", + }).format(receivedAt); +});