@gingkoo/pandora-explorer 0.0.1-alpha.50 → 0.0.1-alpha.52
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 +499 -379
- package/lib/es/index.js.map +1 -1
- package/lib/es/store.d.ts +2 -0
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-explorer v0.0.1-alpha.
|
|
2
|
+
* @gingkoo/pandora-explorer v0.0.1-alpha.52
|
|
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, useLayoutEffect, useContext, createElement, forwardRef } from 'react';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
8
9
|
import createEmotion from '@emotion/css/create-instance';
|
|
9
10
|
import { cx as cx$2 } from '@emotion/css';
|
|
10
|
-
import { createRoot } from 'react-dom/client';
|
|
11
11
|
import { cloneDeep, truncate } from 'lodash';
|
|
12
12
|
import KeyCode from 'rc-util/lib/KeyCode';
|
|
13
13
|
import pickAttrs from 'rc-util/lib/pickAttrs';
|
|
@@ -1585,30 +1585,9 @@ const ExplorerHead = props => {
|
|
|
1585
1585
|
const pathInputRef = useRef(null);
|
|
1586
1586
|
const [path, setPath] = useState('');
|
|
1587
1587
|
const [pathFocus, setFocus] = useState(false);
|
|
1588
|
-
useLayoutEffect(() => {
|
|
1589
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
1590
|
-
return () => {
|
|
1591
|
-
document.removeEventListener('keydown', handleKeyDown);
|
|
1592
|
-
};
|
|
1593
|
-
}, [path, pathFocus]);
|
|
1594
1588
|
useEffect(() => {
|
|
1595
1589
|
setPath(store?.curInfo?.pathDisplay || '');
|
|
1596
1590
|
}, [store?.curInfo?.pathDisplay]);
|
|
1597
|
-
const handleKeyDown = e => {
|
|
1598
|
-
if (e.altKey && e.key === '3') {
|
|
1599
|
-
store?.setMenutype('column');
|
|
1600
|
-
}
|
|
1601
|
-
if (e.altKey && e.key === '2') {
|
|
1602
|
-
store?.setMenutype('table');
|
|
1603
|
-
}
|
|
1604
|
-
if (e.altKey && e.key === '1') {
|
|
1605
|
-
store?.setMenutype('tile');
|
|
1606
|
-
}
|
|
1607
|
-
if (pathFocus && (e.key === 'Enter' || e.keyCode === 13)) {
|
|
1608
|
-
loadData?.(path);
|
|
1609
|
-
setFocus(false);
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
1591
|
const Breadcrumb = useMemo(() => {
|
|
1613
1592
|
let arr = [];
|
|
1614
1593
|
let path = store?.curInfo?.pathDisplay || '';
|
|
@@ -1731,6 +1710,12 @@ const ExplorerHead = props => {
|
|
|
1731
1710
|
},
|
|
1732
1711
|
className: 'path',
|
|
1733
1712
|
spellCheck: 'false',
|
|
1713
|
+
onKeyDown: e => {
|
|
1714
|
+
if (pathFocus && (e.key === 'Enter' || e.keyCode === 13)) {
|
|
1715
|
+
loadData?.(path);
|
|
1716
|
+
setFocus(false);
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1734
1719
|
onBlur: v => {
|
|
1735
1720
|
loadData?.(v.target.value);
|
|
1736
1721
|
setFocus(false);
|
|
@@ -5229,17 +5214,17 @@ function TableItem(props) {
|
|
|
5229
5214
|
loadMenu,
|
|
5230
5215
|
...param
|
|
5231
5216
|
} = props;
|
|
5232
|
-
return jsx(
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
},
|
|
5217
|
+
return jsx("div", {
|
|
5218
|
+
className: cx$1('explorer-tree-row'),
|
|
5219
|
+
"data-id": id,
|
|
5220
|
+
"data-type": props.type,
|
|
5237
5221
|
onContextMenu: e => {
|
|
5238
5222
|
e.stopPropagation();
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5223
|
+
e.preventDefault();
|
|
5224
|
+
let x = 0;
|
|
5225
|
+
let y = 0;
|
|
5226
|
+
x = e.nativeEvent.clientX + 5;
|
|
5227
|
+
y = e.nativeEvent.clientY + 5;
|
|
5243
5228
|
if (!props.isOpenMenu) return;
|
|
5244
5229
|
let menudata = [];
|
|
5245
5230
|
if (getMenu(props.id)) {
|
|
@@ -5249,133 +5234,134 @@ function TableItem(props) {
|
|
|
5249
5234
|
} else {
|
|
5250
5235
|
menudata = getMenu('');
|
|
5251
5236
|
}
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5237
|
+
props?.openMenu({
|
|
5238
|
+
x,
|
|
5239
|
+
y,
|
|
5240
|
+
content: jsx(Menu, {
|
|
5241
|
+
menu: menudata,
|
|
5242
|
+
loadMenu: loadMenu,
|
|
5243
|
+
onChange: async v => {
|
|
5244
|
+
onMenuClick && onMenuClick(v);
|
|
5245
|
+
props?.closeMenu?.();
|
|
5246
|
+
}
|
|
5247
|
+
})
|
|
5248
|
+
}, {
|
|
5249
|
+
key: props.id
|
|
5259
5250
|
});
|
|
5260
5251
|
},
|
|
5261
|
-
children:
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
if (i == 0 && typeof param.level === 'number') {
|
|
5268
|
-
x = x - param.level * 16;
|
|
5269
|
-
}
|
|
5270
|
-
if (typeof v?.render === 'function') {
|
|
5271
|
-
return jsxs("div", {
|
|
5272
|
-
className: cx$1('row-item'),
|
|
5273
|
-
style: width[i] ? {
|
|
5274
|
-
flex: `0 0 ${x}px`,
|
|
5275
|
-
width: x + 'px'
|
|
5276
|
-
} : {},
|
|
5277
|
-
children: [jsxs("div", {
|
|
5278
|
-
className: 'row-item-content',
|
|
5279
|
-
children: [" ", v.render?.(param, v.key)]
|
|
5280
|
-
}), !i && jsx("div", {
|
|
5281
|
-
children: jsx("div", {
|
|
5282
|
-
className: cx$1('row-item-check', {
|
|
5283
|
-
active: active
|
|
5284
|
-
}),
|
|
5285
|
-
onMouseDown: e => {
|
|
5286
|
-
e.stopPropagation();
|
|
5287
|
-
},
|
|
5288
|
-
onClick: e => {
|
|
5289
|
-
e.stopPropagation();
|
|
5290
|
-
e.preventDefault();
|
|
5291
|
-
onCheck?.();
|
|
5292
|
-
},
|
|
5293
|
-
children: jsx("span", {
|
|
5294
|
-
className: 'btn-check',
|
|
5295
|
-
children: jsx(CircleCheckSvg, {})
|
|
5296
|
-
})
|
|
5297
|
-
})
|
|
5298
|
-
})]
|
|
5299
|
-
}, i);
|
|
5300
|
-
}
|
|
5301
|
-
if (rename && v.key == 'title') {
|
|
5302
|
-
return jsx("div", {
|
|
5303
|
-
className: cx$1('row-item'),
|
|
5304
|
-
style: width[i] ? {
|
|
5305
|
-
flex: `0 0 ${x}px`,
|
|
5306
|
-
width: x + 'px'
|
|
5307
|
-
} : {},
|
|
5308
|
-
children: jsx("div", {
|
|
5309
|
-
className: 'row-item-content',
|
|
5310
|
-
children: jsx("input", {
|
|
5311
|
-
className: 'node-input',
|
|
5312
|
-
autoFocus: true,
|
|
5313
|
-
defaultValue: param[v?.key],
|
|
5314
|
-
placeholder: '\u8BF7\u8F93\u5165',
|
|
5315
|
-
onKeyDown: e => {
|
|
5316
|
-
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
5317
|
-
if (props.create_file) {
|
|
5318
|
-
onRename?.(e.target?.value);
|
|
5319
|
-
return;
|
|
5320
|
-
}
|
|
5321
|
-
if (e.target?.value === param[v?.key]) {
|
|
5322
|
-
onRename?.(false);
|
|
5323
|
-
return;
|
|
5324
|
-
}
|
|
5325
|
-
onRename?.(e.target?.value);
|
|
5326
|
-
}
|
|
5327
|
-
},
|
|
5328
|
-
onFocus: e => {
|
|
5329
|
-
let i = param[v?.key]?.lastIndexOf('.');
|
|
5330
|
-
if (props?.suffix == 'folder') {
|
|
5331
|
-
e.target.setSelectionRange(0, param[v?.key]?.length);
|
|
5332
|
-
} else if (i !== -1) {
|
|
5333
|
-
e.target.setSelectionRange(0, i);
|
|
5334
|
-
}
|
|
5335
|
-
},
|
|
5336
|
-
onBlur: e => {
|
|
5337
|
-
if (props.create_file) {
|
|
5338
|
-
onRename?.(e.target.value);
|
|
5339
|
-
return;
|
|
5340
|
-
}
|
|
5341
|
-
if (e.target.value === param[v?.key]) {
|
|
5342
|
-
onRename?.(false);
|
|
5343
|
-
return;
|
|
5344
|
-
}
|
|
5345
|
-
onRename?.(e.target.value);
|
|
5346
|
-
}
|
|
5347
|
-
})
|
|
5348
|
-
})
|
|
5349
|
-
}, i);
|
|
5350
|
-
}
|
|
5252
|
+
children: columns.map((v, i) => {
|
|
5253
|
+
let x = width[i] - (i ? 0 : 58 + 8) + (i ? 10 : 0);
|
|
5254
|
+
if (i == 0 && typeof param.level === 'number') {
|
|
5255
|
+
x = x - param.level * 16;
|
|
5256
|
+
}
|
|
5257
|
+
if (typeof v?.render === 'function') {
|
|
5351
5258
|
return jsxs("div", {
|
|
5352
5259
|
className: cx$1('row-item'),
|
|
5353
5260
|
style: width[i] ? {
|
|
5354
5261
|
flex: `0 0 ${x}px`,
|
|
5355
5262
|
width: x + 'px'
|
|
5356
5263
|
} : {},
|
|
5357
|
-
children: [
|
|
5264
|
+
children: [jsxs("div", {
|
|
5358
5265
|
className: 'row-item-content',
|
|
5359
|
-
children:
|
|
5266
|
+
children: [" ", v.render?.(param, v.key)]
|
|
5360
5267
|
}), !i && jsx("div", {
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
e
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
e
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5268
|
+
children: jsx("div", {
|
|
5269
|
+
className: cx$1('row-item-check', {
|
|
5270
|
+
active: active
|
|
5271
|
+
}),
|
|
5272
|
+
onMouseDown: e => {
|
|
5273
|
+
e.stopPropagation();
|
|
5274
|
+
},
|
|
5275
|
+
onClick: e => {
|
|
5276
|
+
e.stopPropagation();
|
|
5277
|
+
e.preventDefault();
|
|
5278
|
+
onCheck?.();
|
|
5279
|
+
},
|
|
5280
|
+
children: jsx("span", {
|
|
5281
|
+
className: 'btn-check',
|
|
5282
|
+
children: jsx(CircleCheckSvg, {})
|
|
5283
|
+
})
|
|
5375
5284
|
})
|
|
5376
5285
|
})]
|
|
5377
5286
|
}, i);
|
|
5378
|
-
}
|
|
5287
|
+
}
|
|
5288
|
+
if (rename && v.key == 'title') {
|
|
5289
|
+
return jsx("div", {
|
|
5290
|
+
className: cx$1('row-item'),
|
|
5291
|
+
style: width[i] ? {
|
|
5292
|
+
flex: `0 0 ${x}px`,
|
|
5293
|
+
width: x + 'px'
|
|
5294
|
+
} : {},
|
|
5295
|
+
children: jsx("div", {
|
|
5296
|
+
className: 'row-item-content',
|
|
5297
|
+
children: jsx("input", {
|
|
5298
|
+
className: 'node-input',
|
|
5299
|
+
autoFocus: true,
|
|
5300
|
+
defaultValue: param[v?.key],
|
|
5301
|
+
placeholder: '\u8BF7\u8F93\u5165',
|
|
5302
|
+
onKeyDown: e => {
|
|
5303
|
+
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
5304
|
+
if (props.create_file) {
|
|
5305
|
+
onRename?.(e.target?.value);
|
|
5306
|
+
return;
|
|
5307
|
+
}
|
|
5308
|
+
if (e.target?.value === param[v?.key]) {
|
|
5309
|
+
onRename?.(false);
|
|
5310
|
+
return;
|
|
5311
|
+
}
|
|
5312
|
+
onRename?.(e.target?.value);
|
|
5313
|
+
}
|
|
5314
|
+
},
|
|
5315
|
+
onFocus: e => {
|
|
5316
|
+
let i = param[v?.key]?.lastIndexOf('.');
|
|
5317
|
+
if (props?.suffix == 'folder') {
|
|
5318
|
+
e.target.setSelectionRange(0, param[v?.key]?.length);
|
|
5319
|
+
} else if (i !== -1) {
|
|
5320
|
+
e.target.setSelectionRange(0, i);
|
|
5321
|
+
}
|
|
5322
|
+
},
|
|
5323
|
+
onBlur: e => {
|
|
5324
|
+
if (props.create_file) {
|
|
5325
|
+
onRename?.(e.target.value);
|
|
5326
|
+
return;
|
|
5327
|
+
}
|
|
5328
|
+
if (e.target.value === param[v?.key]) {
|
|
5329
|
+
onRename?.(false);
|
|
5330
|
+
return;
|
|
5331
|
+
}
|
|
5332
|
+
onRename?.(e.target.value);
|
|
5333
|
+
}
|
|
5334
|
+
})
|
|
5335
|
+
})
|
|
5336
|
+
}, i);
|
|
5337
|
+
}
|
|
5338
|
+
return jsxs("div", {
|
|
5339
|
+
className: cx$1('row-item'),
|
|
5340
|
+
style: width[i] ? {
|
|
5341
|
+
flex: `0 0 ${x}px`,
|
|
5342
|
+
width: x + 'px'
|
|
5343
|
+
} : {},
|
|
5344
|
+
children: [jsx("div", {
|
|
5345
|
+
className: 'row-item-content',
|
|
5346
|
+
children: param[v?.key] || ''
|
|
5347
|
+
}), !i && jsx("div", {
|
|
5348
|
+
className: cx$1('row-item-check', {
|
|
5349
|
+
active: active
|
|
5350
|
+
}),
|
|
5351
|
+
onMouseDown: e => {
|
|
5352
|
+
e.stopPropagation();
|
|
5353
|
+
},
|
|
5354
|
+
onClick: e => {
|
|
5355
|
+
e.stopPropagation();
|
|
5356
|
+
e.preventDefault();
|
|
5357
|
+
onCheck?.();
|
|
5358
|
+
},
|
|
5359
|
+
children: jsx("span", {
|
|
5360
|
+
className: 'btn-check',
|
|
5361
|
+
children: jsx(CircleCheckSvg, {})
|
|
5362
|
+
})
|
|
5363
|
+
})]
|
|
5364
|
+
}, i);
|
|
5379
5365
|
})
|
|
5380
5366
|
});
|
|
5381
5367
|
}
|
|
@@ -5398,22 +5384,26 @@ var TreeItem = (props => {
|
|
|
5398
5384
|
} else {
|
|
5399
5385
|
menudata = getMenu('');
|
|
5400
5386
|
}
|
|
5401
|
-
return jsx(
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5387
|
+
return jsx("div", {
|
|
5388
|
+
onContextMenu: e => {
|
|
5389
|
+
e.preventDefault();
|
|
5390
|
+
let x = 0;
|
|
5391
|
+
let y = 0;
|
|
5392
|
+
x = e.nativeEvent.clientX + 5;
|
|
5393
|
+
y = e.nativeEvent.clientY + 5;
|
|
5394
|
+
props?.openMenu({
|
|
5395
|
+
x,
|
|
5396
|
+
y,
|
|
5397
|
+
content: jsx(Menu, {
|
|
5398
|
+
menu: menudata,
|
|
5399
|
+
loadMenu: loadMenu,
|
|
5400
|
+
onChange: async v => {
|
|
5401
|
+
onMenuClick && onMenuClick(v);
|
|
5402
|
+
props?.closeMenu?.();
|
|
5403
|
+
}
|
|
5404
|
+
})
|
|
5405
|
+
}, {
|
|
5406
|
+
key: props.id
|
|
5417
5407
|
});
|
|
5418
5408
|
},
|
|
5419
5409
|
children: props.rename ? jsx("div", {
|
|
@@ -5883,6 +5873,7 @@ var Tree = (props => {
|
|
|
5883
5873
|
},
|
|
5884
5874
|
onClick: e => {
|
|
5885
5875
|
e.stopPropagation();
|
|
5876
|
+
props?.closeMenu();
|
|
5886
5877
|
},
|
|
5887
5878
|
onLoad: v => {
|
|
5888
5879
|
if (v.length == loadedKeys?.length) return;
|
|
@@ -5979,6 +5970,7 @@ const ExplorerMenu = props => {
|
|
|
5979
5970
|
expandedKeys,
|
|
5980
5971
|
onMenuClick: _onMenuClick,
|
|
5981
5972
|
onChange,
|
|
5973
|
+
loadMenu,
|
|
5982
5974
|
onRename: _onRename
|
|
5983
5975
|
} = props;
|
|
5984
5976
|
const store = useContext(ExampleContext);
|
|
@@ -5998,6 +5990,10 @@ const ExplorerMenu = props => {
|
|
|
5998
5990
|
function onMenuClick(key, data) {
|
|
5999
5991
|
_onMenuClick(key, data, 'menu');
|
|
6000
5992
|
}
|
|
5993
|
+
const openMenu = (props, param) => {
|
|
5994
|
+
setSelect(param.key);
|
|
5995
|
+
store.openMenu(props);
|
|
5996
|
+
};
|
|
6001
5997
|
return jsx("div", {
|
|
6002
5998
|
className: 'frame-left',
|
|
6003
5999
|
onContextMenu: e => {
|
|
@@ -6016,8 +6012,11 @@ const ExplorerMenu = props => {
|
|
|
6016
6012
|
},
|
|
6017
6013
|
onMenuClick: onMenuClick,
|
|
6018
6014
|
loadData: loadNode,
|
|
6015
|
+
loadMenu: loadMenu,
|
|
6019
6016
|
onChange: onChange,
|
|
6020
6017
|
onRename: onRename,
|
|
6018
|
+
openMenu: openMenu,
|
|
6019
|
+
closeMenu: store.closeMenu,
|
|
6021
6020
|
onSelect: v => {
|
|
6022
6021
|
if (v.key === store.curInfo?.key) return;
|
|
6023
6022
|
store.setPathDisplay(v?.pathDisplay);
|
|
@@ -6174,7 +6173,7 @@ function Tile(props) {
|
|
|
6174
6173
|
menudata = getMenu('');
|
|
6175
6174
|
}
|
|
6176
6175
|
let isname = rekey == v.key || v?.create_file;
|
|
6177
|
-
return
|
|
6176
|
+
return jsxs("div", {
|
|
6178
6177
|
"data-id": v.key,
|
|
6179
6178
|
"data-type": v.type,
|
|
6180
6179
|
className: cx$1('file', {
|
|
@@ -6197,79 +6196,68 @@ function Tile(props) {
|
|
|
6197
6196
|
onDoubleClick: () => {
|
|
6198
6197
|
onDblclick?.(v.key, v);
|
|
6199
6198
|
},
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6199
|
+
onContextMenu: e => {
|
|
6200
|
+
e.preventDefault();
|
|
6201
|
+
e.stopPropagation();
|
|
6202
|
+
let x = 0;
|
|
6203
|
+
let y = 0;
|
|
6204
|
+
x = e.nativeEvent.clientX + 5;
|
|
6205
|
+
y = e.nativeEvent.clientY + 5;
|
|
6206
|
+
props.openMenu({
|
|
6207
|
+
x: x,
|
|
6208
|
+
y: y,
|
|
6209
|
+
content: jsx(Menu, {
|
|
6209
6210
|
menu: menudata,
|
|
6210
6211
|
loadMenu: loadMenu,
|
|
6211
6212
|
onChange: key => {
|
|
6212
6213
|
if (key == 'rename') {
|
|
6213
6214
|
setRekey(v.key);
|
|
6214
|
-
onClone();
|
|
6215
6215
|
return;
|
|
6216
6216
|
}
|
|
6217
6217
|
onMenuClick?.(key, v);
|
|
6218
|
-
|
|
6218
|
+
props.closeMenu();
|
|
6219
6219
|
}
|
|
6220
|
-
})
|
|
6220
|
+
})
|
|
6221
|
+
}, v);
|
|
6222
|
+
},
|
|
6223
|
+
children: [jsx("i", {
|
|
6224
|
+
className: cx$1('path-ico'),
|
|
6225
|
+
style: {
|
|
6226
|
+
width: w + 'px',
|
|
6227
|
+
height: w - w / 10 + 'px'
|
|
6221
6228
|
},
|
|
6222
|
-
children:
|
|
6223
|
-
|
|
6229
|
+
children: v.type === 'folder' || !v?.pic ? icons(v, 'x-item-icon', {
|
|
6230
|
+
width: w + 'px',
|
|
6231
|
+
height: w + 'px',
|
|
6232
|
+
lineHeight: w + 'px'
|
|
6233
|
+
}) : jsx("img", {
|
|
6234
|
+
className: 'picture-show',
|
|
6235
|
+
draggable: 'false',
|
|
6236
|
+
src: v.pic,
|
|
6224
6237
|
style: {
|
|
6225
6238
|
width: w + 'px',
|
|
6226
|
-
height: w
|
|
6227
|
-
}
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
+
height: w + 'px'
|
|
6240
|
+
}
|
|
6241
|
+
})
|
|
6242
|
+
}), jsx("div", {
|
|
6243
|
+
className: 'title-type-name',
|
|
6244
|
+
style: {
|
|
6245
|
+
width: w + 'px'
|
|
6246
|
+
},
|
|
6247
|
+
children: isname ? jsx("textarea", {
|
|
6248
|
+
autoFocus: true,
|
|
6249
|
+
rows: 3,
|
|
6250
|
+
defaultValue: v.title,
|
|
6251
|
+
onFocus: e => {
|
|
6252
|
+
let i = v.title.lastIndexOf('.');
|
|
6253
|
+
if (props?.suffix == 'folder') {
|
|
6254
|
+
e.target.setSelectionRange(0, v.title.length);
|
|
6255
|
+
} else if (i !== -1) {
|
|
6256
|
+
e.target.setSelectionRange(0, i);
|
|
6239
6257
|
}
|
|
6240
|
-
})
|
|
6241
|
-
}), jsx("div", {
|
|
6242
|
-
className: 'title-type-name',
|
|
6243
|
-
style: {
|
|
6244
|
-
width: w + 'px'
|
|
6245
6258
|
},
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
rows: 3,
|
|
6249
|
-
defaultValue: v.title,
|
|
6250
|
-
onFocus: e => {
|
|
6251
|
-
let i = v.title.lastIndexOf('.');
|
|
6252
|
-
if (props?.suffix == 'folder') {
|
|
6253
|
-
e.target.setSelectionRange(0, v.title.length);
|
|
6254
|
-
} else if (i !== -1) {
|
|
6255
|
-
e.target.setSelectionRange(0, i);
|
|
6256
|
-
}
|
|
6257
|
-
},
|
|
6258
|
-
onKeyDown: e => {
|
|
6259
|
-
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
6260
|
-
if (props.create_file) {
|
|
6261
|
-
onRename?.(v.key, e.target?.value, v);
|
|
6262
|
-
return;
|
|
6263
|
-
}
|
|
6264
|
-
if (e.target?.value === v.title) {
|
|
6265
|
-
setRekey(null);
|
|
6266
|
-
return;
|
|
6267
|
-
}
|
|
6268
|
-
onRename?.(v.key, e.target.value, v);
|
|
6269
|
-
setRekey(null);
|
|
6270
|
-
}
|
|
6271
|
-
},
|
|
6272
|
-
onBlur: e => {
|
|
6259
|
+
onKeyDown: e => {
|
|
6260
|
+
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
6273
6261
|
if (props.create_file) {
|
|
6274
6262
|
onRename?.(v.key, e.target?.value, v);
|
|
6275
6263
|
return;
|
|
@@ -6280,16 +6268,28 @@ function Tile(props) {
|
|
|
6280
6268
|
}
|
|
6281
6269
|
onRename?.(v.key, e.target.value, v);
|
|
6282
6270
|
setRekey(null);
|
|
6283
|
-
},
|
|
6284
|
-
onMouseDown: e => {
|
|
6285
|
-
e.stopPropagation();
|
|
6286
6271
|
}
|
|
6287
|
-
}
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6272
|
+
},
|
|
6273
|
+
onBlur: e => {
|
|
6274
|
+
if (props.create_file) {
|
|
6275
|
+
onRename?.(v.key, e.target?.value, v);
|
|
6276
|
+
return;
|
|
6277
|
+
}
|
|
6278
|
+
if (e.target?.value === v.title) {
|
|
6279
|
+
setRekey(null);
|
|
6280
|
+
return;
|
|
6281
|
+
}
|
|
6282
|
+
onRename?.(v.key, e.target.value, v);
|
|
6283
|
+
setRekey(null);
|
|
6284
|
+
},
|
|
6285
|
+
onMouseDown: e => {
|
|
6286
|
+
e.stopPropagation();
|
|
6287
|
+
}
|
|
6288
|
+
}) : jsx("span", {
|
|
6289
|
+
className: 'title',
|
|
6290
|
+
children: v.title
|
|
6291
|
+
})
|
|
6292
|
+
})]
|
|
6293
6293
|
}, v.key);
|
|
6294
6294
|
})
|
|
6295
6295
|
}, index);
|
|
@@ -6429,10 +6429,11 @@ const SelectBox = props => {
|
|
|
6429
6429
|
clientX: x,
|
|
6430
6430
|
clientY: y
|
|
6431
6431
|
} = e;
|
|
6432
|
+
//动画
|
|
6432
6433
|
if (!time && cur?.current?.length && isDrag) {
|
|
6433
6434
|
cur.current?.map((v, i) => {
|
|
6434
6435
|
v.style.cssText = `
|
|
6435
|
-
position: absolute;
|
|
6436
|
+
position: absolute;
|
|
6436
6437
|
transition: 0.3s;
|
|
6437
6438
|
top:${y + i * 3}px;
|
|
6438
6439
|
left:${x + i * 3}px;
|
|
@@ -6443,23 +6444,22 @@ const SelectBox = props => {
|
|
|
6443
6444
|
cur.current = [];
|
|
6444
6445
|
}, 200);
|
|
6445
6446
|
}
|
|
6447
|
+
//移动
|
|
6446
6448
|
if (isDrag && selects.length) {
|
|
6447
6449
|
if (target.current) {
|
|
6448
6450
|
target.current.style.cssText = `
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6451
|
+
position: absolute;
|
|
6452
|
+
top:${y}px;
|
|
6453
|
+
left:${x}px;
|
|
6454
|
+
`;
|
|
6453
6455
|
}
|
|
6454
6456
|
} else {
|
|
6457
|
+
//选框
|
|
6455
6458
|
createBox(e);
|
|
6456
6459
|
}
|
|
6457
6460
|
}
|
|
6458
6461
|
//鼠标松开
|
|
6459
6462
|
function handleBodyMouseup() {
|
|
6460
|
-
if (isDclick.current) {
|
|
6461
|
-
clearTimeout(isDclick.current);
|
|
6462
|
-
}
|
|
6463
6463
|
if (target.current) {
|
|
6464
6464
|
empty();
|
|
6465
6465
|
} else {
|
|
@@ -6484,7 +6484,7 @@ const SelectBox = props => {
|
|
|
6484
6484
|
}, 300);
|
|
6485
6485
|
}
|
|
6486
6486
|
}
|
|
6487
|
-
|
|
6487
|
+
//拖动文件
|
|
6488
6488
|
const handleDragOver = e => {
|
|
6489
6489
|
e.preventDefault();
|
|
6490
6490
|
const {
|
|
@@ -6530,7 +6530,10 @@ const SelectBox = props => {
|
|
|
6530
6530
|
const traverseFileTree = (item, path = '') => {
|
|
6531
6531
|
if (item.isFile) {
|
|
6532
6532
|
item.file(file => {
|
|
6533
|
-
files = [...files,
|
|
6533
|
+
files = [...files, {
|
|
6534
|
+
file: file,
|
|
6535
|
+
path: path
|
|
6536
|
+
}];
|
|
6534
6537
|
});
|
|
6535
6538
|
} else if (item.isDirectory) {
|
|
6536
6539
|
const dirReader = item.createReader();
|
|
@@ -6843,109 +6846,104 @@ const SelectBox = props => {
|
|
|
6843
6846
|
})
|
|
6844
6847
|
});
|
|
6845
6848
|
}
|
|
6846
|
-
return
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
+
return jsxs("div", {
|
|
6850
|
+
ref: ref,
|
|
6851
|
+
className: cx$1(`file-select-box ${className}`),
|
|
6852
|
+
onDragLeave: e => {
|
|
6853
|
+
e.preventDefault();
|
|
6849
6854
|
},
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
store.createFolder();
|
|
6877
|
-
onClone();
|
|
6878
|
-
return;
|
|
6855
|
+
onDoubleClick: () => {
|
|
6856
|
+
clearTimeout(isDclick.current);
|
|
6857
|
+
},
|
|
6858
|
+
onMouseDown: e => {
|
|
6859
|
+
let type = isSelectTarget(e, checkType);
|
|
6860
|
+
if (checks.includes(type?.[0])) {
|
|
6861
|
+
//右键不能今天拖动
|
|
6862
|
+
if (e.button === 2) return;
|
|
6863
|
+
if (!isDrag && checkMode == 'check') {
|
|
6864
|
+
isDclick.current = setTimeout(() => {
|
|
6865
|
+
let arr = checks.filter(v => v !== type?.[0]);
|
|
6866
|
+
setSelect(arr);
|
|
6867
|
+
onChange(arr);
|
|
6868
|
+
}, 200);
|
|
6869
|
+
}
|
|
6870
|
+
time = null;
|
|
6871
|
+
isDrag && createVDom(e);
|
|
6872
|
+
return;
|
|
6873
|
+
}
|
|
6874
|
+
//在区域未选中
|
|
6875
|
+
if (Array.isArray(type)) {
|
|
6876
|
+
if (checkMode == 'check') {
|
|
6877
|
+
if (!checks.includes(type?.[0])) {
|
|
6878
|
+
let arr = [...selects, ...type];
|
|
6879
|
+
setSelect(arr);
|
|
6880
|
+
onChange(arr);
|
|
6879
6881
|
}
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
+
} else {
|
|
6883
|
+
setSelect(type);
|
|
6884
|
+
onChange(type);
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
isDclick.current = null;
|
|
6888
|
+
if (type) return;
|
|
6889
|
+
if (selects.length) {
|
|
6890
|
+
if (checkMode !== 'check') {
|
|
6891
|
+
setSelect([]);
|
|
6892
|
+
onChange([]);
|
|
6893
|
+
empty();
|
|
6882
6894
|
}
|
|
6895
|
+
}
|
|
6896
|
+
//创建选取
|
|
6897
|
+
clickRef.current = false;
|
|
6898
|
+
isSelectBoxes && setStageClickInfo({
|
|
6899
|
+
show: true,
|
|
6900
|
+
x: e.clientX,
|
|
6901
|
+
y: e.clientY
|
|
6883
6902
|
});
|
|
6884
6903
|
},
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
if (
|
|
6904
|
-
|
|
6905
|
-
let arr = checks.filter(v => v !== type?.[0]);
|
|
6906
|
-
setSelect(arr);
|
|
6907
|
-
onChange(arr);
|
|
6904
|
+
onContextMenu: e => {
|
|
6905
|
+
let x = 0;
|
|
6906
|
+
let y = 0;
|
|
6907
|
+
x = e.nativeEvent.clientX + 5;
|
|
6908
|
+
y = e.nativeEvent.clientY + 5;
|
|
6909
|
+
store.openMenu({
|
|
6910
|
+
x: x,
|
|
6911
|
+
y: y,
|
|
6912
|
+
content: jsx(Menu, {
|
|
6913
|
+
menu: menudata,
|
|
6914
|
+
loadMenu: v => {
|
|
6915
|
+
let menu = loadMenu(v);
|
|
6916
|
+
if (menu?.key == 'rename') return undefined;
|
|
6917
|
+
if (menu?.key == 'copy') return undefined;
|
|
6918
|
+
return menu;
|
|
6919
|
+
},
|
|
6920
|
+
onChange: key => {
|
|
6921
|
+
if (key == 'update') {
|
|
6922
|
+
if (store?.curInfo) {
|
|
6923
|
+
loadData(store?.curInfo?.key);
|
|
6908
6924
|
}
|
|
6909
|
-
|
|
6910
|
-
isDrag && createVDom(e);
|
|
6925
|
+
store.closeMenu();
|
|
6911
6926
|
return;
|
|
6912
6927
|
}
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
let arr = [...selects, ...type];
|
|
6918
|
-
setSelect(arr);
|
|
6919
|
-
onChange(arr);
|
|
6920
|
-
}
|
|
6921
|
-
} else {
|
|
6922
|
-
setSelect(type);
|
|
6923
|
-
onChange(type);
|
|
6924
|
-
}
|
|
6928
|
+
if (key == 'file-upload') {
|
|
6929
|
+
store.uploadFile();
|
|
6930
|
+
store.closeMenu();
|
|
6931
|
+
return;
|
|
6925
6932
|
}
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
if (checkMode !== 'check') {
|
|
6931
|
-
setSelect([]);
|
|
6932
|
-
onChange([]);
|
|
6933
|
-
empty();
|
|
6933
|
+
if (key == 'create') {
|
|
6934
|
+
store.createFolder();
|
|
6935
|
+
store.closeMenu();
|
|
6936
|
+
return;
|
|
6934
6937
|
}
|
|
6938
|
+
onMenuClick?.(key, store.curInfo);
|
|
6939
|
+
store.closeMenu();
|
|
6935
6940
|
}
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
});
|
|
6943
|
-
}
|
|
6944
|
-
},
|
|
6945
|
-
children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
|
|
6946
|
-
ref: selectionRef
|
|
6947
|
-
}), document.body)]
|
|
6948
|
-
})
|
|
6941
|
+
})
|
|
6942
|
+
}, store?.curInfo);
|
|
6943
|
+
},
|
|
6944
|
+
children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
|
|
6945
|
+
ref: selectionRef
|
|
6946
|
+
}), document.body)]
|
|
6949
6947
|
});
|
|
6950
6948
|
};
|
|
6951
6949
|
|
|
@@ -7228,7 +7226,7 @@ const Layout$1 = props => {
|
|
|
7228
7226
|
const [expandkey, setExpandkey] = useState([]);
|
|
7229
7227
|
useEffect(() => {
|
|
7230
7228
|
setExpandkey([]);
|
|
7231
|
-
}, [store
|
|
7229
|
+
}, [store?.curInfo?.key]);
|
|
7232
7230
|
function Loading() {
|
|
7233
7231
|
return jsx("div", {
|
|
7234
7232
|
className: 'explorer-columns-loading',
|
|
@@ -7337,6 +7335,8 @@ const Layout$1 = props => {
|
|
|
7337
7335
|
showLine: false,
|
|
7338
7336
|
isOpenMenu: isOpenMenu,
|
|
7339
7337
|
icon: store.getIcons,
|
|
7338
|
+
openMenu: store.openMenu,
|
|
7339
|
+
closeMenu: store.closeMenu,
|
|
7340
7340
|
isload: true,
|
|
7341
7341
|
ischeck: truncate,
|
|
7342
7342
|
onChecks: arr => {
|
|
@@ -7377,6 +7377,8 @@ const Layout$1 = props => {
|
|
|
7377
7377
|
data: store.curlist,
|
|
7378
7378
|
icons: store.getIcons,
|
|
7379
7379
|
checks: checks,
|
|
7380
|
+
openMenu: store.openMenu,
|
|
7381
|
+
closeMenu: store.closeMenu,
|
|
7380
7382
|
onSelect: (key, v) => {
|
|
7381
7383
|
store.setCurSelect(v.key);
|
|
7382
7384
|
},
|
|
@@ -7645,6 +7647,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7645
7647
|
const [menutype, setMenutype] = useState('tile');
|
|
7646
7648
|
const [infoshow, setInfoShow] = useState(false);
|
|
7647
7649
|
const [loading, setLoading] = useState(ApiStatusEnum.READY);
|
|
7650
|
+
const box = useRef(null);
|
|
7651
|
+
const boxMenu = useRef(null);
|
|
7652
|
+
const menu = useRef(null);
|
|
7648
7653
|
useImperativeHandle(ref, () => ({
|
|
7649
7654
|
removeLog: () => {
|
|
7650
7655
|
//清空日志
|
|
@@ -7669,6 +7674,52 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7669
7674
|
}
|
|
7670
7675
|
}
|
|
7671
7676
|
}));
|
|
7677
|
+
/* ************ 挂载监听 **************** */
|
|
7678
|
+
useEffect(() => {
|
|
7679
|
+
window.addEventListener('click', closeMenu);
|
|
7680
|
+
window.addEventListener('click', closeMenu);
|
|
7681
|
+
return () => {
|
|
7682
|
+
window.removeEventListener('click', closeMenu, false);
|
|
7683
|
+
window.removeEventListener('contextmenu', closeMenu, true);
|
|
7684
|
+
};
|
|
7685
|
+
}, []);
|
|
7686
|
+
useLayoutEffect(() => {
|
|
7687
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
7688
|
+
return () => {
|
|
7689
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
7690
|
+
};
|
|
7691
|
+
}, [curSelect, dataMap]);
|
|
7692
|
+
const handleKeyDown = e => {
|
|
7693
|
+
if (e.altKey && e.key === '3') {
|
|
7694
|
+
setMenutype('column');
|
|
7695
|
+
}
|
|
7696
|
+
if (e.altKey && e.key === '2') {
|
|
7697
|
+
setMenutype('table');
|
|
7698
|
+
}
|
|
7699
|
+
if (e.altKey && e.key === '1') {
|
|
7700
|
+
setMenutype('tile');
|
|
7701
|
+
}
|
|
7702
|
+
if (e.altKey && e.key === 'c') {
|
|
7703
|
+
if (curSelect && dataMap?.[curSelect]) {
|
|
7704
|
+
onCopy?.(dataMap?.[curSelect]);
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
if (e.altKey && e.key === 'x') {
|
|
7708
|
+
if (curSelect && dataMap?.[curSelect]) {
|
|
7709
|
+
onCopy?.(dataMap?.[curSelect]);
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
if (e.altKey && e.key === 'v') {
|
|
7713
|
+
if (curSelect && dataMap?.[curSelect]) {
|
|
7714
|
+
onCopy?.(dataMap?.[curSelect]);
|
|
7715
|
+
}
|
|
7716
|
+
}
|
|
7717
|
+
};
|
|
7718
|
+
const closeMenu = () => {
|
|
7719
|
+
boxMenu.current?.remove?.();
|
|
7720
|
+
boxMenu.current = null;
|
|
7721
|
+
menu.current = null;
|
|
7722
|
+
};
|
|
7672
7723
|
const Icons = (v, className, style) => {
|
|
7673
7724
|
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, {})]]);
|
|
7674
7725
|
if (v?.label) {
|
|
@@ -7732,6 +7783,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7732
7783
|
let map = addLevel(curlist, {});
|
|
7733
7784
|
setDataMap(map);
|
|
7734
7785
|
}, [curlist]);
|
|
7786
|
+
/* ************ 加载更新数据 **************** */
|
|
7735
7787
|
async function loadData(key, param) {
|
|
7736
7788
|
setLoading(ApiStatusEnum.LOADING);
|
|
7737
7789
|
let data = (await props.loadData?.(key, param)) || {};
|
|
@@ -7755,6 +7807,51 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7755
7807
|
let data = await props.loadData?.(key);
|
|
7756
7808
|
return data?.fileList || [];
|
|
7757
7809
|
}
|
|
7810
|
+
const reloadNode = key => {
|
|
7811
|
+
setNavLoadKey(nav_loadKey.filter(v => v !== key));
|
|
7812
|
+
const addData = (data, key) => {
|
|
7813
|
+
let arr = data;
|
|
7814
|
+
let i = 0;
|
|
7815
|
+
while (i < arr.length) {
|
|
7816
|
+
let item = arr[i];
|
|
7817
|
+
if (item.key == key) {
|
|
7818
|
+
item.api = true;
|
|
7819
|
+
item.isLeaf = false;
|
|
7820
|
+
item.children = [];
|
|
7821
|
+
}
|
|
7822
|
+
if (Array.isArray(item.children)) {
|
|
7823
|
+
item.children = addData(item.children, key);
|
|
7824
|
+
}
|
|
7825
|
+
i++;
|
|
7826
|
+
}
|
|
7827
|
+
return arr || [];
|
|
7828
|
+
};
|
|
7829
|
+
let arr = addData(data || [], key);
|
|
7830
|
+
onChange?.(arr);
|
|
7831
|
+
};
|
|
7832
|
+
function updata(id, param) {
|
|
7833
|
+
const fixData = (data, id, param) => {
|
|
7834
|
+
let arr = data;
|
|
7835
|
+
let i = 0;
|
|
7836
|
+
while (i < arr.length) {
|
|
7837
|
+
let item = arr[i];
|
|
7838
|
+
if (item.key == id) {
|
|
7839
|
+
let _arr = Object.keys(param);
|
|
7840
|
+
_arr.map(v => {
|
|
7841
|
+
item[v] = param[v];
|
|
7842
|
+
});
|
|
7843
|
+
}
|
|
7844
|
+
if (Array.isArray(item.children)) {
|
|
7845
|
+
item.children = fixData(item.children, id, param);
|
|
7846
|
+
}
|
|
7847
|
+
i++;
|
|
7848
|
+
}
|
|
7849
|
+
return arr || [];
|
|
7850
|
+
};
|
|
7851
|
+
let arr = fixData(data || [], id, param);
|
|
7852
|
+
onChange?.(arr);
|
|
7853
|
+
}
|
|
7854
|
+
/* ************ 功能方法 **************** */
|
|
7758
7855
|
//创建和重名
|
|
7759
7856
|
async function onRename(key, value, info, type) {
|
|
7760
7857
|
if (info.create_file) {
|
|
@@ -7789,7 +7886,13 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7789
7886
|
input?.click();
|
|
7790
7887
|
input.onchange = async e => {
|
|
7791
7888
|
const files = Array.from(e.target.files);
|
|
7792
|
-
|
|
7889
|
+
let _file = files.map(v => {
|
|
7890
|
+
return {
|
|
7891
|
+
file: v,
|
|
7892
|
+
path: curInfo.key
|
|
7893
|
+
};
|
|
7894
|
+
});
|
|
7895
|
+
await props?.onUpload?.(_file, curInfo);
|
|
7793
7896
|
loadData?.(curInfo?.key);
|
|
7794
7897
|
};
|
|
7795
7898
|
}
|
|
@@ -7857,50 +7960,6 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7857
7960
|
});
|
|
7858
7961
|
setCurList(list);
|
|
7859
7962
|
}
|
|
7860
|
-
function updata(id, param) {
|
|
7861
|
-
const fixData = (data, id, param) => {
|
|
7862
|
-
let arr = data;
|
|
7863
|
-
let i = 0;
|
|
7864
|
-
while (i < arr.length) {
|
|
7865
|
-
let item = arr[i];
|
|
7866
|
-
if (item.key == id) {
|
|
7867
|
-
let _arr = Object.keys(param);
|
|
7868
|
-
_arr.map(v => {
|
|
7869
|
-
item[v] = param[v];
|
|
7870
|
-
});
|
|
7871
|
-
}
|
|
7872
|
-
if (Array.isArray(item.children)) {
|
|
7873
|
-
item.children = fixData(item.children, id, param);
|
|
7874
|
-
}
|
|
7875
|
-
i++;
|
|
7876
|
-
}
|
|
7877
|
-
return arr || [];
|
|
7878
|
-
};
|
|
7879
|
-
let arr = fixData(data || [], id, param);
|
|
7880
|
-
onChange?.(arr);
|
|
7881
|
-
}
|
|
7882
|
-
const reloadNode = key => {
|
|
7883
|
-
setNavLoadKey(nav_loadKey.filter(v => v !== key));
|
|
7884
|
-
const addData = (data, key) => {
|
|
7885
|
-
let arr = data;
|
|
7886
|
-
let i = 0;
|
|
7887
|
-
while (i < arr.length) {
|
|
7888
|
-
let item = arr[i];
|
|
7889
|
-
if (item.key == key) {
|
|
7890
|
-
item.api = true;
|
|
7891
|
-
item.isLeaf = false;
|
|
7892
|
-
item.children = [];
|
|
7893
|
-
}
|
|
7894
|
-
if (Array.isArray(item.children)) {
|
|
7895
|
-
item.children = addData(item.children, key);
|
|
7896
|
-
}
|
|
7897
|
-
i++;
|
|
7898
|
-
}
|
|
7899
|
-
return arr || [];
|
|
7900
|
-
};
|
|
7901
|
-
let arr = addData(data || [], key);
|
|
7902
|
-
onChange?.(arr);
|
|
7903
|
-
};
|
|
7904
7963
|
async function onMenuClick(key, param, type) {
|
|
7905
7964
|
if (key == 'remove') {
|
|
7906
7965
|
await onDelect?.(param);
|
|
@@ -7927,6 +7986,64 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7927
7986
|
}
|
|
7928
7987
|
_onMenuClick?.(key, param);
|
|
7929
7988
|
}
|
|
7989
|
+
function openMenu(props, param) {
|
|
7990
|
+
if (param?.key) ;
|
|
7991
|
+
closeMenu();
|
|
7992
|
+
let {
|
|
7993
|
+
x = 0,
|
|
7994
|
+
y = 0,
|
|
7995
|
+
className = '',
|
|
7996
|
+
placement,
|
|
7997
|
+
content
|
|
7998
|
+
} = props;
|
|
7999
|
+
let _menu = null;
|
|
8000
|
+
_menu = document.createElement('div');
|
|
8001
|
+
menu.current = createRoot(_menu);
|
|
8002
|
+
if (boxMenu.current) {
|
|
8003
|
+
boxMenu.current?.appendChild(menu);
|
|
8004
|
+
} else {
|
|
8005
|
+
let body = document.querySelector('body');
|
|
8006
|
+
let _body = document.createElement('div');
|
|
8007
|
+
_body.className = `_explorer-menu ${className}`;
|
|
8008
|
+
_body.style.cssText = `
|
|
8009
|
+
position:absolute;
|
|
8010
|
+
top: 0px;
|
|
8011
|
+
left: 0px;
|
|
8012
|
+
widht:0px;
|
|
8013
|
+
height: 0px;
|
|
8014
|
+
z-index:110;
|
|
8015
|
+
`;
|
|
8016
|
+
boxMenu.current = _body;
|
|
8017
|
+
_body?.appendChild(_menu);
|
|
8018
|
+
body?.appendChild(_body);
|
|
8019
|
+
}
|
|
8020
|
+
let _box = box.current.getBoundingClientRect();
|
|
8021
|
+
_menu.style.cssText = `
|
|
8022
|
+
position:absolute;
|
|
8023
|
+
top: -100px;
|
|
8024
|
+
left: -100px;
|
|
8025
|
+
background: #fff;
|
|
8026
|
+
opacity: 0;
|
|
8027
|
+
`;
|
|
8028
|
+
_box.bottom;
|
|
8029
|
+
_box.top;
|
|
8030
|
+
menu.current.render(content);
|
|
8031
|
+
setTimeout(() => {
|
|
8032
|
+
let cur = _menu.getBoundingClientRect();
|
|
8033
|
+
if (cur.height + y > _box.bottom) {
|
|
8034
|
+
y = y - cur.height - 10;
|
|
8035
|
+
}
|
|
8036
|
+
if (cur.width + x > _box.right) {
|
|
8037
|
+
x = x - cur.width - 10;
|
|
8038
|
+
}
|
|
8039
|
+
_menu.style.cssText = `
|
|
8040
|
+
position:absolute;
|
|
8041
|
+
top: ${y}px;
|
|
8042
|
+
left:${x}px;
|
|
8043
|
+
background: #fff;
|
|
8044
|
+
`;
|
|
8045
|
+
}, 100);
|
|
8046
|
+
}
|
|
7930
8047
|
return jsx(ExampleContext.Provider, {
|
|
7931
8048
|
value: {
|
|
7932
8049
|
//data
|
|
@@ -7955,6 +8072,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7955
8072
|
uploadFile,
|
|
7956
8073
|
createFolder,
|
|
7957
8074
|
reloadNode,
|
|
8075
|
+
openMenu,
|
|
8076
|
+
closeMenu,
|
|
7958
8077
|
//set
|
|
7959
8078
|
setLog,
|
|
7960
8079
|
setLogIndex,
|
|
@@ -7973,6 +8092,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7973
8092
|
},
|
|
7974
8093
|
children: jsx("div", {
|
|
7975
8094
|
className: 'explorer-container',
|
|
8095
|
+
ref: box,
|
|
7976
8096
|
children: jsx(Layout, {
|
|
7977
8097
|
...props,
|
|
7978
8098
|
loadData: loadData,
|