@gingkoo/pandora-explorer 0.0.1-alpha.32 → 0.0.1-alpha.34
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 +121 -53
- package/lib/es/index.js.map +1 -1
- package/lib/es/store.d.ts +2 -0
- package/lib/es/types.d.ts +2 -1
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-explorer v0.0.1-alpha.
|
|
2
|
+
* @gingkoo/pandora-explorer v0.0.1-alpha.34
|
|
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
|
-
import React__default, { createContext, useRef, useState, useImperativeHandle, useEffect, useMemo, useLayoutEffect, useContext, createElement } from 'react';
|
|
7
|
+
import React__default, { createContext, useRef, useState, useImperativeHandle, useEffect, useMemo, useLayoutEffect, useContext, createElement, forwardRef } from 'react';
|
|
8
8
|
import createEmotion from '@emotion/css/create-instance';
|
|
9
9
|
import { cx as cx$2 } from '@emotion/css';
|
|
10
10
|
import { createRoot } from 'react-dom/client';
|
|
@@ -1633,18 +1633,19 @@ const ExplorerHead = props => {
|
|
|
1633
1633
|
function exit() {
|
|
1634
1634
|
if (store.logindex) {
|
|
1635
1635
|
if (Array.isArray(store.log)) {
|
|
1636
|
-
let
|
|
1637
|
-
|
|
1636
|
+
let index = store.logindex - 2;
|
|
1637
|
+
let key = store?.log[index];
|
|
1638
|
+
loadData?.(key || '');
|
|
1639
|
+
store.setLogIndex(index + 1);
|
|
1638
1640
|
}
|
|
1639
|
-
store.setLogIndex(store.logindex - 1);
|
|
1640
1641
|
}
|
|
1641
1642
|
}
|
|
1642
1643
|
function forward() {
|
|
1643
|
-
if (Array.isArray(store.log) && store.log.length
|
|
1644
|
-
let key = store?.log[store.logindex
|
|
1644
|
+
if (Array.isArray(store.log) && store.log.length - 1 >= store.logindex) {
|
|
1645
|
+
let key = store?.log[store.logindex];
|
|
1645
1646
|
loadData?.(key);
|
|
1647
|
+
store.setLogIndex(store.logindex + 1);
|
|
1646
1648
|
}
|
|
1647
|
-
store.setLogIndex(store.logindex + 1);
|
|
1648
1649
|
}
|
|
1649
1650
|
return jsxs(Fragment, {
|
|
1650
1651
|
children: [jsxs("div", {
|
|
@@ -1833,6 +1834,14 @@ function Slider(props) {
|
|
|
1833
1834
|
const ref = useRef(null);
|
|
1834
1835
|
const [isdarg, setDarg] = useState(false);
|
|
1835
1836
|
const [size, setSize] = useState(null);
|
|
1837
|
+
useEffect(() => {
|
|
1838
|
+
document.addEventListener('mousemove', handleBodyMousemove);
|
|
1839
|
+
document.addEventListener('mouseup', handleBodyMouseup);
|
|
1840
|
+
return () => {
|
|
1841
|
+
document.removeEventListener('mousemove', handleBodyMousemove);
|
|
1842
|
+
document.removeEventListener('mouseup', handleBodyMouseup);
|
|
1843
|
+
};
|
|
1844
|
+
}, [isdarg, ref.current]);
|
|
1836
1845
|
useEffect(() => {
|
|
1837
1846
|
if (!size) return;
|
|
1838
1847
|
let d_value = max - min;
|
|
@@ -1844,22 +1853,25 @@ function Slider(props) {
|
|
|
1844
1853
|
let data = value - min;
|
|
1845
1854
|
setSize(data / d_value * 100);
|
|
1846
1855
|
}, [value]);
|
|
1856
|
+
function handleBodyMousemove(e) {
|
|
1857
|
+
if (!isdarg) return;
|
|
1858
|
+
if (!ref.current) return;
|
|
1859
|
+
e.preventDefault();
|
|
1860
|
+
let dom = ref.current.getBoundingClientRect();
|
|
1861
|
+
let cur = dom.top + 15;
|
|
1862
|
+
let num = e.clientY - cur;
|
|
1863
|
+
num > 100 ? num = 100 : null;
|
|
1864
|
+
num < 0 ? num = 0 : null;
|
|
1865
|
+
setSize(num);
|
|
1866
|
+
}
|
|
1867
|
+
function handleBodyMouseup(e) {
|
|
1868
|
+
e.preventDefault();
|
|
1869
|
+
e.stopPropagation();
|
|
1870
|
+
setDarg(false);
|
|
1871
|
+
}
|
|
1847
1872
|
return jsx("div", {
|
|
1848
1873
|
className: '_slider',
|
|
1849
1874
|
ref: ref,
|
|
1850
|
-
onMouseOut: () => {
|
|
1851
|
-
setDarg(false);
|
|
1852
|
-
},
|
|
1853
|
-
onMouseMove: e => {
|
|
1854
|
-
if (!isdarg) return;
|
|
1855
|
-
if (!ref.current) return;
|
|
1856
|
-
let dom = ref.current.getBoundingClientRect();
|
|
1857
|
-
let cur = dom.top + 15;
|
|
1858
|
-
let num = e.clientY - cur;
|
|
1859
|
-
num > 100 ? num = 100 : null;
|
|
1860
|
-
num < 0 ? num = 0 : null;
|
|
1861
|
-
setSize(num);
|
|
1862
|
-
},
|
|
1863
1875
|
children: jsx("div", {
|
|
1864
1876
|
className: '_slider-link',
|
|
1865
1877
|
onClick: e => {
|
|
@@ -1875,11 +1887,8 @@ function Slider(props) {
|
|
|
1875
1887
|
top: size + 'px'
|
|
1876
1888
|
},
|
|
1877
1889
|
className: '_slider-drop',
|
|
1878
|
-
onMouseDown:
|
|
1890
|
+
onMouseDown: e => {
|
|
1879
1891
|
setDarg(true);
|
|
1880
|
-
},
|
|
1881
|
-
onMouseUp: () => {
|
|
1882
|
-
setDarg(false);
|
|
1883
1892
|
}
|
|
1884
1893
|
})
|
|
1885
1894
|
})
|
|
@@ -5257,7 +5266,16 @@ function TableItem(props) {
|
|
|
5257
5266
|
autoFocus: true,
|
|
5258
5267
|
defaultValue: param[v?.key],
|
|
5259
5268
|
placeholder: '\u8BF7\u8F93\u5165',
|
|
5269
|
+
onFocus: e => {
|
|
5270
|
+
let i = param[v?.key]?.lastIndexOf('.');
|
|
5271
|
+
if (props?.suffix == 'folder') {
|
|
5272
|
+
e.target.setSelectionRange(0, param[v?.key]?.length);
|
|
5273
|
+
} else if (i !== -1) {
|
|
5274
|
+
e.target.setSelectionRange(0, i);
|
|
5275
|
+
}
|
|
5276
|
+
},
|
|
5260
5277
|
onBlur: e => {
|
|
5278
|
+
if (e.target.value === param[v?.key]) return;
|
|
5261
5279
|
onRename?.(e.target.value);
|
|
5262
5280
|
}
|
|
5263
5281
|
})
|
|
@@ -5335,6 +5353,14 @@ var TreeItem = (props => {
|
|
|
5335
5353
|
autoFocus: true,
|
|
5336
5354
|
value: title,
|
|
5337
5355
|
placeholder: '\u8BF7\u8F93\u5165',
|
|
5356
|
+
onFocus: e => {
|
|
5357
|
+
let i = title.lastIndexOf('.');
|
|
5358
|
+
if (props?.suffix == 'folder') {
|
|
5359
|
+
e.target.setSelectionRange(0, title.length);
|
|
5360
|
+
} else if (i !== -1) {
|
|
5361
|
+
e.target.setSelectionRange(0, i);
|
|
5362
|
+
}
|
|
5363
|
+
},
|
|
5338
5364
|
onChange: v => {
|
|
5339
5365
|
setTitle?.(v.target.value);
|
|
5340
5366
|
},
|
|
@@ -5866,7 +5892,8 @@ const ExplorerMenu = props => {
|
|
|
5866
5892
|
loadData,
|
|
5867
5893
|
loadNode,
|
|
5868
5894
|
onMenuClick,
|
|
5869
|
-
onChange
|
|
5895
|
+
onChange,
|
|
5896
|
+
onRename
|
|
5870
5897
|
} = props;
|
|
5871
5898
|
const store = useContext(ExampleContext);
|
|
5872
5899
|
const [eventKey, setEventKey] = useState([]);
|
|
@@ -5886,6 +5913,7 @@ const ExplorerMenu = props => {
|
|
|
5886
5913
|
onMenuClick: onMenuClick,
|
|
5887
5914
|
loadData: loadNode,
|
|
5888
5915
|
onChange: onChange,
|
|
5916
|
+
onRename: onRename,
|
|
5889
5917
|
onSelect: v => {
|
|
5890
5918
|
store.setPathDisplay(v?.pathDisplay);
|
|
5891
5919
|
loadData(v.key);
|
|
@@ -5952,6 +5980,7 @@ const VirtualScroll = ({
|
|
|
5952
5980
|
ref: containerRef,
|
|
5953
5981
|
children: jsx("div", {
|
|
5954
5982
|
style: {
|
|
5983
|
+
position: 'relative',
|
|
5955
5984
|
height: `${data.length * itemHeight}px`,
|
|
5956
5985
|
paddingTop: `${startIdx * itemHeight}px`
|
|
5957
5986
|
},
|
|
@@ -6012,7 +6041,7 @@ function Tile(props) {
|
|
|
6012
6041
|
[className || '']: className
|
|
6013
6042
|
}),
|
|
6014
6043
|
style: {
|
|
6015
|
-
height: '
|
|
6044
|
+
height: height + 'px'
|
|
6016
6045
|
},
|
|
6017
6046
|
onContextMenu: e => {
|
|
6018
6047
|
e.preventDefault();
|
|
@@ -6084,17 +6113,14 @@ function Tile(props) {
|
|
|
6084
6113
|
width: w + 'px',
|
|
6085
6114
|
height: w + 'px',
|
|
6086
6115
|
lineHeight: w + 'px'
|
|
6087
|
-
}) : jsx("
|
|
6088
|
-
className: 'picture',
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
height: w + 'px'
|
|
6096
|
-
}
|
|
6097
|
-
})
|
|
6116
|
+
}) : jsx("img", {
|
|
6117
|
+
className: 'picture-show',
|
|
6118
|
+
draggable: 'false',
|
|
6119
|
+
src: v.pic,
|
|
6120
|
+
style: {
|
|
6121
|
+
width: w + 'px',
|
|
6122
|
+
height: w + 'px'
|
|
6123
|
+
}
|
|
6098
6124
|
})
|
|
6099
6125
|
}), jsx("div", {
|
|
6100
6126
|
className: 'title-type-name',
|
|
@@ -7149,8 +7175,9 @@ const Layout$1 = props => {
|
|
|
7149
7175
|
},
|
|
7150
7176
|
onSelect: v => {
|
|
7151
7177
|
if (v?.type == 'folder' && v.expanded) {
|
|
7152
|
-
store.
|
|
7178
|
+
store.setCurSelectFile(v.key);
|
|
7153
7179
|
}
|
|
7180
|
+
store.setCurSelect(v.key);
|
|
7154
7181
|
},
|
|
7155
7182
|
onRename: onRename,
|
|
7156
7183
|
onMenuClick: onMenuClick,
|
|
@@ -7191,9 +7218,12 @@ function ExplorerInfo(props) {
|
|
|
7191
7218
|
const {
|
|
7192
7219
|
infoshow,
|
|
7193
7220
|
getIcons,
|
|
7194
|
-
curInfo
|
|
7221
|
+
curInfo,
|
|
7222
|
+
dataMap,
|
|
7223
|
+
curSelect
|
|
7195
7224
|
} = useContext(ExampleContext);
|
|
7196
7225
|
const [isEdit, setIsEdit] = useState(false);
|
|
7226
|
+
const [info, setInfo] = useState({});
|
|
7197
7227
|
useEffect(() => {
|
|
7198
7228
|
if (infoshow) {
|
|
7199
7229
|
props?.setSize(285);
|
|
@@ -7201,6 +7231,13 @@ function ExplorerInfo(props) {
|
|
|
7201
7231
|
props?.onMinimize();
|
|
7202
7232
|
}
|
|
7203
7233
|
}, [infoshow]);
|
|
7234
|
+
useEffect(() => {
|
|
7235
|
+
if (curSelect) {
|
|
7236
|
+
setInfo(dataMap?.[curSelect]);
|
|
7237
|
+
} else {
|
|
7238
|
+
setInfo(curInfo);
|
|
7239
|
+
}
|
|
7240
|
+
}, [curInfo, dataMap]);
|
|
7204
7241
|
function rednerInfo() {
|
|
7205
7242
|
return jsxs("div", {
|
|
7206
7243
|
className: 'panel-info',
|
|
@@ -7211,7 +7248,7 @@ function ExplorerInfo(props) {
|
|
|
7211
7248
|
children: "\u8DEF\u5F84:"
|
|
7212
7249
|
}), jsx("div", {
|
|
7213
7250
|
className: 'content',
|
|
7214
|
-
children:
|
|
7251
|
+
children: info?.pathDisplay || '-'
|
|
7215
7252
|
})]
|
|
7216
7253
|
}), jsxs("div", {
|
|
7217
7254
|
className: 'panel-col',
|
|
@@ -7220,7 +7257,7 @@ function ExplorerInfo(props) {
|
|
|
7220
7257
|
children: "\u5927\u5C0F:"
|
|
7221
7258
|
}), jsx("div", {
|
|
7222
7259
|
className: 'content',
|
|
7223
|
-
children: typeof
|
|
7260
|
+
children: typeof info?.size == 'number' ? convertBytesToSize(info?.size) : info?.size || '-'
|
|
7224
7261
|
})]
|
|
7225
7262
|
}), jsxs("div", {
|
|
7226
7263
|
className: 'panel-col',
|
|
@@ -7229,7 +7266,7 @@ function ExplorerInfo(props) {
|
|
|
7229
7266
|
children: "\u521B\u5EFA\u65F6\u95F4 :"
|
|
7230
7267
|
}), jsx("div", {
|
|
7231
7268
|
className: 'content',
|
|
7232
|
-
children: DateFormat(
|
|
7269
|
+
children: DateFormat(info?.createTime)
|
|
7233
7270
|
})]
|
|
7234
7271
|
}), jsxs("div", {
|
|
7235
7272
|
className: 'panel-col',
|
|
@@ -7238,7 +7275,7 @@ function ExplorerInfo(props) {
|
|
|
7238
7275
|
children: "\u4FEE\u6539\u65F6\u95F4 :"
|
|
7239
7276
|
}), jsx("div", {
|
|
7240
7277
|
className: 'content',
|
|
7241
|
-
children: DateFormat(
|
|
7278
|
+
children: DateFormat(info?.createTime)
|
|
7242
7279
|
})]
|
|
7243
7280
|
}), jsxs("div", {
|
|
7244
7281
|
className: 'panel-col',
|
|
@@ -7282,18 +7319,18 @@ function ExplorerInfo(props) {
|
|
|
7282
7319
|
className: 'info-header',
|
|
7283
7320
|
children: [jsx("div", {
|
|
7284
7321
|
className: 'file-icon',
|
|
7285
|
-
children: getIcons(
|
|
7322
|
+
children: getIcons(info, '')
|
|
7286
7323
|
}), jsxs("div", {
|
|
7287
7324
|
className: 'file-name',
|
|
7288
7325
|
children: [jsx("div", {
|
|
7289
7326
|
className: 'title',
|
|
7290
|
-
children:
|
|
7327
|
+
children: info?.title
|
|
7291
7328
|
}), jsxs("div", {
|
|
7292
7329
|
className: 'desc',
|
|
7293
7330
|
children: [jsx("span", {
|
|
7294
|
-
children: typeof
|
|
7331
|
+
children: typeof info?.size == 'number' ? convertBytesToSize(info?.size) : info?.size || '-'
|
|
7295
7332
|
}), jsx("span", {
|
|
7296
|
-
children:
|
|
7333
|
+
children: info?.fixTime || '-'
|
|
7297
7334
|
})]
|
|
7298
7335
|
})]
|
|
7299
7336
|
})]
|
|
@@ -7397,7 +7434,7 @@ const defaultColumns = [{
|
|
|
7397
7434
|
});
|
|
7398
7435
|
}
|
|
7399
7436
|
}];
|
|
7400
|
-
const Explorer = props => {
|
|
7437
|
+
const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
7401
7438
|
const {
|
|
7402
7439
|
data,
|
|
7403
7440
|
columns,
|
|
@@ -7412,7 +7449,8 @@ const Explorer = props => {
|
|
|
7412
7449
|
const [curlist, setCurList] = useState([]);
|
|
7413
7450
|
const [curInfo, setCurInfo] = useState(null);
|
|
7414
7451
|
const [dataMap, setDataMap] = useState({});
|
|
7415
|
-
const [curSelect, setCurSelect] = useState(
|
|
7452
|
+
const [curSelect, setCurSelect] = useState(null); //当前选中信息
|
|
7453
|
+
const [curSelectFile, setCurSelectFile] = useState(''); //当前选中的文件
|
|
7416
7454
|
const [menuSize, setMenuSize] = useState(80);
|
|
7417
7455
|
const [reamekey, setReName] = useState(null);
|
|
7418
7456
|
const [logindex, setLogIndex] = useState(0); //前进
|
|
@@ -7421,6 +7459,17 @@ const Explorer = props => {
|
|
|
7421
7459
|
const [menutype, setMenutype] = useState('tile');
|
|
7422
7460
|
const [infoshow, setInfoShow] = useState(false);
|
|
7423
7461
|
const [loading, setLoading] = useState(ApiStatusEnum.READY);
|
|
7462
|
+
useImperativeHandle(ref, () => ({
|
|
7463
|
+
removeLog: () => {
|
|
7464
|
+
//清空日志
|
|
7465
|
+
setLog([]);
|
|
7466
|
+
},
|
|
7467
|
+
updateData: () => {
|
|
7468
|
+
if (curInfo?.key) {
|
|
7469
|
+
loadData(curInfo.key, curInfo);
|
|
7470
|
+
}
|
|
7471
|
+
}
|
|
7472
|
+
}));
|
|
7424
7473
|
const Icons = (v, className, style) => {
|
|
7425
7474
|
const IconMap = new Map([['favorite', jsx(FavoriteSvg, {})], ['space', jsx(SpaceSvg, {})], ['netdisk', jsx(NetdiskSvg, {})], ['album', jsx(AlbumSvg, {})], ['recycle', jsx(RecycleSvg, {})], ['recently', jsx(RecentlySvg, {})], ['coordination', jsx(LinkSvg, {})], ['text', jsx(TextSvg, {})], ['share', jsx(ShareLinkSvg, {})]]);
|
|
7426
7475
|
if (v?.label) {
|
|
@@ -7536,13 +7585,20 @@ const Explorer = props => {
|
|
|
7536
7585
|
function createFolder() {
|
|
7537
7586
|
const addData = (data, key, child) => {
|
|
7538
7587
|
let arr = data;
|
|
7588
|
+
let file = [];
|
|
7589
|
+
let folder = [];
|
|
7539
7590
|
if (key) {
|
|
7540
7591
|
let i = 0;
|
|
7541
7592
|
while (i < arr.length) {
|
|
7542
7593
|
let item = arr[i];
|
|
7543
7594
|
if (item.key == key) {
|
|
7544
7595
|
if (Array.isArray(item.children)) {
|
|
7545
|
-
item.children.
|
|
7596
|
+
item.children.forEach(v => {
|
|
7597
|
+
if (v.type == 'folder') folder.push(v);
|
|
7598
|
+
if (v.type == 'file') file.push(v);
|
|
7599
|
+
});
|
|
7600
|
+
folder.push(child);
|
|
7601
|
+
item.children = [...folder, ...file];
|
|
7546
7602
|
} else {
|
|
7547
7603
|
item.children = [child];
|
|
7548
7604
|
}
|
|
@@ -7555,7 +7611,16 @@ const Explorer = props => {
|
|
|
7555
7611
|
i++;
|
|
7556
7612
|
}
|
|
7557
7613
|
} else {
|
|
7558
|
-
arr.
|
|
7614
|
+
if (arr.length) {
|
|
7615
|
+
arr.forEach(v => {
|
|
7616
|
+
if (v.type == 'folder') folder.push(v);
|
|
7617
|
+
if (v.type == 'file') file.push(v);
|
|
7618
|
+
});
|
|
7619
|
+
folder.push(child);
|
|
7620
|
+
arr = [...folder, ...file];
|
|
7621
|
+
} else {
|
|
7622
|
+
arr.push(child);
|
|
7623
|
+
}
|
|
7559
7624
|
}
|
|
7560
7625
|
return arr || [];
|
|
7561
7626
|
};
|
|
@@ -7566,6 +7631,7 @@ const Explorer = props => {
|
|
|
7566
7631
|
title: '新建文件夹',
|
|
7567
7632
|
create_file: true
|
|
7568
7633
|
});
|
|
7634
|
+
console.log(list, 123);
|
|
7569
7635
|
setCurList(list);
|
|
7570
7636
|
}
|
|
7571
7637
|
return jsx(ExampleContext.Provider, {
|
|
@@ -7587,6 +7653,7 @@ const Explorer = props => {
|
|
|
7587
7653
|
checkMode,
|
|
7588
7654
|
reamekey,
|
|
7589
7655
|
curSelect,
|
|
7656
|
+
curSelectFile,
|
|
7590
7657
|
loadkey,
|
|
7591
7658
|
//icon
|
|
7592
7659
|
getIcons: Icons,
|
|
@@ -7605,6 +7672,7 @@ const Explorer = props => {
|
|
|
7605
7672
|
setLoading,
|
|
7606
7673
|
setReName,
|
|
7607
7674
|
setCurSelect,
|
|
7675
|
+
setCurSelectFile,
|
|
7608
7676
|
setLoadKey
|
|
7609
7677
|
},
|
|
7610
7678
|
children: jsx("div", {
|
|
@@ -7617,7 +7685,7 @@ const Explorer = props => {
|
|
|
7617
7685
|
})
|
|
7618
7686
|
})
|
|
7619
7687
|
});
|
|
7620
|
-
};
|
|
7688
|
+
});
|
|
7621
7689
|
|
|
7622
7690
|
export { ApiStatusEnum, Explorer as default, registerMenu };
|
|
7623
7691
|
//# sourceMappingURL=index.js.map
|