From 1d4e048777585d54693758ec6495595ce3ebdb00 Mon Sep 17 00:00:00 2001 From: "Yoan.liu" Date: Sat, 14 Jun 2025 21:51:10 +0800 Subject: [PATCH] refactor code --- ui/src/pages/certificates/CertificateList.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/pages/certificates/CertificateList.tsx b/ui/src/pages/certificates/CertificateList.tsx index f44b8168..52dadf39 100644 --- a/ui/src/pages/certificates/CertificateList.tsx +++ b/ui/src/pages/certificates/CertificateList.tsx @@ -111,16 +111,16 @@ const CertificateList = () => { const total = dayjs(record.expireAt).diff(dayjs(record.created), "d") + 1; // 使用 isAfter 更精确地判断是否过期 const isExpired = dayjs().isAfter(dayjs(record.expireAt)); - const left = dayjs(record.expireAt).diff(dayjs(), "d"); - const hours = dayjs(record.expireAt).diff(dayjs(), "h"); + const leftDays = dayjs(record.expireAt).diff(dayjs(), "d"); + const leftHours = dayjs(record.expireAt).diff(dayjs(), "h"); return ( {!isExpired ? ( - left > 0 ? ( - {t("certificate.props.validity.left_days", { left, total })} + leftDays > 0 ? ( + {t("certificate.props.validity.left_days", { left: leftDays, total })} ) : ( - {t("certificate.props.validity.less_than_day", { hours: hours > 0 ? hours : 1 })} + {t("certificate.props.validity.less_than_day", { hours: leftHours > 0 ? leftHours : 1 })} ) ) : ( {t("certificate.props.validity.expired")}