diff --git a/01_content/src/client/split.tsx b/01_content/src/client/split.tsx index 23d20bc..dbd4d82 100644 --- a/01_content/src/client/split.tsx +++ b/01_content/src/client/split.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef, useState } from 'react' +import { Fragment, useCallback, useEffect, useRef, useState } from 'react' import { Terminal } from 'xterm' import 'xterm/css/xterm.css' import MarkdownIt from 'markdown-it' @@ -1245,6 +1245,51 @@ function TextViewer(props: { path: string; fileUrl: string; isMd: boolean }) { ) } +/** 自制下拉列表(原生 select 无法美化):文件夹分组标题 + 1px 细分隔线 + 选项列表 */ +function SelectPop(props: { + value: string | null + groups: { title: string; items: { id: string; label: string; isCurrent?: boolean }[] }[] + placeholder?: string + onChange: (id: string) => void +}) { + const [open, setOpen] = useState(false) + const flat = props.groups.flatMap((g) => g.items) + const selected = flat.find((i) => i.id === props.value) + return ( +
+ + {open && ( +
+ {props.groups.map((g, gi) => ( + + {g.title && ( + <> +
+
📁 {g.title}
+ + )} + {g.items.map((it) => ( + + ))} + + ))} +
+ )} +
+ ) +} + /** 自定义窗口:居中对话框。两种模式:新建专属会话 / 发送到已有会话(默认当前会话)。 */ function CustomPane() { const custom = splitEnv?.custom @@ -1320,37 +1365,25 @@ function CustomPane() { {mode === 'existing' && (
{T('custom.session')} - + ({ + title: g.title, + items: g.sessions.map((s) => ({ id: s.id, label: s.title, isCurrent: s.isCurrent })), + }))} + placeholder={T('custom.session')} + onChange={setSessionId} + />
)}
{T('custom.project')} - + ({ id: p.id, label: p.name })) }]} + placeholder={T('custom.project')} + onChange={setProjectId} + />