seeder-resources-view 1.0.13 → 1.2.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.js CHANGED
@@ -17320,7 +17320,7 @@ const MediaGridItem = /*#__PURE__*/react.memo(_ref => {
17320
17320
  trigger: ['contextMenu'],
17321
17321
  disabled: !onContextMenu,
17322
17322
  children: /*#__PURE__*/jsxRuntime.jsxs(antd.List.Item, {
17323
- className: "".concat(showCheckbox ? 'media-grid-item' : ''),
17323
+ className: "media-grid-item ".concat(showCheckbox ? 'media-grid-item--selectable' : ''),
17324
17324
  title: item.name,
17325
17325
  onClick: handleItemClick,
17326
17326
  children: [showCheckbox && /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -17767,41 +17767,59 @@ const TreeTitleNode = _ref2 => {
17767
17767
  var TreeTitle$1 = /*#__PURE__*/react.memo(TreeTitle);
17768
17768
 
17769
17769
  const buildDirectoryTree = function (data) {
17770
- let basePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
17771
- let parentRoute = arguments.length > 2 ? arguments[2] : undefined;
17770
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17771
+ const {
17772
+ withRoot = true
17773
+ } = options; // 默认包含 root 节点
17774
+
17772
17775
  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
17776
 
17798
- // 递归处理子目录
17799
- if (Array.isArray(item.contents) && item.contents.length > 0) {
17800
- treeNode.children = buildDirectoryTree(item.contents.filter(content => content.type !== 'file'), key, currentPath);
17801
- }
17802
- acc.push(treeNode);
17803
- return acc;
17804
- }, []);
17777
+ // 如果需要 root 节点,包装一层
17778
+ const processedData = withRoot ? [{
17779
+ name: 'root',
17780
+ type: 'directory',
17781
+ contents: data
17782
+ }] : data;
17783
+
17784
+ // 递归构建树
17785
+ const build = function (nodes) {
17786
+ let basePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
17787
+ let parentRoute = arguments.length > 2 ? arguments[2] : undefined;
17788
+ return nodes.reduce((acc, item, index) => {
17789
+ var _item$sd_index, _item$path;
17790
+ // 跳过文件类型,只处理目录
17791
+ if (item.type === 'file') return acc;
17792
+ const title = parentRoute ? item.name : (_item$sd_index = item.sd_index) !== null && _item$sd_index !== void 0 ? _item$sd_index : item.name;
17793
+ const key = "".concat(basePath, "-").concat(index);
17794
+ const currentPath = parentRoute ? "".concat(parentRoute, "/").concat(title) : (_item$path = item.path) !== null && _item$path !== void 0 ? _item$path : item.name;
17795
+ const treeNode = {
17796
+ title,
17797
+ // 文件/文件夹名称
17798
+ key,
17799
+ icon: _ref => {
17800
+ let {
17801
+ expanded
17802
+ } = _ref;
17803
+ return expanded ? /*#__PURE__*/jsxRuntime.jsx(icons.FolderOpenOutlined, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.FolderOutlined, {});
17804
+ },
17805
+ children: [],
17806
+ isLeaf: false,
17807
+ // isRoot: Boolean(item.sd_index),
17808
+ isRoot: !parentRoute,
17809
+ path: currentPath,
17810
+ contents: (item.contents || []).filter(content => content.type === 'file'),
17811
+ rawData: item // 保留原始数据
17812
+ };
17813
+
17814
+ // 递归处理子目录
17815
+ if (Array.isArray(item.contents) && item.contents.length > 0) {
17816
+ treeNode.children = build(item.contents.filter(content => content.type !== 'file'), key, currentPath);
17817
+ }
17818
+ acc.push(treeNode);
17819
+ return acc;
17820
+ }, []);
17821
+ };
17822
+ return build(processedData);
17805
17823
  };
17806
17824
 
17807
17825
  /**
@@ -17854,6 +17872,8 @@ const useDirectoryTree = _ref => {
17854
17872
  createFolder,
17855
17873
  removeFolderFile,
17856
17874
  renameFolderFile,
17875
+ batchOperations = true,
17876
+ withRootNode = true,
17857
17877
  height = 828,
17858
17878
  theme = {
17859
17879
  components: {
@@ -17884,13 +17904,14 @@ const useDirectoryTree = _ref => {
17884
17904
 
17885
17905
  // 路径处理工具
17886
17906
  const pathUtils = {
17907
+ replaceRoot: path => path.replace(/^root\//, ''),
17887
17908
  getNewPath: (node, newTitle) => {
17888
17909
  const arr = node.path.split('/');
17889
17910
  arr[arr.length - 1] = newTitle;
17890
17911
  return arr.join('/');
17891
17912
  },
17892
17913
  isSamePath: (path1, path2) => {
17893
- return path1 === path2;
17914
+ return pathUtils.replaceRoot(path1) === pathUtils.replaceRoot(path2);
17894
17915
  }
17895
17916
  };
17896
17917
 
@@ -17914,7 +17935,9 @@ const useDirectoryTree = _ref => {
17914
17935
  setOriginTreeData(data.directoryTree);
17915
17936
 
17916
17937
  // 递归生成treenodes
17917
- const treeNodes = buildDirectoryTree(data.directoryTree);
17938
+ const treeNodes = buildDirectoryTree(data.directoryTree, {
17939
+ withRoot: withRootNode
17940
+ });
17918
17941
  if (!treeNodes.length) {
17919
17942
  return null;
17920
17943
  }
@@ -17932,7 +17955,7 @@ const useDirectoryTree = _ref => {
17932
17955
  } catch (error) {
17933
17956
  handleError(error, 'GET FOLDER DATA');
17934
17957
  }
17935
- }, []);
17958
+ }, [withRootNode]);
17936
17959
 
17937
17960
  // 初始化数据
17938
17961
  react.useEffect(() => {
@@ -17944,7 +17967,7 @@ const useDirectoryTree = _ref => {
17944
17967
  if (!(newTitle !== null && newTitle !== void 0 && newTitle.trim())) return false;
17945
17968
  try {
17946
17969
  var _parentNode$;
17947
- const path = "".concat(node.path, "/").concat(newTitle);
17970
+ const path = pathUtils.replaceRoot("".concat(node.path, "/").concat(newTitle));
17948
17971
  await createFolder({
17949
17972
  path
17950
17973
  });
@@ -17971,10 +17994,12 @@ const useDirectoryTree = _ref => {
17971
17994
  const handleRemove = react.useCallback(async node => {
17972
17995
  if (!node.path) return;
17973
17996
  try {
17974
- await removeFolderFile({
17997
+ batchOperations ? await removeFolderFile({
17975
17998
  paths: [{
17976
- path: node.path
17999
+ path: pathUtils.replaceRoot(node.path)
17977
18000
  }]
18001
+ }) : await removeFolderFile({
18002
+ path: pathUtils.replaceRoot(node.path)
17978
18003
  });
17979
18004
  // 如果删除的是当前选中节点,则重新初始化
17980
18005
  const shouldReinitialize = treeState.selectedKeys[0] === node.key;
@@ -17990,8 +18015,8 @@ const useDirectoryTree = _ref => {
17990
18015
  if (pathUtils.isSamePath(node.path, newPath)) return false;
17991
18016
  try {
17992
18017
  await renameFolderFile({
17993
- old_path: node.path,
17994
- new_path: newPath
18018
+ old_path: pathUtils.replaceRoot(node.path),
18019
+ new_path: pathUtils.replaceRoot(newPath)
17995
18020
  });
17996
18021
  await fetchFolderData();
17997
18022
  } catch (error) {
@@ -18135,6 +18160,7 @@ const ResourcesView = _ref => {
18135
18160
  style = {},
18136
18161
  renderTreeHeader,
18137
18162
  renderGridHeader,
18163
+ withRootNode = true,
18138
18164
  acceptFileTypes = "video/*,.mxf,application/mxf,video/mxf",
18139
18165
  uploadTimeout = 60 * 60 * 1000,
18140
18166
  searchPlaceholder = "Search ..."
@@ -18169,7 +18195,9 @@ const ResourcesView = _ref => {
18169
18195
  getFolderData: mergedApiConfig.getFolderData,
18170
18196
  createFolder: mergedApiConfig.createFolder,
18171
18197
  removeFolderFile: mergedApiConfig.removeFolderFile,
18172
- renameFolderFile: mergedApiConfig.renameFolderFile
18198
+ renameFolderFile: mergedApiConfig.renameFolderFile,
18199
+ batchOperations: mergedFeatures.batchOperations,
18200
+ withRootNode
18173
18201
  });
18174
18202
  const [showProgress, setShowProgress] = react.useState(false);
18175
18203
  const [percent, setPercent] = react.useState(0);