From 68df4582c1edaf1952e6c21d769981e348fb3d04 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 20 二月 2025 18:00:29 +0800 Subject: [PATCH] 流输出 --- src/components/chat/chatComponents/hooks/useDrawChatChart.ts | 35 +++++++++++++++++++++++------------ 1 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/components/chat/chatComponents/hooks/useDrawChatChart.ts b/src/components/chat/chatComponents/hooks/useDrawChatChart.ts index fc80503..2f057e5 100644 --- a/src/components/chat/chatComponents/hooks/useDrawChatChart.ts +++ b/src/components/chat/chatComponents/hooks/useDrawChatChart.ts @@ -16,27 +16,38 @@ resizeChart?.(width, height); }; - onMounted(() => { + const initChart = () => { setTimeout(() => { - const parent = chartRef.value.parentElement; - const parentBound = parent.getBoundingClientRect(); - chartInstance.value = echarts.init(chartRef.value, undefined, { - width: parentBound.width, - height: parentBound.height, - }); - resizeChart = debounce((width, height) => { - chartInstance.value.resize({ - width: width, - height: height, + const instance = echarts.getInstanceByDom(chartRef.value); + if (!instance) { + const parent = chartRef.value.parentElement; + const parentBound = parent.getBoundingClientRect(); + + chartInstance.value = echarts.init(chartRef.value, undefined, { + width: parentBound.width, + height: parentBound.height, + locale: 'ZH', }); - }); + + resizeChart = debounce((width, height) => { + chartInstance.value.resize({ + width: width, + height: height, + }); + }); + } drawChart(); }, 100); + }; + + onMounted(() => { + initChart(); }); return { chartContainerResize, chartInstance, + }; }; -- Gitblit v1.9.3