@gingkoo/pandora-explorer 0.0.1-alpha.63 → 0.0.1-alpha.64
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 +65 -13
- package/lib/es/index.js.map +1 -1
- package/lib/es/store.d.ts +2 -0
- package/lib/es/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-explorer v0.0.1-alpha.
|
|
2
|
+
* @gingkoo/pandora-explorer v0.0.1-alpha.64
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import cx$1 from 'classnames';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import React__default, { createContext, useRef, useState, useImperativeHandle, useEffect, useMemo, useContext, createElement, useLayoutEffect as useLayoutEffect$1, forwardRef } from 'react';
|
|
8
|
+
import _$3, { cloneDeep, truncate } from 'lodash';
|
|
8
9
|
import { createRoot } from 'react-dom/client';
|
|
9
10
|
import createEmotion from '@emotion/css/create-instance';
|
|
10
11
|
import { cx as cx$2 } from '@emotion/css';
|
|
11
|
-
import { cloneDeep, truncate } from 'lodash';
|
|
12
12
|
import KeyCode from 'rc-util/lib/KeyCode';
|
|
13
13
|
import pickAttrs from 'rc-util/lib/pickAttrs';
|
|
14
14
|
import 'rc-util/lib/warning';
|
|
@@ -7342,10 +7342,6 @@ const Layout$1 = props => {
|
|
|
7342
7342
|
onMenuClick: _onMenuClick
|
|
7343
7343
|
} = props;
|
|
7344
7344
|
const store = useContext(ExampleContext);
|
|
7345
|
-
const [expandkey, setExpandkey] = useState([]);
|
|
7346
|
-
useEffect(() => {
|
|
7347
|
-
setExpandkey([]);
|
|
7348
|
-
}, [store?.curInfo?.key]);
|
|
7349
7345
|
function Loading() {
|
|
7350
7346
|
return jsx("div", {
|
|
7351
7347
|
className: 'explorer-columns-loading',
|
|
@@ -7448,7 +7444,7 @@ const Layout$1 = props => {
|
|
|
7448
7444
|
type: 'table',
|
|
7449
7445
|
checks: checks,
|
|
7450
7446
|
selectedKeys: [store.curSelect],
|
|
7451
|
-
expandedKeys: expandkey,
|
|
7447
|
+
expandedKeys: store.expandkey,
|
|
7452
7448
|
loadedKeys: store.loadkey,
|
|
7453
7449
|
treeData: store.curlist,
|
|
7454
7450
|
columns: store.columns,
|
|
@@ -7492,7 +7488,7 @@ const Layout$1 = props => {
|
|
|
7492
7488
|
store.setLoadKey(v);
|
|
7493
7489
|
},
|
|
7494
7490
|
onExpand: v => {
|
|
7495
|
-
setExpandkey(v);
|
|
7491
|
+
store.setExpandkey(v);
|
|
7496
7492
|
},
|
|
7497
7493
|
onChange: v => {
|
|
7498
7494
|
store.setCurList(v);
|
|
@@ -7769,6 +7765,26 @@ const defaultColumns = [{
|
|
|
7769
7765
|
});
|
|
7770
7766
|
}
|
|
7771
7767
|
}];
|
|
7768
|
+
Object.defineProperty(Array.prototype, 'myforeach', {
|
|
7769
|
+
value: async function (fn, context = null) {
|
|
7770
|
+
let index = 0;
|
|
7771
|
+
let arr = this;
|
|
7772
|
+
if (typeof fn !== 'function') {
|
|
7773
|
+
throw new TypeError(fn + ' is not a function');
|
|
7774
|
+
}
|
|
7775
|
+
while (index < arr.length) {
|
|
7776
|
+
if (index in arr) {
|
|
7777
|
+
try {
|
|
7778
|
+
await fn.call(context, arr[index], index, arr);
|
|
7779
|
+
} catch (e) {
|
|
7780
|
+
console.log(e);
|
|
7781
|
+
}
|
|
7782
|
+
}
|
|
7783
|
+
index++;
|
|
7784
|
+
}
|
|
7785
|
+
},
|
|
7786
|
+
enumerable: false
|
|
7787
|
+
});
|
|
7772
7788
|
const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
7773
7789
|
const {
|
|
7774
7790
|
data,
|
|
@@ -7786,6 +7802,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7786
7802
|
onPaste,
|
|
7787
7803
|
onDelect,
|
|
7788
7804
|
onChange,
|
|
7805
|
+
onChangeCurMap,
|
|
7789
7806
|
loadData: _loadData,
|
|
7790
7807
|
onRename: _onRename,
|
|
7791
7808
|
onMenuClick: _onMenuClick
|
|
@@ -7801,6 +7818,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7801
7818
|
const [reamekey, setReName] = useState(null);
|
|
7802
7819
|
const [logindex, setLogIndex] = useState(0); //前进
|
|
7803
7820
|
const [log, setLog] = useState([]); //后退
|
|
7821
|
+
const [expandkey, setExpandkey] = useState([]);
|
|
7804
7822
|
const [loadkey, setLoadKey] = useState([]);
|
|
7805
7823
|
const [nav_loadKey, setNavLoadKey] = useState([]);
|
|
7806
7824
|
const [menutype, setMenutype] = useState('tile');
|
|
@@ -7825,8 +7843,11 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7825
7843
|
if (key) {
|
|
7826
7844
|
loadData(key, undefined, closeload);
|
|
7827
7845
|
} else {
|
|
7828
|
-
curInfo?.key
|
|
7846
|
+
loadData(curInfo?.key || '', undefined, closeload);
|
|
7829
7847
|
}
|
|
7848
|
+
},
|
|
7849
|
+
updateCurListNode: key => {
|
|
7850
|
+
updateCurlist(key || '');
|
|
7830
7851
|
}
|
|
7831
7852
|
}));
|
|
7832
7853
|
/* ************ 挂载监听 **************** */
|
|
@@ -7932,11 +7953,12 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7932
7953
|
});
|
|
7933
7954
|
};
|
|
7934
7955
|
useEffect(() => {
|
|
7956
|
+
if (!isNavtab) return;
|
|
7935
7957
|
if (!curInfo) {
|
|
7936
7958
|
setCurList(data?.[0]?.children || []);
|
|
7937
7959
|
setCurInfo(data?.[0] || null);
|
|
7938
7960
|
}
|
|
7939
|
-
}, [data]);
|
|
7961
|
+
}, [data, isNavtab]);
|
|
7940
7962
|
useEffect(() => {
|
|
7941
7963
|
const addLevel = (data, map) => {
|
|
7942
7964
|
let i = 0;
|
|
@@ -7953,16 +7975,20 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7953
7975
|
let map = addLevel(curlist, {});
|
|
7954
7976
|
setDataMap(map);
|
|
7955
7977
|
}, [curlist]);
|
|
7978
|
+
useEffect(() => {
|
|
7979
|
+
setExpandkey([]);
|
|
7980
|
+
}, [curInfo?.key]);
|
|
7956
7981
|
useEffect(() => {
|
|
7957
7982
|
if (isNavtab) return;
|
|
7958
|
-
console.log(data, '我是data');
|
|
7959
|
-
console.log(curlist, '我是cur');
|
|
7960
7983
|
if (!curlist?.length) {
|
|
7961
7984
|
if (Array.isArray(data)) {
|
|
7962
7985
|
setCurList(data);
|
|
7963
7986
|
}
|
|
7964
7987
|
}
|
|
7965
7988
|
}, [curlist, isNavtab, data]);
|
|
7989
|
+
useEffect(() => {
|
|
7990
|
+
onChangeCurMap?.(dataMap);
|
|
7991
|
+
}, [dataMap]);
|
|
7966
7992
|
/* ************ 加载更新数据 **************** */
|
|
7967
7993
|
async function loadData(key, param, closeload = true) {
|
|
7968
7994
|
closeload && setLoading(ApiStatusEnum.LOADING);
|
|
@@ -8033,6 +8059,30 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8033
8059
|
let arr = fixData(data || [], id, param);
|
|
8034
8060
|
onChange?.(arr);
|
|
8035
8061
|
}
|
|
8062
|
+
async function updateCurlist(key) {
|
|
8063
|
+
let data = await reduceGetTreeData(curlist, key || curInfo?.key || '', expandkey);
|
|
8064
|
+
setCurList(data);
|
|
8065
|
+
}
|
|
8066
|
+
async function reduceGetTreeData(data, key, expand) {
|
|
8067
|
+
let res = await loadNode(key);
|
|
8068
|
+
const newData = [];
|
|
8069
|
+
// @ts-ignore
|
|
8070
|
+
await data.myforeach(async v => {
|
|
8071
|
+
let obj = _$3.cloneDeep(v);
|
|
8072
|
+
if (expand.includes(obj.key)) {
|
|
8073
|
+
obj.children = await reduceGetTreeData(obj.children, obj.key, expand);
|
|
8074
|
+
}
|
|
8075
|
+
if (obj.type == 'file') {
|
|
8076
|
+
let match = res.filter(it => it.key === obj.key);
|
|
8077
|
+
if (match.length) {
|
|
8078
|
+
newData.push(match[0]);
|
|
8079
|
+
return null;
|
|
8080
|
+
}
|
|
8081
|
+
}
|
|
8082
|
+
newData.push(obj);
|
|
8083
|
+
});
|
|
8084
|
+
return newData;
|
|
8085
|
+
}
|
|
8036
8086
|
/* ************ 功能方法 **************** */
|
|
8037
8087
|
//创建和重名
|
|
8038
8088
|
async function onRename(key, value, info, type) {
|
|
@@ -8280,6 +8330,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8280
8330
|
curSelectFile,
|
|
8281
8331
|
loadkey,
|
|
8282
8332
|
nav_loadKey,
|
|
8333
|
+
expandkey,
|
|
8283
8334
|
//icon
|
|
8284
8335
|
getIcons: Icons,
|
|
8285
8336
|
loadMenu: props.loadMenu,
|
|
@@ -8302,7 +8353,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8302
8353
|
setCurSelect,
|
|
8303
8354
|
setCurSelectFile,
|
|
8304
8355
|
setLoadKey,
|
|
8305
|
-
setNavLoadKey
|
|
8356
|
+
setNavLoadKey,
|
|
8357
|
+
setExpandkey
|
|
8306
8358
|
},
|
|
8307
8359
|
children: jsx("div", {
|
|
8308
8360
|
className: 'explorer-container',
|