* perf: 优化Vben Modal destroyOnClose,解决destroyOnClose=false,Modal依旧会被销毁的问题 影响范围(重要):destroyOnClose默认为true,这会导致所有的modal都会默认渲染到body radix-vue Dialog组件默认会销毁挂载的组件,所以即使destroyOnClose=false,Modal依旧会被销毁的问题 对于一些大表单重复渲染导致卡顿,ApiComponent也会频繁的加载数据 * fix: modal closing animation --------- Co-authored-by: Netfan <netfan@foxmail.com>
50 lines
1.1 KiB
Vue
50 lines
1.1 KiB
Vue
<script lang="ts" setup>
|
|
import { ref } from 'vue';
|
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
import { Button, message } from 'ant-design-vue';
|
|
|
|
const list = ref<number[]>([]);
|
|
|
|
const [Modal, modalApi] = useVbenModal({
|
|
onCancel() {
|
|
modalApi.close();
|
|
},
|
|
onConfirm() {
|
|
message.info('onConfirm');
|
|
},
|
|
onOpenChange(isOpen) {
|
|
if (isOpen) {
|
|
handleUpdate();
|
|
}
|
|
},
|
|
});
|
|
|
|
function handleUpdate(len?: number) {
|
|
modalApi.setState({ confirmDisabled: true, loading: true });
|
|
setTimeout(() => {
|
|
list.value = Array.from(
|
|
{ length: len ?? Math.floor(Math.random() * 10) + 1 },
|
|
(_v, k) => k + 1,
|
|
);
|
|
modalApi.setState({ confirmDisabled: false, loading: false });
|
|
}, 2000);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Modal title="自动计算高度">
|
|
<div
|
|
v-for="item in list"
|
|
:key="item"
|
|
class="even:bg-heavy bg-muted flex-center h-[220px] w-full"
|
|
>
|
|
{{ item }}
|
|
</div>
|
|
<template #prepend-footer>
|
|
<Button type="link" @click="handleUpdate()">点击更新数据</Button>
|
|
</template>
|
|
</Modal>
|
|
</template>
|