hy-virtual-tree 2.0.0 → 2.0.2

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,21 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.2
4
+
5
+ _2026-03-12_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)修复虚拟树更新时没有调用销毁方法的问题
9
+ (2)修复renderContent传入true回显默认值不生效问题
10
+ (3)修复 planGroupDevice 业务类型设备图标不显示问题
11
+
12
+ ### 2.0.1
13
+
14
+ _2026-03-11_
15
+
16
+ - 扩展[VirtualTree] 功能
17
+ (1)修复外部自定义插槽传入对象报错问题
18
+
3
19
  ### 2.0.0
4
20
 
5
21
  _2026-03-11_
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* hy-virtual-tree v2.0.0 */
1
+ /* hy-virtual-tree v2.0.2 */
2
2
  import './svg_bundle.js';
3
3
  const isString = (e) => typeof e === 'string';
4
4
  const isNumber = (e) => typeof e === 'number';
@@ -6708,8 +6708,8 @@ const setElementFocus = (config) => {
6708
6708
  const getElement = (vnode) => {
6709
6709
  return vnode.el;
6710
6710
  };
6711
- const createVNode = (tag, render) => {
6712
- const el = document.createElement(tag);
6711
+ const createVNode = (arg, render) => {
6712
+ const el = isString(arg) ? document.createElement(arg) : arg;
6713
6713
  let target = {
6714
6714
  el,
6715
6715
  children: [],
@@ -6727,6 +6727,7 @@ const createVNode = (tag, render) => {
6727
6727
  vnode && vnode.destroy && vnode.destroy();
6728
6728
  vnode && vnode.$destroy && vnode.$destroy();
6729
6729
  }
6730
+ target.$destroy && target.$destroy();
6730
6731
  // @ts-ignore
6731
6732
  target.el = undefined;
6732
6733
  // @ts-ignore
@@ -7472,6 +7473,11 @@ class VirtualScroll {
7472
7473
  }
7473
7474
  if (this._cacheDataMap.has(item.key)) {
7474
7475
  const vnode = this._cacheDataMap.get(item.key);
7476
+ // 调用销毁方法
7477
+ const cacheTarget = this._cacheNodeMap.get(vnode.outerHTML);
7478
+ if (cacheTarget?.renderNode?.destroy) {
7479
+ cacheTarget.renderNode.destroy();
7480
+ }
7475
7481
  this.contentContainer.removeChild(vnode.el);
7476
7482
  this._cacheNodeMap.delete(vnode.outerHTML);
7477
7483
  }
@@ -7610,6 +7616,9 @@ class VirtualScroll {
7610
7616
  if (isElement(value)) {
7611
7617
  el.appendChild(value);
7612
7618
  }
7619
+ else if (isObject(value)) {
7620
+ el.appendChild(value.el);
7621
+ }
7613
7622
  else {
7614
7623
  el.innerHTML = value;
7615
7624
  }
@@ -8973,7 +8982,7 @@ const useIcon = (config, data, node) => {
8973
8982
  return new Icon({ svgName: deviceIconMap.cs });
8974
8983
  }
8975
8984
  // 其他设备
8976
- if ((/^(device|channel|groupDevice)$/.test(config.business) && data.dataType === DataType.DEVICE)) {
8985
+ if ((/^(device|channel|groupDevice|planGroupDevice)$/.test(config.business) && data.dataType === DataType.DEVICE)) {
8977
8986
  const { useIcon } = getGlobalDeviceConfig();
8978
8987
  let svgName;
8979
8988
  if (useIcon) {
@@ -9020,12 +9029,22 @@ const customRender = (options) => {
9020
9029
  value = fn(node.data, node);
9021
9030
  }
9022
9031
  if (isObject(value) && value.el) {
9032
+ // 处理从外部传入的没有挂载方法的节点
9033
+ if (!value.mount) {
9034
+ value = createVNode(value.el, (vnode) => {
9035
+ vnode.$destroy = value.$destroy;
9036
+ });
9037
+ }
9023
9038
  className && value.el.classList.add(className);
9024
9039
  parent && value.mount(parent);
9025
9040
  return value;
9026
9041
  }
9027
9042
  if (isBoolean(value) && value) {
9028
- return defaultFn && isFunction(defaultFn) ? defaultFn(node.data, node) : undefined;
9043
+ value = defaultFn && isFunction(defaultFn) ? defaultFn(node.data, node) : undefined;
9044
+ if (value && parent) {
9045
+ value.mount(parent);
9046
+ }
9047
+ return value;
9029
9048
  }
9030
9049
  else if (isElement(value)) {
9031
9050
  if (inset) {
@@ -9761,10 +9780,10 @@ class VirtualTree {
9761
9780
  rightSlot = customRender({ fn: config.renderRight, node: item, inset: true, className: 'hy-tree-node__right-content' });
9762
9781
  if (!statusSlot && !rightSlot)
9763
9782
  return;
9764
- return createVNode('div', (vnnode) => {
9765
- vnnode.el.classList.add('hy-tree-node__right');
9766
- statusSlot && statusSlot.mount(vnnode);
9767
- rightSlot && rightSlot.mount(vnnode);
9783
+ return createVNode('div', (vnode) => {
9784
+ vnode.el.classList.add('hy-tree-node__right');
9785
+ statusSlot && statusSlot.mount(vnode);
9786
+ rightSlot && rightSlot.mount(vnode);
9768
9787
  });
9769
9788
  };
9770
9789
  /** 设置节点class */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",