seeder-resources-view 1.0.14 → 1.3.0
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/dist/index.esm.js +89 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +89 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17666,7 +17666,8 @@ const TreeTitleNode = _ref2 => {
|
|
|
17666
17666
|
nodeData,
|
|
17667
17667
|
handleSave,
|
|
17668
17668
|
handleDel,
|
|
17669
|
-
handleAdd
|
|
17669
|
+
handleAdd,
|
|
17670
|
+
isEditable = true
|
|
17670
17671
|
} = _ref2;
|
|
17671
17672
|
const [editing, setEditing] = react.useState(false);
|
|
17672
17673
|
const inputRef = react.useRef(null);
|
|
@@ -17761,47 +17762,71 @@ const TreeTitleNode = _ref2 => {
|
|
|
17761
17762
|
}, [editing, nodeData.title, save, title, renderIconNode]);
|
|
17762
17763
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
17763
17764
|
className: "tree-title",
|
|
17764
|
-
children: renderChildNode()
|
|
17765
|
+
children: isEditable ? renderChildNode() : /*#__PURE__*/jsxRuntime.jsx(antd.Typography.Text, {
|
|
17766
|
+
ellipsis: true,
|
|
17767
|
+
style: {
|
|
17768
|
+
width: "100%%"
|
|
17769
|
+
},
|
|
17770
|
+
children: title
|
|
17771
|
+
})
|
|
17765
17772
|
});
|
|
17766
17773
|
};
|
|
17767
17774
|
var TreeTitle$1 = /*#__PURE__*/react.memo(TreeTitle);
|
|
17768
17775
|
|
|
17769
17776
|
const buildDirectoryTree = function (data) {
|
|
17770
|
-
let
|
|
17771
|
-
|
|
17777
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17778
|
+
const {
|
|
17779
|
+
withRoot = true
|
|
17780
|
+
} = options; // 默认包含 root 节点
|
|
17781
|
+
|
|
17772
17782
|
if (!Array.isArray(data)) return [];
|
|
17773
|
-
return data.reduce((acc, item, index) => {
|
|
17774
|
-
var _item$sd_index;
|
|
17775
|
-
// 跳过文件类型,只处理目录
|
|
17776
|
-
if (item.type === 'file') return acc;
|
|
17777
|
-
const title = parentRoute ? item.name : (_item$sd_index = item.sd_index) !== null && _item$sd_index !== void 0 ? _item$sd_index : item.name;
|
|
17778
|
-
const key = "".concat(basePath, "-").concat(index);
|
|
17779
|
-
const currentPath = parentRoute ? "".concat(parentRoute, "/").concat(title) : item.path;
|
|
17780
|
-
const treeNode = {
|
|
17781
|
-
title,
|
|
17782
|
-
// 文件/文件夹名称
|
|
17783
|
-
key,
|
|
17784
|
-
icon: _ref => {
|
|
17785
|
-
let {
|
|
17786
|
-
expanded
|
|
17787
|
-
} = _ref;
|
|
17788
|
-
return expanded ? /*#__PURE__*/jsxRuntime.jsx(icons.FolderOpenOutlined, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.FolderOutlined, {});
|
|
17789
|
-
},
|
|
17790
|
-
children: [],
|
|
17791
|
-
isLeaf: false,
|
|
17792
|
-
isRoot: Boolean(item.sd_index),
|
|
17793
|
-
path: currentPath,
|
|
17794
|
-
contents: (item.contents || []).filter(content => content.type === 'file'),
|
|
17795
|
-
rawData: item // 保留原始数据
|
|
17796
|
-
};
|
|
17797
17783
|
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17784
|
+
// 如果需要 root 节点,包装一层
|
|
17785
|
+
const processedData = withRoot ? [{
|
|
17786
|
+
name: 'root',
|
|
17787
|
+
type: 'directory',
|
|
17788
|
+
contents: data
|
|
17789
|
+
}] : data;
|
|
17790
|
+
|
|
17791
|
+
// 递归构建树
|
|
17792
|
+
const build = function (nodes) {
|
|
17793
|
+
let basePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
|
|
17794
|
+
let parentRoute = arguments.length > 2 ? arguments[2] : undefined;
|
|
17795
|
+
return nodes.reduce((acc, item, index) => {
|
|
17796
|
+
var _item$sd_index, _item$path;
|
|
17797
|
+
// 跳过文件类型,只处理目录
|
|
17798
|
+
if (item.type === 'file') return acc;
|
|
17799
|
+
const title = parentRoute ? item.name : (_item$sd_index = item.sd_index) !== null && _item$sd_index !== void 0 ? _item$sd_index : item.name;
|
|
17800
|
+
const key = "".concat(basePath, "-").concat(index);
|
|
17801
|
+
const currentPath = parentRoute ? "".concat(parentRoute, "/").concat(title) : (_item$path = item.path) !== null && _item$path !== void 0 ? _item$path : item.name;
|
|
17802
|
+
const treeNode = {
|
|
17803
|
+
title,
|
|
17804
|
+
// 文件/文件夹名称
|
|
17805
|
+
key,
|
|
17806
|
+
icon: _ref => {
|
|
17807
|
+
let {
|
|
17808
|
+
expanded
|
|
17809
|
+
} = _ref;
|
|
17810
|
+
return expanded ? /*#__PURE__*/jsxRuntime.jsx(icons.FolderOpenOutlined, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.FolderOutlined, {});
|
|
17811
|
+
},
|
|
17812
|
+
children: [],
|
|
17813
|
+
isLeaf: false,
|
|
17814
|
+
// isRoot: Boolean(item.sd_index),
|
|
17815
|
+
isRoot: !parentRoute,
|
|
17816
|
+
path: currentPath,
|
|
17817
|
+
contents: (item.contents || []).filter(content => content.type === 'file'),
|
|
17818
|
+
rawData: item // 保留原始数据
|
|
17819
|
+
};
|
|
17820
|
+
|
|
17821
|
+
// 递归处理子目录
|
|
17822
|
+
if (Array.isArray(item.contents) && item.contents.length > 0) {
|
|
17823
|
+
treeNode.children = build(item.contents.filter(content => content.type !== 'file'), key, currentPath);
|
|
17824
|
+
}
|
|
17825
|
+
acc.push(treeNode);
|
|
17826
|
+
return acc;
|
|
17827
|
+
}, []);
|
|
17828
|
+
};
|
|
17829
|
+
return build(processedData);
|
|
17805
17830
|
};
|
|
17806
17831
|
|
|
17807
17832
|
/**
|
|
@@ -17854,6 +17879,10 @@ const useDirectoryTree = _ref => {
|
|
|
17854
17879
|
createFolder,
|
|
17855
17880
|
removeFolderFile,
|
|
17856
17881
|
renameFolderFile,
|
|
17882
|
+
mediaType,
|
|
17883
|
+
isEditable = true,
|
|
17884
|
+
batchOperations = true,
|
|
17885
|
+
withRootNode = true,
|
|
17857
17886
|
height = 828,
|
|
17858
17887
|
theme = {
|
|
17859
17888
|
components: {
|
|
@@ -17884,13 +17913,14 @@ const useDirectoryTree = _ref => {
|
|
|
17884
17913
|
|
|
17885
17914
|
// 路径处理工具
|
|
17886
17915
|
const pathUtils = {
|
|
17916
|
+
replaceRoot: path => path.replace(/^root\//, ''),
|
|
17887
17917
|
getNewPath: (node, newTitle) => {
|
|
17888
17918
|
const arr = node.path.split('/');
|
|
17889
17919
|
arr[arr.length - 1] = newTitle;
|
|
17890
17920
|
return arr.join('/');
|
|
17891
17921
|
},
|
|
17892
17922
|
isSamePath: (path1, path2) => {
|
|
17893
|
-
return path1 === path2;
|
|
17923
|
+
return pathUtils.replaceRoot(path1) === pathUtils.replaceRoot(path2);
|
|
17894
17924
|
}
|
|
17895
17925
|
};
|
|
17896
17926
|
|
|
@@ -17905,16 +17935,23 @@ const useDirectoryTree = _ref => {
|
|
|
17905
17935
|
const fetchFolderData = react.useCallback(async function () {
|
|
17906
17936
|
let initialization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
17907
17937
|
try {
|
|
17908
|
-
|
|
17938
|
+
// 构建请求参数
|
|
17939
|
+
const requestParams = {
|
|
17909
17940
|
folder: ""
|
|
17910
|
-
}
|
|
17941
|
+
};
|
|
17942
|
+
if (mediaType) {
|
|
17943
|
+
requestParams.media_type = mediaType;
|
|
17944
|
+
}
|
|
17945
|
+
const data = await getFolderData(requestParams);
|
|
17911
17946
|
if (!(data !== null && data !== void 0 && data.directoryTree)) {
|
|
17912
17947
|
return null;
|
|
17913
17948
|
}
|
|
17914
17949
|
setOriginTreeData(data.directoryTree);
|
|
17915
17950
|
|
|
17916
17951
|
// 递归生成treenodes
|
|
17917
|
-
const treeNodes = buildDirectoryTree(data.directoryTree
|
|
17952
|
+
const treeNodes = buildDirectoryTree(data.directoryTree, {
|
|
17953
|
+
withRoot: withRootNode
|
|
17954
|
+
});
|
|
17918
17955
|
if (!treeNodes.length) {
|
|
17919
17956
|
return null;
|
|
17920
17957
|
}
|
|
@@ -17932,7 +17969,7 @@ const useDirectoryTree = _ref => {
|
|
|
17932
17969
|
} catch (error) {
|
|
17933
17970
|
handleError(error, 'GET FOLDER DATA');
|
|
17934
17971
|
}
|
|
17935
|
-
}, []);
|
|
17972
|
+
}, [mediaType, withRootNode]);
|
|
17936
17973
|
|
|
17937
17974
|
// 初始化数据
|
|
17938
17975
|
react.useEffect(() => {
|
|
@@ -17944,7 +17981,7 @@ const useDirectoryTree = _ref => {
|
|
|
17944
17981
|
if (!(newTitle !== null && newTitle !== void 0 && newTitle.trim())) return false;
|
|
17945
17982
|
try {
|
|
17946
17983
|
var _parentNode$;
|
|
17947
|
-
const path = "".concat(node.path, "/").concat(newTitle);
|
|
17984
|
+
const path = pathUtils.replaceRoot("".concat(node.path, "/").concat(newTitle));
|
|
17948
17985
|
await createFolder({
|
|
17949
17986
|
path
|
|
17950
17987
|
});
|
|
@@ -17971,10 +18008,12 @@ const useDirectoryTree = _ref => {
|
|
|
17971
18008
|
const handleRemove = react.useCallback(async node => {
|
|
17972
18009
|
if (!node.path) return;
|
|
17973
18010
|
try {
|
|
17974
|
-
await removeFolderFile({
|
|
18011
|
+
batchOperations ? await removeFolderFile({
|
|
17975
18012
|
paths: [{
|
|
17976
|
-
path: node.path
|
|
18013
|
+
path: pathUtils.replaceRoot(node.path)
|
|
17977
18014
|
}]
|
|
18015
|
+
}) : await removeFolderFile({
|
|
18016
|
+
path: pathUtils.replaceRoot(node.path)
|
|
17978
18017
|
});
|
|
17979
18018
|
// 如果删除的是当前选中节点,则重新初始化
|
|
17980
18019
|
const shouldReinitialize = treeState.selectedKeys[0] === node.key;
|
|
@@ -17990,8 +18029,8 @@ const useDirectoryTree = _ref => {
|
|
|
17990
18029
|
if (pathUtils.isSamePath(node.path, newPath)) return false;
|
|
17991
18030
|
try {
|
|
17992
18031
|
await renameFolderFile({
|
|
17993
|
-
old_path: node.path,
|
|
17994
|
-
new_path: newPath
|
|
18032
|
+
old_path: pathUtils.replaceRoot(node.path),
|
|
18033
|
+
new_path: pathUtils.replaceRoot(newPath)
|
|
17995
18034
|
});
|
|
17996
18035
|
await fetchFolderData();
|
|
17997
18036
|
} catch (error) {
|
|
@@ -18077,6 +18116,7 @@ const useDirectoryTree = _ref => {
|
|
|
18077
18116
|
titleRender: nodeData => /*#__PURE__*/jsxRuntime.jsx(TreeTitle$1, {
|
|
18078
18117
|
title: nodeData.title,
|
|
18079
18118
|
nodeData: nodeData,
|
|
18119
|
+
isEditable: isEditable,
|
|
18080
18120
|
handleSave: handleRename,
|
|
18081
18121
|
handleDel: handleRemove,
|
|
18082
18122
|
handleAdd: handleCreate
|
|
@@ -18135,6 +18175,7 @@ const ResourcesView = _ref => {
|
|
|
18135
18175
|
style = {},
|
|
18136
18176
|
renderTreeHeader,
|
|
18137
18177
|
renderGridHeader,
|
|
18178
|
+
withRootNode = true,
|
|
18138
18179
|
acceptFileTypes = "video/*,.mxf,application/mxf,video/mxf",
|
|
18139
18180
|
uploadTimeout = 60 * 60 * 1000,
|
|
18140
18181
|
searchPlaceholder = "Search ..."
|
|
@@ -18169,7 +18210,9 @@ const ResourcesView = _ref => {
|
|
|
18169
18210
|
getFolderData: mergedApiConfig.getFolderData,
|
|
18170
18211
|
createFolder: mergedApiConfig.createFolder,
|
|
18171
18212
|
removeFolderFile: mergedApiConfig.removeFolderFile,
|
|
18172
|
-
renameFolderFile: mergedApiConfig.renameFolderFile
|
|
18213
|
+
renameFolderFile: mergedApiConfig.renameFolderFile,
|
|
18214
|
+
batchOperations: mergedFeatures.batchOperations,
|
|
18215
|
+
withRootNode
|
|
18173
18216
|
});
|
|
18174
18217
|
const [showProgress, setShowProgress] = react.useState(false);
|
|
18175
18218
|
const [percent, setPercent] = react.useState(0);
|