hy-virtual-tree 1.1.47 → 1.1.49

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.49
4
+
5
+ _2025-12-06_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)修复在奇安信浏览器下的css样式不兼容 :has(+.className) 查询下一个元素是否满足条件
9
+
10
+ ### 1.1.48
11
+
12
+ _2025-12-04_
13
+
14
+ - 扩展[VirtualTree] 功能
15
+ (1)输出 try...catch... 捕获的错误
16
+
3
17
  ### 1.1.47
4
18
 
5
19
  _2025-12-03_
package/dist/index.css CHANGED
@@ -469,12 +469,12 @@
469
469
  right: 0;
470
470
  transform: translateY(-50%);
471
471
  }
472
- .hy-tree .hy-tree-node:not(.hy-tree-channel-node):has(+ .hy-tree-channel-node) {
473
- background-image: linear-gradient(to bottom, transparent 50%, var(--hy-tree-channel-bg-color) 50%, var(--hy-tree-channel-bg-color) 100%);
474
- }
475
472
  .hy-tree .hy-tree-node:not(.hy-tree-channel-node) + .hy-tree-channel-node .hy-tree-node-container .hy-tree-node__expand::before {
476
473
  height: calc(var(--hy-tree-item-height) - var(--hy-tree-item-gap) / 2);
477
474
  }
478
- .hy-tree .hy-tree-channel-node:has( + .hy-tree-node:not(.hy-tree-channel-node)) {
475
+ .hy-tree .hy-tree-node.hy-tree-device-node.hy-tree-node-expand {
476
+ background-image: linear-gradient(to bottom, transparent 50%, var(--hy-tree-channel-bg-color) 50%, var(--hy-tree-channel-bg-color) 100%);
477
+ }
478
+ .hy-tree .hy-tree-channel-node.hy-tree-channel-last-node {
479
479
  background: linear-gradient(to bottom, var(--hy-tree-channel-bg-color) 0%, var(--hy-tree-channel-bg-color) calc(100% - var(--hy-tree-item-gap)), transparent calc(100% - var(--hy-tree-item-gap)));
480
480
  }
package/dist/index.js CHANGED
@@ -465,7 +465,7 @@ class VirtualScroll {
465
465
  const item = this.items[i];
466
466
  if (this.customRenderItem) {
467
467
  // Use custom render function
468
- const itemElement = this.customRenderItem(item, i);
468
+ const itemElement = this.customRenderItem(item, i, this.items[i - 1], this.items[i + 1]);
469
469
  if (itemElement) {
470
470
  // Only set necessary height styles, other styles are determined by the caller
471
471
  itemElement.style.height = `${this.itemHeight * this.heightScale}px`;
@@ -2649,11 +2649,20 @@ class VirtualTree {
2649
2649
  }
2650
2650
  };
2651
2651
  /** 渲染项 */
2652
- const generateItem = (item) => {
2652
+ const generateItem = (item, index, prev, next) => {
2653
2653
  let el = document.createElement('div');
2654
2654
  el.classList.add('hy-tree-node');
2655
- if (item.data.dataType === 9) {
2655
+ if (item.data.dataType === DataType.CHANNEL) {
2656
2656
  el.classList.add('hy-tree-channel-node');
2657
+ if (!next || next.data.dataType !== DataType.CHANNEL) {
2658
+ el.classList.add('hy-tree-channel-last-node');
2659
+ }
2660
+ }
2661
+ else if (item.data.dataType === DataType.DEVICE) {
2662
+ el.classList.add('hy-tree-device-node');
2663
+ }
2664
+ if (this._expandedKeySet.has(item.key)) {
2665
+ el.classList.add('hy-tree-node-expand');
2657
2666
  }
2658
2667
  let nodeContainer = document.createElement('div');
2659
2668
  nodeContainer.style.height = `${config.itemHeight}px`;
@@ -2719,7 +2728,9 @@ class VirtualTree {
2719
2728
  this._refreshVirtualScroll();
2720
2729
  }
2721
2730
  }
2722
- catch { }
2731
+ catch (err) {
2732
+ console.error(err);
2733
+ }
2723
2734
  };
2724
2735
  nodeContainer.addEventListener('mousedown', (e) => {
2725
2736
  isSelecting = false;
@@ -2774,7 +2785,8 @@ class VirtualTree {
2774
2785
  toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true, true);
2775
2786
  this.refresh();
2776
2787
  }
2777
- catch {
2788
+ catch (err) {
2789
+ console.error(err);
2778
2790
  }
2779
2791
  });
2780
2792
  // 鼠标右键点击事件
@@ -2986,7 +2998,7 @@ class VirtualTree {
2986
2998
  : data;
2987
2999
  return this._tree ? this._tree.treeNodeMap.get(key) : undefined;
2988
3000
  };
2989
- /** 获取设备/群组下的全部设备 */
3001
+ /** 获取部门/群组/设备 下 的 设备和通道 */
2990
3002
  getDeviceIntegrated = (() => {
2991
3003
  const getAllDevice = (children, params, list = []) => {
2992
3004
  if (!children?.length)
@@ -3032,8 +3044,9 @@ class VirtualTree {
3032
3044
  };
3033
3045
  return (params) => {
3034
3046
  const { id, isBusiness = false } = params;
3035
- if (!id)
3036
- return;
3047
+ if (!id) {
3048
+ throw Error('getDeviceIntegrated:id不能为空');
3049
+ }
3037
3050
  let node;
3038
3051
  if (isBusiness && this._business) {
3039
3052
  switch (this._business) {
@@ -3052,6 +3065,9 @@ class VirtualTree {
3052
3065
  node = node?.[0];
3053
3066
  }
3054
3067
  node = node || this._tree.treeNodeMap.get(params.id);
3068
+ if (!node) {
3069
+ throw Error('getDeviceIntegrated:找不到节点');
3070
+ }
3055
3071
  return getAllDevice(node?.children || [], params);
3056
3072
  };
3057
3073
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.47",
3
+ "version": "1.1.49",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",