From 58f94ac646ce797c0d9847a6617a0250abeeceb5 Mon Sep 17 00:00:00 2001 From: al Date: Tue, 21 Jan 2025 15:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- screeens/NoticeDetail/SystemNotice/index.jsx | 60 ++++++++++--------- .../components/NoticeItem/index.jsx | 14 ++++- screeens/Search/HostList/index.jsx | 2 +- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/screeens/NoticeDetail/SystemNotice/index.jsx b/screeens/NoticeDetail/SystemNotice/index.jsx index a8e1ca1..78c7506 100644 --- a/screeens/NoticeDetail/SystemNotice/index.jsx +++ b/screeens/NoticeDetail/SystemNotice/index.jsx @@ -89,35 +89,37 @@ export default function SystemNotice({ navigation, route, ...props }) { } }; return ( - - {data.map((it) => ( - - - - } - /> - ))} - {!data.length && } + + + {data.map((it) => ( + + + + } + /> + ))} + {!data.length && } + ); } diff --git a/screeens/NoticeDetail/components/NoticeItem/index.jsx b/screeens/NoticeDetail/components/NoticeItem/index.jsx index eeea6b5..86d18e8 100644 --- a/screeens/NoticeDetail/components/NoticeItem/index.jsx +++ b/screeens/NoticeDetail/components/NoticeItem/index.jsx @@ -6,6 +6,7 @@ import { formatDate, goToPage } from "../../../../utils/tools"; import { Image } from "expo-image"; import Toast from "react-native-toast-message"; import * as Linking from "expo-linking"; +import dayjs from "dayjs"; export default function NoticeItem({ navigation, leftIcon, hasLink, data }) { const tailwind = useTailwind(); // const currentLink = useMemo(() => { @@ -16,6 +17,17 @@ export default function NoticeItem({ navigation, leftIcon, hasLink, data }) { // return hasAppLink ?? null; // } // }, [data]); + //日期格式 + const renderDay = (time) => { + const now = dayjs(); + if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 1) { + return dayjs(time * 1000).format("HH:mm"); + } else if (now.diff(dayjs(time * 1000), "hour") - now.hour() < 24) { + return "昨天" + dayjs(time * 1000).format("HH:mm"); + } else { + return dayjs(time * 1000).format("MM-DD"); + } + }; return ( - {formatDate(data?.push_time || data?.ct)} + {renderDay(data?.push_time || data?.ct)} diff --git a/screeens/Search/HostList/index.jsx b/screeens/Search/HostList/index.jsx index 45e038c..99e9bdc 100644 --- a/screeens/Search/HostList/index.jsx +++ b/screeens/Search/HostList/index.jsx @@ -247,7 +247,7 @@ export default function HostList() { ))} {/* Banner预留位置 */} - +