mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
图表增加了适配窗口大小
This commit is contained in:
parent
c1a37cdf53
commit
b8d8b8353f
@ -146,6 +146,20 @@ function EchartsComponent({ currentDate, setCurrentDate }: ComponentProps) {
|
||||
};
|
||||
}, [currentDate, searchDate]); // 空数组作为第二个参数,表示仅在组件挂载和卸载时执行
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
console.log("窗口大小变化");
|
||||
let chartDom = document.getElementById("usage-by-model-chart");
|
||||
if (!chartDom) return;
|
||||
const myChart = echarts.getInstanceByDom(chartDom);
|
||||
myChart?.resize();
|
||||
};
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
id="usage-by-model-chart"
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user