pref: optimize dialog property (#158)

This commit is contained in:
Hayden
2025-03-03 17:02:03 +08:00
committed by GitHub
parent 7378a7deae
commit 384a106917
3 changed files with 19 additions and 11 deletions

View File

@@ -1,16 +1,9 @@
<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"
v-model:visible="item.visible"
v-bind="omitProps(item)"
:auto-z-index="false"
:pt:mask:style="{ zIndex: baseZIndex + index + 1 }"
:pt:root:onMousedown="() => rise(item)"
@@ -42,7 +35,8 @@
<script setup lang="ts">
import ResponseDialog from 'components/ResponseDialog.vue'
import { useDialog } from 'hooks/dialog'
import { type DialogItem, useDialog } from 'hooks/dialog'
import { omit } from 'lodash'
import Button from 'primevue/button'
import { usePrimeVue } from 'primevue/config'
import Dialog from 'primevue/dialog'
@@ -55,4 +49,15 @@ const { config } = usePrimeVue()
const baseZIndex = computed(() => {
return config.zIndex?.modal ?? 1100
})
const omitProps = (item: DialogItem) => {
return omit(item, [
'key',
'visible',
'title',
'headerButtons',
'content',
'contentProps',
])
}
</script>

View File

@@ -3,6 +3,7 @@
ref="dialogRef"
:visible="true"
@update:visible="updateVisible"
:modal="modal"
:close-on-escape="false"
:maximizable="!isMobile"
maximizeIcon="pi pi-arrow-up-right-and-arrow-down-left-from-center"
@@ -91,6 +92,7 @@ interface Props {
minHeight?: number
maxHeight?: number
zIndex?: number
modal?: boolean
}
const props = withDefaults(defineProps<Props>(), {

View File

@@ -8,7 +8,7 @@ interface HeaderButton {
command: () => void
}
interface DialogItem {
export interface DialogItem {
key: string
title: string
content: Component
@@ -22,6 +22,7 @@ interface DialogItem {
maxWidth?: number
minHeight?: number
maxHeight?: number
modal?: boolean
}
export const useDialog = defineStore('dialog', () => {