dtable-ui-component 6.0.93 → 6.0.95-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,5 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _toaster = _interopRequireDefault(require("./toaster"));
9
+ // 确保只创建一个 Toaster 实例
9
10
  const toaster = new _toaster.default();
10
11
  var _default = exports.default = toaster;
@@ -63,8 +63,14 @@ class Toaster {
63
63
  });
64
64
  };
65
65
  if (!isBrowser) return;
66
- let toastContainer = document.querySelector('.dtable-toast-manager');
67
- if (toastContainer) return;
66
+
67
+ // 单例模式:如果已经存在实例,直接返回
68
+ if (Toaster.instance) {
69
+ return Toaster.instance;
70
+ }
71
+
72
+ // 清理可能存在的旧容器
73
+ this._cleanupOldContainers();
68
74
  const container = document.createElement('div');
69
75
  container.setAttribute('data-evergreen-toaster-container', '');
70
76
  document.body.appendChild(container);
@@ -74,6 +80,20 @@ class Toaster {
74
80
  bindGetToasts: this._bindGetToasts,
75
81
  bindCloseAll: this._bindCloseAll
76
82
  }));
83
+
84
+ // 保存实例引用
85
+ Toaster.instance = this;
86
+ }
87
+
88
+ // 清理旧的 toaster 容器
89
+ _cleanupOldContainers() {
90
+ const oldContainers = document.querySelectorAll('[data-evergreen-toaster-container]');
91
+ oldContainers.forEach(container => {
92
+ if (container.parentNode) {
93
+ container.parentNode.removeChild(container);
94
+ }
95
+ });
77
96
  }
78
97
  }
79
- exports.default = Toaster;
98
+ exports.default = Toaster;
99
+ Toaster.instance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.93",
3
+ "version": "6.0.95-beta.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",