feat: workspace 目录树服务端懒加载
- api.ts: listWorkspaceDirectories 支持 parent_path 查询; WorkspaceDirectory 增加 has_children; 同步 WorkspaceBoundApi 签名 - AuthContext: 绑定透传 parentPath - scriptWorkspaceStore: 新增 expandedPaths/loadingChildrenPaths/loadedChildPaths, loadChildren/toggleExpanded, 局部刷新 createFolder/deleteDirectory - WorkspaceTree: 移除 useState, 改为受控展开/加载状态 - ScriptExplorer: 从 store 读取并透传展开状态与 toggle
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { type ChangeEvent, type MouseEvent as ReactMouseEvent, type RefObject, useMemo } from "react";
|
||||
import Icon from "../common/Icon";
|
||||
import { WorkspaceTreeGroup } from "~/features/platform/WorkspaceTree";
|
||||
import { useScriptWorkspaceStore } from "~/features/platform/state/scriptWorkspaceStore";
|
||||
import type { ScriptItem, WorkspaceDirectory } from "~/services/api";
|
||||
import { type AuthUser } from "~/context/AuthContext";
|
||||
|
||||
@@ -50,6 +51,12 @@ export function ScriptExplorer({
|
||||
uploadInputRef,
|
||||
onHandleUpload,
|
||||
}: ScriptExplorerProps) {
|
||||
const expandedPaths = useScriptWorkspaceStore((s) => s.expandedPaths);
|
||||
const loadingChildrenPaths = useScriptWorkspaceStore(
|
||||
(s) => s.loadingChildrenPaths,
|
||||
);
|
||||
const onToggle = useScriptWorkspaceStore((s) => s.toggleExpanded);
|
||||
|
||||
const memberScriptGroups = useMemo(() => {
|
||||
const visibleScripts =
|
||||
user?.is_system_admin === true
|
||||
@@ -185,6 +192,9 @@ export function ScriptExplorer({
|
||||
: undefined
|
||||
}
|
||||
readOnly={group.user?.user_id !== user?.user_id}
|
||||
expandedPaths={expandedPaths}
|
||||
onToggle={onToggle}
|
||||
loadingChildrenPaths={loadingChildrenPaths}
|
||||
/>
|
||||
))}
|
||||
{filteredScripts.length === 0 && (
|
||||
|
||||
Reference in New Issue
Block a user