iframe.js 863 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { defineStore } from 'pinia'
  2. export const iframeStore = defineStore({
  3. id: 'iframe',
  4. state: () => ({
  5. iframeList: []
  6. }),
  7. getters: {},
  8. actions: {
  9. setIframeList(route) {
  10. this.iframeList = []
  11. this.iframeList.push(route)
  12. },
  13. pushIframeList(route) {
  14. const target = this.iframeList.find((item) => item.path === route.path)
  15. if (!target) {
  16. this.iframeList.push(route)
  17. }
  18. },
  19. removeIframeList(route) {
  20. this.iframeList.forEach((item, index) => {
  21. if (item.path === route.path) {
  22. this.iframeList.splice(index, 1)
  23. }
  24. })
  25. },
  26. refreshIframe(route) {
  27. this.iframeList.forEach((item) => {
  28. if (item.path === route.path) {
  29. const url = route.meta.url
  30. item.meta.url = ''
  31. setTimeout(() => {
  32. item.meta.url = url
  33. }, 200)
  34. }
  35. })
  36. },
  37. clearIframeList() {
  38. this.iframeList = []
  39. }
  40. }
  41. })