Merge branch 'main' into fix

This commit is contained in:
Jin Mao
2026-01-23 13:48:54 +08:00
committed by GitHub
7 changed files with 84 additions and 14 deletions

View File

@@ -41,6 +41,18 @@ export function getElementVisibleRect(
const left = Math.max(rect.left, 0);
const right = Math.min(rect.right, viewWidth);
// 如果元素完全不可见,则返回一个空的矩形
if (top >= viewHeight || bottom <= 0 || left >= viewWidth || right <= 0) {
return {
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
};
}
return {
bottom,
height: Math.max(0, bottom - top),

View File

@@ -41,6 +41,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
// 不能用 Object.assign,会丢失 api 的原型函数
Object.setPrototypeOf(extendedApi, api);
},
consumed: false,
options,
async reCreateModal() {
isModalReady.value = false;
@@ -73,7 +74,13 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
return [Modal, extendedApi as ExtendedModalApi] as const;
}
const injectData = inject<any>(USER_MODAL_INJECT_KEY, {});
let injectData = inject<any>(USER_MODAL_INJECT_KEY, {});
// 这个数据已经被使用了说明这个弹窗是嵌套的弹窗不应该merge上层的配置
if (injectData.consumed) {
injectData = {};
} else {
injectData.consumed = true;
}
const mergedOptions = {
...DEFAULT_MODAL_PROPS,

View File

@@ -32,19 +32,19 @@ const props = withDefaults(defineProps<Props>(), {
// const startTime = ref(0);
const showSpinner = ref(false);
const renderSpinner = ref(false);
const timer = ref<ReturnType<typeof setTimeout>>();
let timer: ReturnType<typeof setTimeout> | undefined;
watch(
() => props.spinning,
(show) => {
if (!show) {
showSpinner.value = false;
clearTimeout(timer.value);
timer && clearTimeout(timer);
return;
}
// startTime.value = performance.now();
timer.value = setTimeout(() => {
timer = setTimeout(() => {
// const loadingTime = performance.now() - startTime.value;
showSpinner.value = true;

View File

@@ -92,7 +92,8 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
return;
}
useTimeoutFn(() => {
if (!chartInstance) {
if (!chartInstance || chartInstance?.getDom() !== el) {
chartInstance?.dispose();
const instance = initCharts();
if (!instance) return;
}
@@ -104,6 +105,36 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
});
};
const updateDate = (
option: EChartsOption,
notMerge = false, // false = 合并保留动画true = 完全替换
lazyUpdate = false, // true 时不立即重绘,适合短时间内多次调用
): Promise<echarts.ECharts | null> => {
return new Promise((resolve) => {
nextTick(() => {
if (!chartInstance) {
// 还没初始化 → 当作首次渲染
renderEcharts(option).then(resolve);
return;
}
// 合并你原有的全局配置(比如 backgroundColor
const finalOption = {
...option,
...getOptions.value,
};
chartInstance.setOption(finalOption, {
notMerge,
lazyUpdate,
// silent: true, // 如果追求极致性能可开启(关闭所有事件)
});
resolve(chartInstance);
});
});
};
function resize() {
const el = getChartEl();
if (isElHidden(el)) {
@@ -139,6 +170,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
return {
renderEcharts,
resize,
updateDate,
getChartInstance: () => chartInstance,
};
}