mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 19:29:04 +08:00
perf(modal): optimize table embedding height calculation problem
This commit is contained in:
@@ -225,11 +225,11 @@ export default defineComponent({
|
||||
{...{ ...attrs, ...props, ...unref(getProps) }}
|
||||
>
|
||||
{{
|
||||
footer: () => renderFooter(),
|
||||
closeIcon: () => renderClose(),
|
||||
title: () => renderTitle(),
|
||||
...extendSlots(slots, ['default']),
|
||||
default: () => renderContent(),
|
||||
closeIcon: () => renderClose(),
|
||||
footer: () => renderFooter(),
|
||||
title: () => renderTitle(),
|
||||
}}
|
||||
</Modal>
|
||||
);
|
||||
|
@@ -15,10 +15,12 @@ import {
|
||||
import { Spin } from 'ant-design-vue';
|
||||
|
||||
import { useWindowSizeFn } from '/@/hooks/event/useWindowSize';
|
||||
import { useTimeout } from '/@/hooks/core/useTimeout';
|
||||
// import { useTimeout } from '/@/hooks/core/useTimeout';
|
||||
|
||||
import { getSlot } from '/@/utils/helper/tsxHelper';
|
||||
import { useElResize } from '/@/hooks/event/useElResize';
|
||||
import { provideModal } from './provideModal';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModalWrapper',
|
||||
props: {
|
||||
@@ -56,6 +58,11 @@ export default defineComponent({
|
||||
const wrapperRef = ref<HTMLElement | null>(null);
|
||||
const spinRef = ref<any>(null);
|
||||
const realHeightRef = ref(0);
|
||||
// 重试次数
|
||||
// let tryCount = 0;
|
||||
let stopElResizeFn: Fn = () => {};
|
||||
|
||||
provideModal(setModalHeight);
|
||||
|
||||
const wrapStyle = computed(() => {
|
||||
return {
|
||||
@@ -65,10 +72,6 @@ export default defineComponent({
|
||||
};
|
||||
});
|
||||
|
||||
// 重试次数
|
||||
let tryCount = 0;
|
||||
let stopElResizeFn: Fn = () => {};
|
||||
|
||||
watchEffect(() => {
|
||||
setModalHeight();
|
||||
});
|
||||
@@ -123,17 +126,17 @@ export default defineComponent({
|
||||
}
|
||||
await nextTick();
|
||||
const spinEl = unref(spinRef);
|
||||
if (!spinEl) {
|
||||
useTimeout(() => {
|
||||
// retry
|
||||
if (tryCount < 3) {
|
||||
setModalHeight();
|
||||
}
|
||||
tryCount++;
|
||||
}, 10);
|
||||
return;
|
||||
}
|
||||
tryCount = 0;
|
||||
// if (!spinEl) {
|
||||
// useTimeout(() => {
|
||||
// // retry
|
||||
// if (tryCount < 3) {
|
||||
// setModalHeight();
|
||||
// }
|
||||
// tryCount++;
|
||||
// }, 10);
|
||||
// return;
|
||||
// }
|
||||
// tryCount = 0;
|
||||
|
||||
const spinContainerEl = spinEl.$el.querySelector('.ant-spin-container') as HTMLElement;
|
||||
if (!spinContainerEl) return;
|
||||
|
11
src/components/Modal/src/provideModal.ts
Normal file
11
src/components/Modal/src/provideModal.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { provide, inject } from 'vue';
|
||||
|
||||
const key = Symbol('basic-modal');
|
||||
|
||||
export function provideModal(redoHeight: Fn) {
|
||||
provide(key, redoHeight);
|
||||
}
|
||||
|
||||
export function injectModal(): Fn {
|
||||
return inject(key) as Fn;
|
||||
}
|
Reference in New Issue
Block a user