hy-virtual-tree 1.1.22 → 1.1.24

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.24
4
+
5
+ _2025-09-13_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)优化刷新销毁逻辑
9
+
10
+ ### 1.1.23
11
+
12
+ _2025-09-13_
13
+
14
+ - 扩展[VirtualTree] 功能
15
+ (1)优化updateData缓存逻辑
16
+
3
17
  ### 1.1.22
4
18
 
5
19
  _2025-09-12_
package/dist/index.js CHANGED
@@ -1976,18 +1976,18 @@ class VirtualTree {
1976
1976
  /** 渲染项 */
1977
1977
  const generateItem = (item) => {
1978
1978
  const { type, showSelect } = config.rowSelection;
1979
- const el = document.createElement('div');
1979
+ let el = document.createElement('div');
1980
1980
  el.classList.add('hy-tree-node');
1981
1981
  if (config.itemGap) {
1982
1982
  el.style.paddingBottom = `${config.itemGap}px`;
1983
1983
  }
1984
- const nodeContainer = document.createElement('div');
1984
+ let nodeContainer = document.createElement('div');
1985
1985
  nodeContainer.style.height = `${config.itemHeight}px`;
1986
1986
  if (config.nodeBgColor) {
1987
1987
  nodeContainer.style.backgroundColor = config.nodeBgColor;
1988
1988
  }
1989
1989
  setNodeClass(nodeContainer, item);
1990
- const content = document.createElement('div');
1990
+ let content = document.createElement('div');
1991
1991
  content.classList.add('hy-tree-node-content');
1992
1992
  content.style.setProperty('padding-left', `${(item.level - 1) * (config.indent || 0)}px`);
1993
1993
  // 设备离线 - 字体颜色
@@ -2132,6 +2132,10 @@ class VirtualTree {
2132
2132
  }
2133
2133
  });
2134
2134
  el.appendChild(nodeContainer);
2135
+ this._destroyDomSet.add(() => {
2136
+ // @ts-ignore
2137
+ el = nodeContainer = content = null;
2138
+ });
2135
2139
  return el;
2136
2140
  };
2137
2141
  return { renderItem: generateItem };
@@ -2189,24 +2193,24 @@ class VirtualTree {
2189
2193
  let cacheTimer;
2190
2194
  let cacheTime = Date.now();
2191
2195
  const cacheInterval = 500;
2192
- const cacheData = new Map();
2196
+ let cacheData = [];
2193
2197
  return async (data, callback) => {
2194
2198
  if (!this._tree)
2195
2199
  return;
2196
2200
  cacheTimer && clearTimeout(cacheTimer);
2197
2201
  if (Array.isArray(data)) {
2198
2202
  data.forEach((item) => {
2199
- cacheData.set(this._getKey(item, true), item);
2203
+ cacheData.push(item);
2200
2204
  });
2201
2205
  }
2202
2206
  else {
2203
- cacheData.set(this._getKey(data, true), data);
2207
+ cacheData.push(data);
2204
2208
  }
2205
2209
  // cacheInterval毫秒仅更新一次数据
2206
2210
  if (Date.now() - cacheTime >= cacheInterval) {
2207
2211
  cacheTime = Date.now();
2208
- await this._updateTree(Array.from(cacheData.values()));
2209
- cacheData.clear();
2212
+ this._updateTree([...cacheData]);
2213
+ cacheData = [];
2210
2214
  this._refreshVirtualScroll();
2211
2215
  callback && callback();
2212
2216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",