updata:icon替换
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { type MouseEvent as ReactMouseEvent, useEffect, useMemo } from "react";
|
||||
|
||||
import Icon from "../../components/common/Icon";
|
||||
import {
|
||||
BookOpen,
|
||||
ChevronRight,
|
||||
Database,
|
||||
FileCode,
|
||||
Folder,
|
||||
Lock,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
import type {
|
||||
ScriptItem,
|
||||
WorkspaceDirectory,
|
||||
@@ -52,8 +60,8 @@ function formatTime(value: string) {
|
||||
}).format(new Date(value));
|
||||
}
|
||||
|
||||
export function scriptIcon(item: ScriptItem) {
|
||||
return item.script_type === "notebook" ? "notebook" : "python";
|
||||
export function scriptIcon(item: Pick<ScriptItem, "script_type">): LucideIcon {
|
||||
return item.script_type === "notebook" ? BookOpen : FileCode;
|
||||
}
|
||||
|
||||
function ownedScriptPath(item: ScriptItem) {
|
||||
@@ -158,10 +166,10 @@ export function WorkspaceTreeGroup({
|
||||
open ? "rotate-90" : ""
|
||||
}`}
|
||||
>
|
||||
<Icon name="chevron" size={14} />
|
||||
<ChevronRight size={14} />
|
||||
</span>
|
||||
<span className="inline-flex text-[#eab434] [&_svg]:fill-[#f7c84a] [&_svg]:stroke-[#e0a828]">
|
||||
<Icon name="folder" size={17} />
|
||||
<Folder size={17} />
|
||||
</span>
|
||||
<span>{title}</span>
|
||||
</button>
|
||||
@@ -242,6 +250,7 @@ function WorkspaceTreeItems({
|
||||
{childScripts.map((item) => {
|
||||
const isActive = selectedId === item.script_id;
|
||||
const isData = item.script_id.startsWith("data:");
|
||||
const ItemIcon = isData ? Database : scriptIcon(item);
|
||||
const iconTone = isData
|
||||
? "text-[#5a8f6a] bg-[#eef8f1]"
|
||||
: item.script_type === "notebook"
|
||||
@@ -273,7 +282,7 @@ function WorkspaceTreeItems({
|
||||
: undefined}
|
||||
>
|
||||
<span className={`grid size-[25px] shrink-0 place-items-center rounded-[5px] ${iconTone}`}>
|
||||
<Icon name={isData ? "database" : scriptIcon(item)} size={17} />
|
||||
<ItemIcon size={17} />
|
||||
</span>
|
||||
<span className="flex min-w-0 flex-1 flex-col">
|
||||
<strong
|
||||
@@ -288,7 +297,7 @@ function WorkspaceTreeItems({
|
||||
</span>
|
||||
{item.is_locked && (
|
||||
<span className="mr-1 inline-flex items-center justify-center text-[#c79a3a]" title="已锁定">
|
||||
<Icon name="lock" size={12} />
|
||||
<Lock size={12} />
|
||||
</span>
|
||||
)}
|
||||
{item.visibility !== "private" && (
|
||||
@@ -343,10 +352,10 @@ function DirectoryBranch({
|
||||
open ? "rotate-90" : ""
|
||||
}`}
|
||||
>
|
||||
<Icon name="chevron" size={13} />
|
||||
<ChevronRight size={13} />
|
||||
</span>
|
||||
<span className="inline-flex shrink-0 text-[#e2aa27] [&_svg]:fill-[#f7c84a]">
|
||||
<Icon name="folder" size={17} />
|
||||
<Folder size={17} />
|
||||
</span>
|
||||
<strong
|
||||
className="truncate text-[11px] font-[650]"
|
||||
|
||||
Reference in New Issue
Block a user