import {defineStore} from "pinia"; export const useDialogStore = defineStore('dialog', { state: () => ({ dialogShows: [], confirmParam: { show: false, title: '提示', content: '', onSubmit: () => {}, onCancel: () => {}, } }), getters: { }, actions: { add(key) { const oldDom: any = document.body.getElementsByClassName(this.dialogShows[0])?.[0] if (oldDom) { oldDom.style.display = 'none' } this.dialogShows.unshift(key) }, del(key) { this.dialogShows = this.dialogShows.filter(v => v !== key) const newDom: any = document.body.getElementsByClassName(this.dialogShows[0])?.[0] if (newDom) { newDom.style.display = 'unset' } }, confirm({title = '提示', content, onSubmit, onCancel = () => {}}) { this.confirmParam = { show: true, title: title, content, onSubmit: onSubmit, onCancel: onCancel } } }, })