@gingkoo/pandora-explorer 0.0.1-alpha.23 → 0.0.1-alpha.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/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @gingkoo/pandora-explorer v0.0.1-alpha.23
2
+ * @gingkoo/pandora-explorer v0.0.1-alpha.24
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import cx$1 from 'classnames';
@@ -5373,6 +5373,30 @@ function NotData() {
5373
5373
  });
5374
5374
  }
5375
5375
 
5376
+ //添加层级
5377
+ const addLevel = (data, levelIndex = 0, filedata) => {
5378
+ let arr = data;
5379
+ if (filedata) {
5380
+ arr = arr.filter(v => filedata?.(v));
5381
+ }
5382
+ let i = 0;
5383
+ while (i < arr.length) {
5384
+ let item = arr[i];
5385
+ item['level'] = levelIndex;
5386
+ if (!item?.api && !item?.children) {
5387
+ item['isLeaf'] = true;
5388
+ }
5389
+ if (Array.isArray(item.children) && item.children.length > 0) {
5390
+ if (filedata) {
5391
+ item.children = addLevel(item.children, levelIndex + 1, filedata);
5392
+ } else {
5393
+ addLevel(item.children, levelIndex + 1, filedata);
5394
+ }
5395
+ }
5396
+ i++;
5397
+ }
5398
+ return arr;
5399
+ };
5376
5400
  //下拉动画
5377
5401
  const motion = {
5378
5402
  motionName: 'node-motion',
@@ -5436,11 +5460,11 @@ var Tree = (props => {
5436
5460
  }, 0);
5437
5461
  return size > w ? size : Math.ceil(w);
5438
5462
  }, [width, _widht]);
5439
- // useEffect(() => {
5440
- // let arr = cloneDeep(treeData);
5441
- // arr = addLevel(arr, 0, filterData);
5442
- // setData(arr);
5443
- // }, [treeData, type, filterData]);
5463
+ useEffect(() => {
5464
+ let arr = cloneDeep(treeData);
5465
+ arr = addLevel(arr, 0, filterData);
5466
+ setData(arr);
5467
+ }, [treeData, type, filterData]);
5444
5468
  useEffect(() => {
5445
5469
  if (!Array.isArray(columns)) return;
5446
5470
  if (!ref.current) return;
@@ -5831,12 +5855,12 @@ const ExplorerMenu = props => {
5831
5855
  onChange: onChange,
5832
5856
  onSelect: v => {
5833
5857
  store.setPathDisplay(v?.pathDisplay);
5834
- if (Array.isArray(v?.children)) {
5835
- store.setCurInfo(v);
5836
- store.setCurList(v?.children || []);
5837
- } else {
5838
- loadData(v.key);
5839
- }
5858
+ // if (Array.isArray(v?.children)) {
5859
+ // store.setCurInfo(v);
5860
+ // store.setCurList(v?.children || []);
5861
+ // } else {
5862
+ loadData(v.key);
5863
+ // }
5840
5864
  },
5841
5865
  filterData: v => {
5842
5866
  if (v.type == 'file') return false;