@gingkoo/pandora-explorer 0.0.1-alpha.33 → 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 +114 -47
- 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';
|
|
@@ -1834,6 +1834,14 @@ function Slider(props) {
|
|
|
1834
1834
|
const ref = useRef(null);
|
|
1835
1835
|
const [isdarg, setDarg] = useState(false);
|
|
1836
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]);
|
|
1837
1845
|
useEffect(() => {
|
|
1838
1846
|
if (!size) return;
|
|
1839
1847
|
let d_value = max - min;
|
|
@@ -1845,22 +1853,25 @@ function Slider(props) {
|
|
|
1845
1853
|
let data = value - min;
|
|
1846
1854
|
setSize(data / d_value * 100);
|
|
1847
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
|
+
}
|
|
1848
1872
|
return jsx("div", {
|
|
1849
1873
|
className: '_slider',
|
|
1850
1874
|
ref: ref,
|
|
1851
|
-
onMouseOut: () => {
|
|
1852
|
-
setDarg(false);
|
|
1853
|
-
},
|
|
1854
|
-
onMouseMove: e => {
|
|
1855
|
-
if (!isdarg) return;
|
|
1856
|
-
if (!ref.current) return;
|
|
1857
|
-
let dom = ref.current.getBoundingClientRect();
|
|
1858
|
-
let cur = dom.top + 15;
|
|
1859
|
-
let num = e.clientY - cur;
|
|
1860
|
-
num > 100 ? num = 100 : null;
|
|
1861
|
-
num < 0 ? num = 0 : null;
|
|
1862
|
-
setSize(num);
|
|
1863
|
-
},
|
|
1864
1875
|
children: jsx("div", {
|
|
1865
1876
|
className: '_slider-link',
|
|
1866
1877
|
onClick: e => {
|
|
@@ -1876,11 +1887,8 @@ function Slider(props) {
|
|
|
1876
1887
|
top: size + 'px'
|
|
1877
1888
|
},
|
|
1878
1889
|
className: '_slider-drop',
|
|
1879
|
-
onMouseDown:
|
|
1890
|
+
onMouseDown: e => {
|
|
1880
1891
|
setDarg(true);
|
|
1881
|
-
},
|
|
1882
|
-
onMouseUp: () => {
|
|
1883
|
-
setDarg(false);
|
|
1884
1892
|
}
|
|
1885
1893
|
})
|
|
1886
1894
|
})
|
|
@@ -5258,7 +5266,16 @@ function TableItem(props) {
|
|
|
5258
5266
|
autoFocus: true,
|
|
5259
5267
|
defaultValue: param[v?.key],
|
|
5260
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
|
+
},
|
|
5261
5277
|
onBlur: e => {
|
|
5278
|
+
if (e.target.value === param[v?.key]) return;
|
|
5262
5279
|
onRename?.(e.target.value);
|
|
5263
5280
|
}
|
|
5264
5281
|
})
|
|
@@ -5336,6 +5353,14 @@ var TreeItem = (props => {
|
|
|
5336
5353
|
autoFocus: true,
|
|
5337
5354
|
value: title,
|
|
5338
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
|
+
},
|
|
5339
5364
|
onChange: v => {
|
|
5340
5365
|
setTitle?.(v.target.value);
|
|
5341
5366
|
},
|
|
@@ -5867,7 +5892,8 @@ const ExplorerMenu = props => {
|
|
|
5867
5892
|
loadData,
|
|
5868
5893
|
loadNode,
|
|
5869
5894
|
onMenuClick,
|
|
5870
|
-
onChange
|
|
5895
|
+
onChange,
|
|
5896
|
+
onRename
|
|
5871
5897
|
} = props;
|
|
5872
5898
|
const store = useContext(ExampleContext);
|
|
5873
5899
|
const [eventKey, setEventKey] = useState([]);
|
|
@@ -5887,6 +5913,7 @@ const ExplorerMenu = props => {
|
|
|
5887
5913
|
onMenuClick: onMenuClick,
|
|
5888
5914
|
loadData: loadNode,
|
|
5889
5915
|
onChange: onChange,
|
|
5916
|
+
onRename: onRename,
|
|
5890
5917
|
onSelect: v => {
|
|
5891
5918
|
store.setPathDisplay(v?.pathDisplay);
|
|
5892
5919
|
loadData(v.key);
|
|
@@ -5953,6 +5980,7 @@ const VirtualScroll = ({
|
|
|
5953
5980
|
ref: containerRef,
|
|
5954
5981
|
children: jsx("div", {
|
|
5955
5982
|
style: {
|
|
5983
|
+
position: 'relative',
|
|
5956
5984
|
height: `${data.length * itemHeight}px`,
|
|
5957
5985
|
paddingTop: `${startIdx * itemHeight}px`
|
|
5958
5986
|
},
|
|
@@ -6013,7 +6041,7 @@ function Tile(props) {
|
|
|
6013
6041
|
[className || '']: className
|
|
6014
6042
|
}),
|
|
6015
6043
|
style: {
|
|
6016
|
-
height: '
|
|
6044
|
+
height: height + 'px'
|
|
6017
6045
|
},
|
|
6018
6046
|
onContextMenu: e => {
|
|
6019
6047
|
e.preventDefault();
|
|
@@ -6085,17 +6113,14 @@ function Tile(props) {
|
|
|
6085
6113
|
width: w + 'px',
|
|
6086
6114
|
height: w + 'px',
|
|
6087
6115
|
lineHeight: w + 'px'
|
|
6088
|
-
}) : jsx("
|
|
6089
|
-
className: 'picture',
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
height: w + 'px'
|
|
6097
|
-
}
|
|
6098
|
-
})
|
|
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
|
+
}
|
|
6099
6124
|
})
|
|
6100
6125
|
}), jsx("div", {
|
|
6101
6126
|
className: 'title-type-name',
|
|
@@ -7150,8 +7175,9 @@ const Layout$1 = props => {
|
|
|
7150
7175
|
},
|
|
7151
7176
|
onSelect: v => {
|
|
7152
7177
|
if (v?.type == 'folder' && v.expanded) {
|
|
7153
|
-
store.
|
|
7178
|
+
store.setCurSelectFile(v.key);
|
|
7154
7179
|
}
|
|
7180
|
+
store.setCurSelect(v.key);
|
|
7155
7181
|
},
|
|
7156
7182
|
onRename: onRename,
|
|
7157
7183
|
onMenuClick: onMenuClick,
|
|
@@ -7192,9 +7218,12 @@ function ExplorerInfo(props) {
|
|
|
7192
7218
|
const {
|
|
7193
7219
|
infoshow,
|
|
7194
7220
|
getIcons,
|
|
7195
|
-
curInfo
|
|
7221
|
+
curInfo,
|
|
7222
|
+
dataMap,
|
|
7223
|
+
curSelect
|
|
7196
7224
|
} = useContext(ExampleContext);
|
|
7197
7225
|
const [isEdit, setIsEdit] = useState(false);
|
|
7226
|
+
const [info, setInfo] = useState({});
|
|
7198
7227
|
useEffect(() => {
|
|
7199
7228
|
if (infoshow) {
|
|
7200
7229
|
props?.setSize(285);
|
|
@@ -7202,6 +7231,13 @@ function ExplorerInfo(props) {
|
|
|
7202
7231
|
props?.onMinimize();
|
|
7203
7232
|
}
|
|
7204
7233
|
}, [infoshow]);
|
|
7234
|
+
useEffect(() => {
|
|
7235
|
+
if (curSelect) {
|
|
7236
|
+
setInfo(dataMap?.[curSelect]);
|
|
7237
|
+
} else {
|
|
7238
|
+
setInfo(curInfo);
|
|
7239
|
+
}
|
|
7240
|
+
}, [curInfo, dataMap]);
|
|
7205
7241
|
function rednerInfo() {
|
|
7206
7242
|
return jsxs("div", {
|
|
7207
7243
|
className: 'panel-info',
|
|
@@ -7212,7 +7248,7 @@ function ExplorerInfo(props) {
|
|
|
7212
7248
|
children: "\u8DEF\u5F84:"
|
|
7213
7249
|
}), jsx("div", {
|
|
7214
7250
|
className: 'content',
|
|
7215
|
-
children:
|
|
7251
|
+
children: info?.pathDisplay || '-'
|
|
7216
7252
|
})]
|
|
7217
7253
|
}), jsxs("div", {
|
|
7218
7254
|
className: 'panel-col',
|
|
@@ -7221,7 +7257,7 @@ function ExplorerInfo(props) {
|
|
|
7221
7257
|
children: "\u5927\u5C0F:"
|
|
7222
7258
|
}), jsx("div", {
|
|
7223
7259
|
className: 'content',
|
|
7224
|
-
children: typeof
|
|
7260
|
+
children: typeof info?.size == 'number' ? convertBytesToSize(info?.size) : info?.size || '-'
|
|
7225
7261
|
})]
|
|
7226
7262
|
}), jsxs("div", {
|
|
7227
7263
|
className: 'panel-col',
|
|
@@ -7230,7 +7266,7 @@ function ExplorerInfo(props) {
|
|
|
7230
7266
|
children: "\u521B\u5EFA\u65F6\u95F4 :"
|
|
7231
7267
|
}), jsx("div", {
|
|
7232
7268
|
className: 'content',
|
|
7233
|
-
children: DateFormat(
|
|
7269
|
+
children: DateFormat(info?.createTime)
|
|
7234
7270
|
})]
|
|
7235
7271
|
}), jsxs("div", {
|
|
7236
7272
|
className: 'panel-col',
|
|
@@ -7239,7 +7275,7 @@ function ExplorerInfo(props) {
|
|
|
7239
7275
|
children: "\u4FEE\u6539\u65F6\u95F4 :"
|
|
7240
7276
|
}), jsx("div", {
|
|
7241
7277
|
className: 'content',
|
|
7242
|
-
children: DateFormat(
|
|
7278
|
+
children: DateFormat(info?.createTime)
|
|
7243
7279
|
})]
|
|
7244
7280
|
}), jsxs("div", {
|
|
7245
7281
|
className: 'panel-col',
|
|
@@ -7283,18 +7319,18 @@ function ExplorerInfo(props) {
|
|
|
7283
7319
|
className: 'info-header',
|
|
7284
7320
|
children: [jsx("div", {
|
|
7285
7321
|
className: 'file-icon',
|
|
7286
|
-
children: getIcons(
|
|
7322
|
+
children: getIcons(info, '')
|
|
7287
7323
|
}), jsxs("div", {
|
|
7288
7324
|
className: 'file-name',
|
|
7289
7325
|
children: [jsx("div", {
|
|
7290
7326
|
className: 'title',
|
|
7291
|
-
children:
|
|
7327
|
+
children: info?.title
|
|
7292
7328
|
}), jsxs("div", {
|
|
7293
7329
|
className: 'desc',
|
|
7294
7330
|
children: [jsx("span", {
|
|
7295
|
-
children: typeof
|
|
7331
|
+
children: typeof info?.size == 'number' ? convertBytesToSize(info?.size) : info?.size || '-'
|
|
7296
7332
|
}), jsx("span", {
|
|
7297
|
-
children:
|
|
7333
|
+
children: info?.fixTime || '-'
|
|
7298
7334
|
})]
|
|
7299
7335
|
})]
|
|
7300
7336
|
})]
|
|
@@ -7398,7 +7434,7 @@ const defaultColumns = [{
|
|
|
7398
7434
|
});
|
|
7399
7435
|
}
|
|
7400
7436
|
}];
|
|
7401
|
-
const Explorer = props => {
|
|
7437
|
+
const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
7402
7438
|
const {
|
|
7403
7439
|
data,
|
|
7404
7440
|
columns,
|
|
@@ -7413,7 +7449,8 @@ const Explorer = props => {
|
|
|
7413
7449
|
const [curlist, setCurList] = useState([]);
|
|
7414
7450
|
const [curInfo, setCurInfo] = useState(null);
|
|
7415
7451
|
const [dataMap, setDataMap] = useState({});
|
|
7416
|
-
const [curSelect, setCurSelect] = useState(
|
|
7452
|
+
const [curSelect, setCurSelect] = useState(null); //当前选中信息
|
|
7453
|
+
const [curSelectFile, setCurSelectFile] = useState(''); //当前选中的文件
|
|
7417
7454
|
const [menuSize, setMenuSize] = useState(80);
|
|
7418
7455
|
const [reamekey, setReName] = useState(null);
|
|
7419
7456
|
const [logindex, setLogIndex] = useState(0); //前进
|
|
@@ -7422,6 +7459,17 @@ const Explorer = props => {
|
|
|
7422
7459
|
const [menutype, setMenutype] = useState('tile');
|
|
7423
7460
|
const [infoshow, setInfoShow] = useState(false);
|
|
7424
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
|
+
}));
|
|
7425
7473
|
const Icons = (v, className, style) => {
|
|
7426
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, {})]]);
|
|
7427
7475
|
if (v?.label) {
|
|
@@ -7537,13 +7585,20 @@ const Explorer = props => {
|
|
|
7537
7585
|
function createFolder() {
|
|
7538
7586
|
const addData = (data, key, child) => {
|
|
7539
7587
|
let arr = data;
|
|
7588
|
+
let file = [];
|
|
7589
|
+
let folder = [];
|
|
7540
7590
|
if (key) {
|
|
7541
7591
|
let i = 0;
|
|
7542
7592
|
while (i < arr.length) {
|
|
7543
7593
|
let item = arr[i];
|
|
7544
7594
|
if (item.key == key) {
|
|
7545
7595
|
if (Array.isArray(item.children)) {
|
|
7546
|
-
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];
|
|
7547
7602
|
} else {
|
|
7548
7603
|
item.children = [child];
|
|
7549
7604
|
}
|
|
@@ -7556,7 +7611,16 @@ const Explorer = props => {
|
|
|
7556
7611
|
i++;
|
|
7557
7612
|
}
|
|
7558
7613
|
} else {
|
|
7559
|
-
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
|
+
}
|
|
7560
7624
|
}
|
|
7561
7625
|
return arr || [];
|
|
7562
7626
|
};
|
|
@@ -7567,6 +7631,7 @@ const Explorer = props => {
|
|
|
7567
7631
|
title: '新建文件夹',
|
|
7568
7632
|
create_file: true
|
|
7569
7633
|
});
|
|
7634
|
+
console.log(list, 123);
|
|
7570
7635
|
setCurList(list);
|
|
7571
7636
|
}
|
|
7572
7637
|
return jsx(ExampleContext.Provider, {
|
|
@@ -7588,6 +7653,7 @@ const Explorer = props => {
|
|
|
7588
7653
|
checkMode,
|
|
7589
7654
|
reamekey,
|
|
7590
7655
|
curSelect,
|
|
7656
|
+
curSelectFile,
|
|
7591
7657
|
loadkey,
|
|
7592
7658
|
//icon
|
|
7593
7659
|
getIcons: Icons,
|
|
@@ -7606,6 +7672,7 @@ const Explorer = props => {
|
|
|
7606
7672
|
setLoading,
|
|
7607
7673
|
setReName,
|
|
7608
7674
|
setCurSelect,
|
|
7675
|
+
setCurSelectFile,
|
|
7609
7676
|
setLoadKey
|
|
7610
7677
|
},
|
|
7611
7678
|
children: jsx("div", {
|
|
@@ -7618,7 +7685,7 @@ const Explorer = props => {
|
|
|
7618
7685
|
})
|
|
7619
7686
|
})
|
|
7620
7687
|
});
|
|
7621
|
-
};
|
|
7688
|
+
});
|
|
7622
7689
|
|
|
7623
7690
|
export { ApiStatusEnum, Explorer as default, registerMenu };
|
|
7624
7691
|
//# sourceMappingURL=index.js.map
|