From 1f6f8a768f8eb9d00fc64d125910838eb3b0f4c9 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 30 Nov 2025 00:32:27 +0800 Subject: [PATCH] =?UTF-8?q?ui:=20=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E7=BC=AE:=20=E5=B0=8F=E6=97=B6=E5=92=8C=E5=88=86?= =?UTF-8?q?=E9=92=9F=E8=A1=A5=E9=BD=90=E4=B8=80=E4=B8=AA=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ui/chat/ChatFragment.tsx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index 70c76f8..467ef5b 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -1,4 +1,4 @@ -import { Tab, TextField } from "mdui" +import { Tab, Tabs, TextField } from "mdui" import { $ } from "mdui/jq" import useEventListener from "../useEventListener.ts" import Element_Message from "./Message.tsx" @@ -31,6 +31,7 @@ import JoinRequestsList from "./JoinRequestsList.tsx" import getUrlForFileByHash from "../../getUrlForFileByHash.ts" import escapeHTML from "../../escapeHtml.ts" import GroupMembersList from "./GroupMembersList.tsx" +import isMobileUI from "../isMobileUI.ts" interface Args extends React.HTMLAttributes { target: string @@ -455,9 +456,20 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC { (() => { let date = new Date(0) + let user: string + function timeAddZeroPrefix(t: number) { + if (t >= 0 && t < 10) + return '0' + t + return t + '' + } return messagesList.map((msg) => { const lastDate = date + const lastUser = user date = new Date(msg.time) + user = msg.user_id + + const shouldShowTime = msg.user_id != null && + (date.getMinutes() != lastDate.getMinutes() || date.getDate() != lastDate.getDate() || date.getMonth() != lastDate.getMonth() || date.getFullYear() != lastDate.getFullYear()) const msgElement = msg.user_id == null ?
{ - msg.user_id != null && - (date.getMinutes() != lastDate.getMinutes() || date.getDate() != lastDate.getDate() || date.getMonth() != lastDate.getMonth() || date.getFullYear() != lastDate.getFullYear()) + shouldShowTime &&
{ (date.getFullYear() != lastDate.getFullYear() ? `${date.getFullYear()}年` : '') + `${date.getMonth() + 1}月` + `${date.getDate()}日` - + ` ${date.getHours()}:${date.getMinutes()}` + + ` ${timeAddZeroPrefix(date.getHours())}:${timeAddZeroPrefix(date.getMinutes())}` }