feat(dialog): Optimize dialog closing logic (#97)

- Add optional parameters to the close function to support parameterless calling
- When the dialog parameter is not provided, automatically close the dialog box on the top of the stack
This commit is contained in:
Hayden
2025-01-15 16:03:46 +08:00
committed by GitHub
parent 8653af1f14
commit 136bc0ecd5

View File

@@ -49,7 +49,12 @@ export const useDialog = defineStore('dialog', () => {
}
}
const close = (dialog: { key: string }) => {
const close = (dialog?: { key: string }) => {
if (!dialog) {
stack.value.pop()
return
}
const item = stack.value.find((item) => item.key === dialog.key)
if (item?.keepAlive) {
item.visible = false