mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-26 13:48:12 +00:00
perf: performance optimization
This commit is contained in:
@@ -14,6 +14,7 @@ export function useECharts(
|
||||
) {
|
||||
const chartInstanceRef = ref<Nullable<ECharts>>(null);
|
||||
let resizeFn: Fn = resize;
|
||||
let removeResizeFn: Fn = () => {};
|
||||
|
||||
const [debounceResize] = useDebounce(resize, 200);
|
||||
resizeFn = debounceResize;
|
||||
@@ -25,11 +26,12 @@ export function useECharts(
|
||||
return;
|
||||
}
|
||||
chartInstanceRef.value = echarts.init(el, theme);
|
||||
useEvent({
|
||||
const { removeEvent } = useEvent({
|
||||
el: window,
|
||||
name: 'resize',
|
||||
listener: resizeFn,
|
||||
});
|
||||
removeResizeFn = removeEvent;
|
||||
const { widthRef, screenEnum } = useBreakpoint();
|
||||
if (unref(widthRef) <= screenEnum.MD) {
|
||||
useTimeout(() => {
|
||||
@@ -37,6 +39,9 @@ export function useECharts(
|
||||
}, 30);
|
||||
}
|
||||
}
|
||||
tryOnUnmounted(() => {
|
||||
removeResizeFn();
|
||||
});
|
||||
|
||||
function setOptions(options: any, clear = true) {
|
||||
nextTick(() => {
|
||||
|
Reference in New Issue
Block a user