seeder-resources-view 1.3.8 → 1.3.9

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 CHANGED
@@ -18169,6 +18169,36 @@ const useDirectoryTree = _ref => {
18169
18169
  });
18170
18170
  }, []);
18171
18171
 
18172
+ // 刷新树数据
18173
+ const refreshTreeData = useCallback(async () => {
18174
+ try {
18175
+ const treeNodes = await fetchFolderData();
18176
+
18177
+ // 查找当前选中节点是否还在新数据中
18178
+ const currentKey = treeState.selectedKeys[0];
18179
+ let shouldUpdateContents = false;
18180
+ if (currentKey && treeNodes) {
18181
+ const foundNode = nodeUtils.findNode(treeNodes, currentKey);
18182
+ if (foundNode !== null && foundNode !== void 0 && foundNode[0]) {
18183
+ shouldUpdateContents = true;
18184
+ updateTreeState({
18185
+ contents: foundNode[0].contents || []
18186
+ });
18187
+ } else {
18188
+ // 如果当前选中节点不存在了,清除选中状态
18189
+ updateTreeState({
18190
+ selectedKeys: [],
18191
+ currentPath: '',
18192
+ contents: []
18193
+ });
18194
+ }
18195
+ }
18196
+ } catch (error) {
18197
+ handleError(error, 'REFRESH TREE DATA');
18198
+ return null;
18199
+ }
18200
+ }, [fetchFolderData, treeState.selectedKeys]);
18201
+
18172
18202
  // 上传右侧文件或删除右侧文件 成功后的回调函数
18173
18203
  const updateFileContents = useCallback(async () => {
18174
18204
  // 找到当前选中的节点,更新当前节点的 contents
@@ -18233,7 +18263,10 @@ const useDirectoryTree = _ref => {
18233
18263
  loading: treeState.loading,
18234
18264
  originTreeData,
18235
18265
  updateFileContents,
18236
- removeFile
18266
+ removeFile,
18267
+ refreshTreeData,
18268
+ // 暴露刷新方法
18269
+ fetchFolderData: refreshTreeData // 也可以保留别名
18237
18270
  };
18238
18271
  };
18239
18272
 
@@ -18281,7 +18314,8 @@ const ResourcesView = _ref => {
18281
18314
  withRootNode = true,
18282
18315
  acceptFileTypes = "video/*,.mxf,application/mxf,video/mxf",
18283
18316
  uploadTimeout = 60 * 60 * 1000,
18284
- searchPlaceholder = "Search ..."
18317
+ searchPlaceholder = "Search ...",
18318
+ refreshSignal = 0 // 外部刷新信号,数值变化时触发刷新
18285
18319
  } = _ref;
18286
18320
  const {
18287
18321
  message,
@@ -18308,7 +18342,8 @@ const ResourcesView = _ref => {
18308
18342
  loading,
18309
18343
  originTreeData,
18310
18344
  updateFileContents,
18311
- removeFile
18345
+ removeFile,
18346
+ refreshTreeData
18312
18347
  } = useDirectoryTree({
18313
18348
  getFolderData: mergedApiConfig.getFolderData,
18314
18349
  createFolder: mergedApiConfig.createFolder,
@@ -18317,6 +18352,13 @@ const ResourcesView = _ref => {
18317
18352
  batchOperations: mergedFeatures.batchOperations,
18318
18353
  withRootNode
18319
18354
  });
18355
+
18356
+ // 监听外部刷新信号变化
18357
+ useEffect(() => {
18358
+ if (refreshTreeData && refreshSignal > 0) {
18359
+ refreshTreeData();
18360
+ }
18361
+ }, [refreshSignal, refreshTreeData]);
18320
18362
  const [showProgress, setShowProgress] = useState(false);
18321
18363
  const [percent, setPercent] = useState(0);
18322
18364
  const inputRef = useRef(null);