feat:脚本文件预览
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
BookOpen,
|
||||
Database,
|
||||
Eye,
|
||||
FileCode,
|
||||
FileText,
|
||||
Folder,
|
||||
@@ -10,6 +11,7 @@ import {
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import type { ScriptItem, ScriptType } from "../../services/api";
|
||||
import { canPreviewDataResource } from "./dataResourcePreview";
|
||||
|
||||
type ContextMenuState = {
|
||||
x: number;
|
||||
@@ -29,6 +31,7 @@ type TreeContextMenuProps = {
|
||||
onChooseUpload: (parentPath: string) => void;
|
||||
onRemoveDirectory: (path: string) => void;
|
||||
onCopyResourcePath?: (jupyterPath: string) => void;
|
||||
onPreviewResource?: (script: ScriptItem) => void;
|
||||
onRemoveResource?: (resourceId: string) => void;
|
||||
onClose: () => void;
|
||||
};
|
||||
@@ -49,12 +52,15 @@ export function TreeContextMenu({
|
||||
onChooseUpload,
|
||||
onRemoveDirectory,
|
||||
onCopyResourcePath,
|
||||
onPreviewResource,
|
||||
onRemoveResource,
|
||||
onClose,
|
||||
}: TreeContextMenuProps) {
|
||||
if (!contextMenu) return null;
|
||||
|
||||
const isDataResource = !!contextMenu.script?.script_id.startsWith("data:");
|
||||
const canPreview =
|
||||
isDataResource && canPreviewDataResource(contextMenu.script?.script_name);
|
||||
const LockToggleIcon = contextMenu.script?.is_locked ? Unlock : Lock;
|
||||
|
||||
return (
|
||||
@@ -71,6 +77,20 @@ export function TreeContextMenu({
|
||||
<>
|
||||
{isDataResource ? (
|
||||
<>
|
||||
{canPreview && onPreviewResource && (
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className={menuItemClass}
|
||||
onClick={() => {
|
||||
onPreviewResource(contextMenu.script!);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<Eye size={16} />
|
||||
预览
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
|
||||
Reference in New Issue
Block a user