From 7d90d4b0f06fcc743ed8fb4d275292969f77396a Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 23 Nov 2025 12:02:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E6=95=B0=E6=8D=AE=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/deno.jsonc | 3 +-- client/ui/chat/Message.tsx | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/client/deno.jsonc b/client/deno.jsonc index c7b8afc..8c259ba 100644 --- a/client/deno.jsonc +++ b/client/deno.jsonc @@ -34,7 +34,6 @@ "socket.io-client": "npm:socket.io-client@4.8.1", "marked": "npm:marked@16.3.0", "dompurify": "npm:dompurify@3.2.7", - "pinch-zoom-element": "npm:pinch-zoom-element@1.1.1", - "react-json-view": "npm:react-json-view@1.21.3" + "pinch-zoom-element": "npm:pinch-zoom-element@1.1.1" } } diff --git a/client/ui/chat/Message.tsx b/client/ui/chat/Message.tsx index 8af3c92..2356323 100644 --- a/client/ui/chat/Message.tsx +++ b/client/ui/chat/Message.tsx @@ -9,7 +9,6 @@ import useAsyncEffect from "../useAsyncEffect.ts" import useEventListener from "../useEventListener.ts" import React from "react" import isMobileUI from "../isMobileUI.ts" -import ReactJson from 'react-json-view' import User from "../../api/client_data/User.ts" import getUrlForFileByHash from "../../getUrlForFileByHash.ts" import escapeHTML from "../../escapeHtml.ts" @@ -86,11 +85,7 @@ export default function Message({ userId, rawData, renderHTML, message, openUser }, [userId]) const dropDownRef = React.useRef(null) - const messageJsonDialogRef = React.useRef(null) - useEventListener(messageJsonDialogRef, 'click', (e) => { - e.stopPropagation() - }) - useEventListener(dropDownRef, 'closed', (e) => { + useEventListener(dropDownRef, 'closed', () => { setDropDownOpen(false) }) @@ -180,12 +175,6 @@ export default function Message({ userId, rawData, renderHTML, message, openUser // paddingTop: isUsingFullDisplay ? undefined : "14px", // backgroundColor: isUsingFullDisplay ? "inherit" : undefined }}> - - { - // @ts-ignore 这是可以正常工作的 - - } - copyToClipboard($(dropDownRef.current as HTMLElement).find('#msg').text().trim())}>复制文字 copyToClipboard(rawData)}>复制原文 - messageJsonDialogRef.current!.open = true}>JSON + dialog({ + headline: "原始数据", + body: `${Object.keys(message) + // @ts-ignore 懒 + .map((k) => `${k} = ${message[k]}`) + .join('

')}`, + closeOnEsc: true, + closeOnOverlayClick: true, + actions: [ + { + text: "关闭", + onClick: () => { + return true + }, + } + ] + }).addEventListener('click', (e) => e.stopPropagation())}>原始数据