feat: Optimize dialog

- Change the method of open dialog
- Fix the problem of open dialog disappearing due to virtual scrolling
- Float the active dialog to the top
This commit is contained in:
hayden
2024-10-29 15:32:30 +08:00
parent 14a31a8ca8
commit 6934fbb331
17 changed files with 547 additions and 590 deletions

View File

@@ -0,0 +1,46 @@
<template>
<ResponseDialog
v-for="(item, index) in stack"
v-model:visible="item.visible"
:key="item.key"
:keep-alive="item.keepAlive"
:default-size="item.defaultSize"
:default-mobile-size="item.defaultMobileSize"
:resize-allow="item.resizeAllow"
:min-width="item.minWidth"
:max-width="item.maxWidth"
:min-height="item.minHeight"
:max-height="item.maxHeight"
:z-index="index"
:pt:root:onMousedown="() => rise(item)"
@hide="() => close(item)"
>
<template #header>
<div class="flex flex-1 items-center justify-between pr-2">
<span class="p-dialog-title select-none">{{ item.title }}</span>
<div class="p-dialog-header-actions">
<Button
v-for="action in item.headerButtons"
severity="secondary"
:text="true"
:rounded="true"
:icon="action.icon"
@click.stop="action.command"
></Button>
</div>
</div>
</template>
<template #default>
<component :is="item.content" v-bind="item.contentProps"></component>
</template>
</ResponseDialog>
</template>
<script setup lang="ts">
import Button from 'primevue/button'
import ResponseDialog from 'components/ResponseDialog.vue'
import { useDialog } from 'hooks/dialog'
const { stack, rise, close } = useDialog()
</script>