dialog-level.ts 634 B

1234567891011121314151617181920212223242526
  1. import {defineStore} from "pinia";
  2. export const useDialogLevelStore = defineStore('dialogLevel', {
  3. state: () => ({
  4. dialogShows: <any>[]
  5. }),
  6. getters: {
  7. },
  8. actions: {
  9. add(key) {
  10. const oldDom = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
  11. if (oldDom) {
  12. oldDom.style.display = 'none'
  13. }
  14. this.dialogShows.unshift(key)
  15. },
  16. del(key) {
  17. this.dialogShows = this.dialogShows.filter(v => v !== key)
  18. const newDom = document.body.getElementsByClassName(this.dialogShows[0])?.[0]
  19. if (newDom) {
  20. newDom.style.display = 'unset'
  21. }
  22. },
  23. },
  24. })