@gingkoo/pandora-explorer 0.0.1-alpha.51 → 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 +486 -378
- 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;
|
|
@@ -5999,6 +5990,10 @@ const ExplorerMenu = props => {
|
|
|
5999
5990
|
function onMenuClick(key, data) {
|
|
6000
5991
|
_onMenuClick(key, data, 'menu');
|
|
6001
5992
|
}
|
|
5993
|
+
const openMenu = (props, param) => {
|
|
5994
|
+
setSelect(param.key);
|
|
5995
|
+
store.openMenu(props);
|
|
5996
|
+
};
|
|
6002
5997
|
return jsx("div", {
|
|
6003
5998
|
className: 'frame-left',
|
|
6004
5999
|
onContextMenu: e => {
|
|
@@ -6020,6 +6015,8 @@ const ExplorerMenu = props => {
|
|
|
6020
6015
|
loadMenu: loadMenu,
|
|
6021
6016
|
onChange: onChange,
|
|
6022
6017
|
onRename: onRename,
|
|
6018
|
+
openMenu: openMenu,
|
|
6019
|
+
closeMenu: store.closeMenu,
|
|
6023
6020
|
onSelect: v => {
|
|
6024
6021
|
if (v.key === store.curInfo?.key) return;
|
|
6025
6022
|
store.setPathDisplay(v?.pathDisplay);
|
|
@@ -6176,7 +6173,7 @@ function Tile(props) {
|
|
|
6176
6173
|
menudata = getMenu('');
|
|
6177
6174
|
}
|
|
6178
6175
|
let isname = rekey == v.key || v?.create_file;
|
|
6179
|
-
return
|
|
6176
|
+
return jsxs("div", {
|
|
6180
6177
|
"data-id": v.key,
|
|
6181
6178
|
"data-type": v.type,
|
|
6182
6179
|
className: cx$1('file', {
|
|
@@ -6199,79 +6196,68 @@ function Tile(props) {
|
|
|
6199
6196
|
onDoubleClick: () => {
|
|
6200
6197
|
onDblclick?.(v.key, v);
|
|
6201
6198
|
},
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
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, {
|
|
6211
6210
|
menu: menudata,
|
|
6212
6211
|
loadMenu: loadMenu,
|
|
6213
6212
|
onChange: key => {
|
|
6214
6213
|
if (key == 'rename') {
|
|
6215
6214
|
setRekey(v.key);
|
|
6216
|
-
onClone();
|
|
6217
6215
|
return;
|
|
6218
6216
|
}
|
|
6219
6217
|
onMenuClick?.(key, v);
|
|
6220
|
-
|
|
6218
|
+
props.closeMenu();
|
|
6221
6219
|
}
|
|
6222
|
-
})
|
|
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'
|
|
6223
6228
|
},
|
|
6224
|
-
children:
|
|
6225
|
-
|
|
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,
|
|
6226
6237
|
style: {
|
|
6227
6238
|
width: w + 'px',
|
|
6228
|
-
height: w
|
|
6229
|
-
}
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
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);
|
|
6241
6257
|
}
|
|
6242
|
-
})
|
|
6243
|
-
}), jsx("div", {
|
|
6244
|
-
className: 'title-type-name',
|
|
6245
|
-
style: {
|
|
6246
|
-
width: w + 'px'
|
|
6247
6258
|
},
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
rows: 3,
|
|
6251
|
-
defaultValue: v.title,
|
|
6252
|
-
onFocus: e => {
|
|
6253
|
-
let i = v.title.lastIndexOf('.');
|
|
6254
|
-
if (props?.suffix == 'folder') {
|
|
6255
|
-
e.target.setSelectionRange(0, v.title.length);
|
|
6256
|
-
} else if (i !== -1) {
|
|
6257
|
-
e.target.setSelectionRange(0, i);
|
|
6258
|
-
}
|
|
6259
|
-
},
|
|
6260
|
-
onKeyDown: e => {
|
|
6261
|
-
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
6262
|
-
if (props.create_file) {
|
|
6263
|
-
onRename?.(v.key, e.target?.value, v);
|
|
6264
|
-
return;
|
|
6265
|
-
}
|
|
6266
|
-
if (e.target?.value === v.title) {
|
|
6267
|
-
setRekey(null);
|
|
6268
|
-
return;
|
|
6269
|
-
}
|
|
6270
|
-
onRename?.(v.key, e.target.value, v);
|
|
6271
|
-
setRekey(null);
|
|
6272
|
-
}
|
|
6273
|
-
},
|
|
6274
|
-
onBlur: e => {
|
|
6259
|
+
onKeyDown: e => {
|
|
6260
|
+
if (e.key === 'Enter' || e.keyCode === 13) {
|
|
6275
6261
|
if (props.create_file) {
|
|
6276
6262
|
onRename?.(v.key, e.target?.value, v);
|
|
6277
6263
|
return;
|
|
@@ -6282,16 +6268,28 @@ function Tile(props) {
|
|
|
6282
6268
|
}
|
|
6283
6269
|
onRename?.(v.key, e.target.value, v);
|
|
6284
6270
|
setRekey(null);
|
|
6285
|
-
},
|
|
6286
|
-
onMouseDown: e => {
|
|
6287
|
-
e.stopPropagation();
|
|
6288
6271
|
}
|
|
6289
|
-
}
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
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
|
+
})]
|
|
6295
6293
|
}, v.key);
|
|
6296
6294
|
})
|
|
6297
6295
|
}, index);
|
|
@@ -6431,10 +6429,11 @@ const SelectBox = props => {
|
|
|
6431
6429
|
clientX: x,
|
|
6432
6430
|
clientY: y
|
|
6433
6431
|
} = e;
|
|
6432
|
+
//动画
|
|
6434
6433
|
if (!time && cur?.current?.length && isDrag) {
|
|
6435
6434
|
cur.current?.map((v, i) => {
|
|
6436
6435
|
v.style.cssText = `
|
|
6437
|
-
position: absolute;
|
|
6436
|
+
position: absolute;
|
|
6438
6437
|
transition: 0.3s;
|
|
6439
6438
|
top:${y + i * 3}px;
|
|
6440
6439
|
left:${x + i * 3}px;
|
|
@@ -6445,23 +6444,22 @@ const SelectBox = props => {
|
|
|
6445
6444
|
cur.current = [];
|
|
6446
6445
|
}, 200);
|
|
6447
6446
|
}
|
|
6447
|
+
//移动
|
|
6448
6448
|
if (isDrag && selects.length) {
|
|
6449
6449
|
if (target.current) {
|
|
6450
6450
|
target.current.style.cssText = `
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6451
|
+
position: absolute;
|
|
6452
|
+
top:${y}px;
|
|
6453
|
+
left:${x}px;
|
|
6454
|
+
`;
|
|
6455
6455
|
}
|
|
6456
6456
|
} else {
|
|
6457
|
+
//选框
|
|
6457
6458
|
createBox(e);
|
|
6458
6459
|
}
|
|
6459
6460
|
}
|
|
6460
6461
|
//鼠标松开
|
|
6461
6462
|
function handleBodyMouseup() {
|
|
6462
|
-
if (isDclick.current) {
|
|
6463
|
-
clearTimeout(isDclick.current);
|
|
6464
|
-
}
|
|
6465
6463
|
if (target.current) {
|
|
6466
6464
|
empty();
|
|
6467
6465
|
} else {
|
|
@@ -6486,7 +6484,7 @@ const SelectBox = props => {
|
|
|
6486
6484
|
}, 300);
|
|
6487
6485
|
}
|
|
6488
6486
|
}
|
|
6489
|
-
|
|
6487
|
+
//拖动文件
|
|
6490
6488
|
const handleDragOver = e => {
|
|
6491
6489
|
e.preventDefault();
|
|
6492
6490
|
const {
|
|
@@ -6848,109 +6846,104 @@ const SelectBox = props => {
|
|
|
6848
6846
|
})
|
|
6849
6847
|
});
|
|
6850
6848
|
}
|
|
6851
|
-
return
|
|
6852
|
-
|
|
6853
|
-
|
|
6849
|
+
return jsxs("div", {
|
|
6850
|
+
ref: ref,
|
|
6851
|
+
className: cx$1(`file-select-box ${className}`),
|
|
6852
|
+
onDragLeave: e => {
|
|
6853
|
+
e.preventDefault();
|
|
6854
6854
|
},
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
store.createFolder();
|
|
6882
|
-
onClone();
|
|
6883
|
-
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);
|
|
6884
6881
|
}
|
|
6885
|
-
|
|
6886
|
-
|
|
6882
|
+
} else {
|
|
6883
|
+
setSelect(type);
|
|
6884
|
+
onChange(type);
|
|
6887
6885
|
}
|
|
6886
|
+
}
|
|
6887
|
+
isDclick.current = null;
|
|
6888
|
+
if (type) return;
|
|
6889
|
+
if (selects.length) {
|
|
6890
|
+
if (checkMode !== 'check') {
|
|
6891
|
+
setSelect([]);
|
|
6892
|
+
onChange([]);
|
|
6893
|
+
empty();
|
|
6894
|
+
}
|
|
6895
|
+
}
|
|
6896
|
+
//创建选取
|
|
6897
|
+
clickRef.current = false;
|
|
6898
|
+
isSelectBoxes && setStageClickInfo({
|
|
6899
|
+
show: true,
|
|
6900
|
+
x: e.clientX,
|
|
6901
|
+
y: e.clientY
|
|
6888
6902
|
});
|
|
6889
6903
|
},
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
if (
|
|
6909
|
-
|
|
6910
|
-
let arr = checks.filter(v => v !== type?.[0]);
|
|
6911
|
-
setSelect(arr);
|
|
6912
|
-
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);
|
|
6913
6924
|
}
|
|
6914
|
-
|
|
6915
|
-
isDrag && createVDom(e);
|
|
6925
|
+
store.closeMenu();
|
|
6916
6926
|
return;
|
|
6917
6927
|
}
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
let arr = [...selects, ...type];
|
|
6923
|
-
setSelect(arr);
|
|
6924
|
-
onChange(arr);
|
|
6925
|
-
}
|
|
6926
|
-
} else {
|
|
6927
|
-
setSelect(type);
|
|
6928
|
-
onChange(type);
|
|
6929
|
-
}
|
|
6928
|
+
if (key == 'file-upload') {
|
|
6929
|
+
store.uploadFile();
|
|
6930
|
+
store.closeMenu();
|
|
6931
|
+
return;
|
|
6930
6932
|
}
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
if (checkMode !== 'check') {
|
|
6936
|
-
setSelect([]);
|
|
6937
|
-
onChange([]);
|
|
6938
|
-
empty();
|
|
6933
|
+
if (key == 'create') {
|
|
6934
|
+
store.createFolder();
|
|
6935
|
+
store.closeMenu();
|
|
6936
|
+
return;
|
|
6939
6937
|
}
|
|
6938
|
+
onMenuClick?.(key, store.curInfo);
|
|
6939
|
+
store.closeMenu();
|
|
6940
6940
|
}
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
});
|
|
6948
|
-
}
|
|
6949
|
-
},
|
|
6950
|
-
children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
|
|
6951
|
-
ref: selectionRef
|
|
6952
|
-
}), document.body)]
|
|
6953
|
-
})
|
|
6941
|
+
})
|
|
6942
|
+
}, store?.curInfo);
|
|
6943
|
+
},
|
|
6944
|
+
children: [props.children, /*#__PURE__*/ReactDOM.createPortal(jsx("div", {
|
|
6945
|
+
ref: selectionRef
|
|
6946
|
+
}), document.body)]
|
|
6954
6947
|
});
|
|
6955
6948
|
};
|
|
6956
6949
|
|
|
@@ -7233,7 +7226,7 @@ const Layout$1 = props => {
|
|
|
7233
7226
|
const [expandkey, setExpandkey] = useState([]);
|
|
7234
7227
|
useEffect(() => {
|
|
7235
7228
|
setExpandkey([]);
|
|
7236
|
-
}, [store
|
|
7229
|
+
}, [store?.curInfo?.key]);
|
|
7237
7230
|
function Loading() {
|
|
7238
7231
|
return jsx("div", {
|
|
7239
7232
|
className: 'explorer-columns-loading',
|
|
@@ -7342,6 +7335,8 @@ const Layout$1 = props => {
|
|
|
7342
7335
|
showLine: false,
|
|
7343
7336
|
isOpenMenu: isOpenMenu,
|
|
7344
7337
|
icon: store.getIcons,
|
|
7338
|
+
openMenu: store.openMenu,
|
|
7339
|
+
closeMenu: store.closeMenu,
|
|
7345
7340
|
isload: true,
|
|
7346
7341
|
ischeck: truncate,
|
|
7347
7342
|
onChecks: arr => {
|
|
@@ -7382,6 +7377,8 @@ const Layout$1 = props => {
|
|
|
7382
7377
|
data: store.curlist,
|
|
7383
7378
|
icons: store.getIcons,
|
|
7384
7379
|
checks: checks,
|
|
7380
|
+
openMenu: store.openMenu,
|
|
7381
|
+
closeMenu: store.closeMenu,
|
|
7385
7382
|
onSelect: (key, v) => {
|
|
7386
7383
|
store.setCurSelect(v.key);
|
|
7387
7384
|
},
|
|
@@ -7650,6 +7647,9 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7650
7647
|
const [menutype, setMenutype] = useState('tile');
|
|
7651
7648
|
const [infoshow, setInfoShow] = useState(false);
|
|
7652
7649
|
const [loading, setLoading] = useState(ApiStatusEnum.READY);
|
|
7650
|
+
const box = useRef(null);
|
|
7651
|
+
const boxMenu = useRef(null);
|
|
7652
|
+
const menu = useRef(null);
|
|
7653
7653
|
useImperativeHandle(ref, () => ({
|
|
7654
7654
|
removeLog: () => {
|
|
7655
7655
|
//清空日志
|
|
@@ -7674,6 +7674,52 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7674
7674
|
}
|
|
7675
7675
|
}
|
|
7676
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
|
+
};
|
|
7677
7723
|
const Icons = (v, className, style) => {
|
|
7678
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, {})]]);
|
|
7679
7725
|
if (v?.label) {
|
|
@@ -7737,6 +7783,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7737
7783
|
let map = addLevel(curlist, {});
|
|
7738
7784
|
setDataMap(map);
|
|
7739
7785
|
}, [curlist]);
|
|
7786
|
+
/* ************ 加载更新数据 **************** */
|
|
7740
7787
|
async function loadData(key, param) {
|
|
7741
7788
|
setLoading(ApiStatusEnum.LOADING);
|
|
7742
7789
|
let data = (await props.loadData?.(key, param)) || {};
|
|
@@ -7760,6 +7807,51 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7760
7807
|
let data = await props.loadData?.(key);
|
|
7761
7808
|
return data?.fileList || [];
|
|
7762
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
|
+
/* ************ 功能方法 **************** */
|
|
7763
7855
|
//创建和重名
|
|
7764
7856
|
async function onRename(key, value, info, type) {
|
|
7765
7857
|
if (info.create_file) {
|
|
@@ -7868,50 +7960,6 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7868
7960
|
});
|
|
7869
7961
|
setCurList(list);
|
|
7870
7962
|
}
|
|
7871
|
-
function updata(id, param) {
|
|
7872
|
-
const fixData = (data, id, param) => {
|
|
7873
|
-
let arr = data;
|
|
7874
|
-
let i = 0;
|
|
7875
|
-
while (i < arr.length) {
|
|
7876
|
-
let item = arr[i];
|
|
7877
|
-
if (item.key == id) {
|
|
7878
|
-
let _arr = Object.keys(param);
|
|
7879
|
-
_arr.map(v => {
|
|
7880
|
-
item[v] = param[v];
|
|
7881
|
-
});
|
|
7882
|
-
}
|
|
7883
|
-
if (Array.isArray(item.children)) {
|
|
7884
|
-
item.children = fixData(item.children, id, param);
|
|
7885
|
-
}
|
|
7886
|
-
i++;
|
|
7887
|
-
}
|
|
7888
|
-
return arr || [];
|
|
7889
|
-
};
|
|
7890
|
-
let arr = fixData(data || [], id, param);
|
|
7891
|
-
onChange?.(arr);
|
|
7892
|
-
}
|
|
7893
|
-
const reloadNode = key => {
|
|
7894
|
-
setNavLoadKey(nav_loadKey.filter(v => v !== key));
|
|
7895
|
-
const addData = (data, key) => {
|
|
7896
|
-
let arr = data;
|
|
7897
|
-
let i = 0;
|
|
7898
|
-
while (i < arr.length) {
|
|
7899
|
-
let item = arr[i];
|
|
7900
|
-
if (item.key == key) {
|
|
7901
|
-
item.api = true;
|
|
7902
|
-
item.isLeaf = false;
|
|
7903
|
-
item.children = [];
|
|
7904
|
-
}
|
|
7905
|
-
if (Array.isArray(item.children)) {
|
|
7906
|
-
item.children = addData(item.children, key);
|
|
7907
|
-
}
|
|
7908
|
-
i++;
|
|
7909
|
-
}
|
|
7910
|
-
return arr || [];
|
|
7911
|
-
};
|
|
7912
|
-
let arr = addData(data || [], key);
|
|
7913
|
-
onChange?.(arr);
|
|
7914
|
-
};
|
|
7915
7963
|
async function onMenuClick(key, param, type) {
|
|
7916
7964
|
if (key == 'remove') {
|
|
7917
7965
|
await onDelect?.(param);
|
|
@@ -7937,7 +7985,64 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7937
7985
|
return;
|
|
7938
7986
|
}
|
|
7939
7987
|
_onMenuClick?.(key, param);
|
|
7940
|
-
|
|
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);
|
|
7941
8046
|
}
|
|
7942
8047
|
return jsx(ExampleContext.Provider, {
|
|
7943
8048
|
value: {
|
|
@@ -7967,6 +8072,8 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7967
8072
|
uploadFile,
|
|
7968
8073
|
createFolder,
|
|
7969
8074
|
reloadNode,
|
|
8075
|
+
openMenu,
|
|
8076
|
+
closeMenu,
|
|
7970
8077
|
//set
|
|
7971
8078
|
setLog,
|
|
7972
8079
|
setLogIndex,
|
|
@@ -7985,6 +8092,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7985
8092
|
},
|
|
7986
8093
|
children: jsx("div", {
|
|
7987
8094
|
className: 'explorer-container',
|
|
8095
|
+
ref: box,
|
|
7988
8096
|
children: jsx(Layout, {
|
|
7989
8097
|
...props,
|
|
7990
8098
|
loadData: loadData,
|