From 0a617ef917aa9f711b6dfe845ec6c2cbb7730fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Thu, 21 Nov 2024 21:02:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B2=99=E7=9B=92=E5=8F=AF=E5=A4=8D?= =?UTF-8?q?=E8=AF=BB=E8=87=AA=E5=B7=B1=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Bot/sandbox/index.vue | 37 ++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/views/Bot/sandbox/index.vue b/src/views/Bot/sandbox/index.vue index dbaed898..c7a0a4e4 100644 --- a/src/views/Bot/sandbox/index.vue +++ b/src/views/Bot/sandbox/index.vue @@ -82,7 +82,23 @@
{{ msg.name }}
- +
+ + + + + +
@@ -185,6 +201,7 @@ import { createWS } from "@/api/utils"; import { buildPrefixUUID, openLink } from "@pureadmin/utils"; import { Link } from "@element-plus/icons-vue"; import Menu from "./components/menu.vue"; +import { IconifyIconOnline as Iconify } from "@/components/ReIcon"; defineOptions({ name: "sandbox" @@ -297,6 +314,7 @@ type msgDataType = { msgId?: string; bot?: boolean; message?: DefineComponent; + rawMessage?: string; poke?: { operatorId: string; targetId: string; @@ -369,9 +387,16 @@ const sendWsMessage = (content: string, push: boolean = true) => { target.push({ name: selectUser.value, msgId, + rawMessage: content, message: defineComponent({ render() { - return h("div", { class: "message", innerHTML: input }); + return h("div", { + class: "message", + innerHTML: input, + style: { + maxWidth: `${bodyWidth.value}px` + } + }); } }) }); @@ -380,6 +405,12 @@ const sendWsMessage = (content: string, push: boolean = true) => { } }; +const handleAgainMsg = (msg: msgDataType) => { + if (msg.rawMessage) { + sendWsMessage(msg.rawMessage, true); + } +}; + const setScrollToBottom = () => { nextTick(() => { const bottom = messageScrollbarRef.value.wrapRef.scrollHeight; @@ -444,7 +475,7 @@ onMounted(() => { window.addEventListener("resize", updateWidth); bodyWidth.value = (cardRef.value.$el.clientWidth - 140 - (isCollapse.value ? 60 : 200)) * - (isCollapse.value ? 1 : 0.8); + (isCollapse.value ? 1.1 : 0.8); socket.value = createWS("sandbox", { onopen(ev) { socket.value.send(