feat:脚本文件预览
This commit is contained in:
@@ -19,6 +19,7 @@ import type {
|
||||
WorkspaceDirectory,
|
||||
ResourceItem,
|
||||
} from "~/services/api";
|
||||
import { canPreviewDataResource } from "./dataResourcePreview";
|
||||
|
||||
export type WorkspaceTreeTarget = {
|
||||
kind: "root" | "directory" | "file";
|
||||
@@ -39,6 +40,7 @@ type WorkspaceTreeProps = {
|
||||
readOnly?: boolean;
|
||||
dataResources?: ResourceItem[];
|
||||
onCopyResourcePath?: (jupyterPath: string) => void;
|
||||
onPreviewResource?: (script: ScriptItem) => void;
|
||||
// 唯一标识此 group(通常 `__group__<owner_user_id>`),让多个 owner 的 group 各自独立展开。
|
||||
groupKey: string;
|
||||
// 该 group 所属 owner 的 user_id —— 透传给 store.toggleExpanded,使他人
|
||||
@@ -129,6 +131,7 @@ export function WorkspaceTreeGroup({
|
||||
readOnly = false,
|
||||
dataResources,
|
||||
onCopyResourcePath,
|
||||
onPreviewResource,
|
||||
groupKey,
|
||||
ownerUserId,
|
||||
expandedPaths,
|
||||
@@ -242,6 +245,7 @@ export function WorkspaceTreeGroup({
|
||||
onToggle={onToggle}
|
||||
loadingChildrenPaths={loadingChildrenPaths}
|
||||
onCopyResourcePath={onCopyResourcePath}
|
||||
onPreviewResource={onPreviewResource}
|
||||
/>
|
||||
{scripts.length === 0 && directories.length === 0 && dataResourceScripts.length === 0 && (
|
||||
<p className="mb-[7px] ml-[35px] mt-0.5 text-[11px] text-[#a5b0bc]">
|
||||
@@ -265,6 +269,7 @@ function WorkspaceTreeItems({
|
||||
onSelect,
|
||||
onContextMenu,
|
||||
onCopyResourcePath,
|
||||
onPreviewResource,
|
||||
expandedPaths,
|
||||
onToggle,
|
||||
loadingChildrenPaths,
|
||||
@@ -293,6 +298,7 @@ function WorkspaceTreeItems({
|
||||
onToggle={onToggle}
|
||||
loadingChildrenPaths={loadingChildrenPaths}
|
||||
onCopyResourcePath={onCopyResourcePath}
|
||||
onPreviewResource={onPreviewResource}
|
||||
/>
|
||||
))}
|
||||
{childScripts.map((item) => {
|
||||
@@ -313,8 +319,12 @@ function WorkspaceTreeItems({
|
||||
key={item.script_id}
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (isData && onCopyResourcePath) {
|
||||
onCopyResourcePath(item.relative_path);
|
||||
if (isData) {
|
||||
if (canPreviewDataResource(item.script_name) && onPreviewResource) {
|
||||
onPreviewResource(item);
|
||||
} else if (onCopyResourcePath) {
|
||||
onCopyResourcePath(item.relative_path);
|
||||
}
|
||||
} else {
|
||||
onSelect(item.script_id);
|
||||
}
|
||||
@@ -370,6 +380,7 @@ function DirectoryBranch({
|
||||
onSelect,
|
||||
onContextMenu,
|
||||
onCopyResourcePath,
|
||||
onPreviewResource,
|
||||
expandedPaths,
|
||||
onToggle,
|
||||
loadingChildrenPaths,
|
||||
@@ -428,6 +439,7 @@ function DirectoryBranch({
|
||||
onToggle={onToggle}
|
||||
loadingChildrenPaths={loadingChildrenPaths}
|
||||
onCopyResourcePath={onCopyResourcePath}
|
||||
onPreviewResource={onPreviewResource}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user