fix(webui): localize the component gallery
This commit is contained in:
1 parent
282839cc65
commit
ae5cb64e9e
54 files changed
+11120
-719
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useRef, useState, type ReactNode } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
|
||||
import { CapabilityMentionToken } from "@/components/CliAppMentionText";
|
||||
import type { CapabilityMentionSegment } from "@/lib/composer-mention-text";
|
||||
@@ -26,6 +26,7 @@ import type { HostCompatibility, RemoteProfile } from "@/lib/remote-instances";
|
||||
import type { CliAppInfo, McpPresetInfo, SessionAutomationJob, SessionMention, WorkbenchLayout } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Sample, StatePicker, type ComponentExample } from "./example";
|
||||
import { useGalleryTranslation } from "./i18n";
|
||||
|
||||
const cliApp: CliAppInfo = {
|
||||
name: "nanobot", display_name: "Nanobot", category: "assistant", description: "Local assistant",
|
||||
@@ -45,18 +46,19 @@ const sessionMention: SessionMention = {
|
||||
|
||||
function RenamePreview() {
|
||||
const { t } = useTranslation();
|
||||
const { t: g } = useGalleryTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [title, setTitle] = useState("组件设计");
|
||||
return <div className="space-y-4">
|
||||
<p className="text-sm">{title}</p>
|
||||
<Button variant="outline" onClick={() => setOpen(true)}>重命名分组</Button>
|
||||
<Button variant="outline" onClick={() => setOpen(true)}>{t("workbench.renameGroupTitle")}</Button>
|
||||
<RenameDialog open={open} title={title}
|
||||
dialogTitle={t("workbench.renameGroupTitle")}
|
||||
description={t("workbench.renameGroupDescription")}
|
||||
placeholder={t("workbench.renameGroupPlaceholder")}
|
||||
onCancel={() => setOpen(false)}
|
||||
onConfirm={(next) => { setTitle(next); setOpen(false); }} />
|
||||
<p role="status" className="text-xs text-muted-foreground">保存后更新上方标题。</p>
|
||||
<p role="status" className="text-xs text-muted-foreground">{g("previews.rename.hint")}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -69,33 +71,36 @@ const automations: SessionAutomationJob[] = [
|
||||
];
|
||||
|
||||
function DeletePreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [scenario, setScenario] = useState<"single" | "multiple" | "automations">("single");
|
||||
const [open, setOpen] = useState(false);
|
||||
const [deleted, setDeleted] = useState(false);
|
||||
return <>
|
||||
<StatePicker label="删除场景" value={scenario} options={["single", "multiple", "automations"]}
|
||||
<StatePicker label={t("previews.delete.scenario")} value={scenario} options={["single", "multiple", "automations"]}
|
||||
onChange={(next) => { setScenario(next); setDeleted(false); }} />
|
||||
<Button variant="outline" onClick={() => { setDeleted(false); setOpen(true); }}>打开删除确认</Button>
|
||||
<Button variant="outline" onClick={() => { setDeleted(false); setOpen(true); }}>{t("previews.delete.open")}</Button>
|
||||
<DeleteConfirm open={open} title="组件设计" count={scenario === "multiple" ? 3 : 1}
|
||||
automations={scenario === "automations" ? automations : []} onCancel={() => setOpen(false)}
|
||||
onConfirm={() => { setDeleted(true); setOpen(false); }} />
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">{deleted ? "已确认删除示例。" : "选择单个、批量或带自动任务的会话。"}</p>
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">{t(deleted ? "previews.delete.confirmed" : "previews.delete.hint")}</p>
|
||||
</>;
|
||||
}
|
||||
|
||||
function InlineTokensPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [command, setCommand] = useState("/status");
|
||||
const [handle, setHandle] = useState("gallery-session");
|
||||
return <div className="space-y-5">
|
||||
<Sample label="命令文本"><Input aria-label="命令文本" value={command} onChange={(event) => setCommand(event.target.value)} />
|
||||
<p className="text-sm">运行 <SlashCommandText command={command} /> 查看状态。</p></Sample>
|
||||
<Sample label="会话标识"><Input aria-label="会话标识" value={handle} onChange={(event) => setHandle(event.target.value)} />
|
||||
<p className="text-sm">继续 <SessionHandleLabel id={handle}>@design</SessionHandleLabel> 中的工作。</p></Sample>
|
||||
<Sample label="共享高亮"><p className="text-sm">使用 <InlineTokenHighlight color={INLINE_TOKEN_HIGHLIGHT_COLOR} title="Skill: review">review</InlineTokenHighlight> 检查修改。</p></Sample>
|
||||
<Sample label={t("previews.inlineTokens.command")}><Input aria-label={t("previews.inlineTokens.command")} value={command} onChange={(event) => setCommand(event.target.value)} />
|
||||
<p className="text-sm"><Trans t={t} i18nKey="previews.inlineTokens.run" components={{ command: <SlashCommandText command={command} /> }} /></p></Sample>
|
||||
<Sample label={t("previews.inlineTokens.handle")}><Input aria-label={t("previews.inlineTokens.handle")} value={handle} onChange={(event) => setHandle(event.target.value)} />
|
||||
<p className="text-sm"><Trans t={t} i18nKey="previews.inlineTokens.continue" components={{ session: <SessionHandleLabel id={handle}>@design</SessionHandleLabel> }} /></p></Sample>
|
||||
<Sample label={t("previews.inlineTokens.highlight")}><p className="text-sm"><Trans t={t} i18nKey="previews.inlineTokens.review" components={{ skill: <InlineTokenHighlight color={INLINE_TOKEN_HIGHLIGHT_COLOR} title={t("previews.inlineTokens.skill", { name: "review" })}>review</InlineTokenHighlight> }} /></p></Sample>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function SessionLinksPreview({ children }: { children: ReactNode }) {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [selected, setSelected] = useState(false);
|
||||
return <div className="space-y-4" onClick={(event) => {
|
||||
if (!(event.target instanceof Element)) return;
|
||||
@@ -105,14 +110,15 @@ function SessionLinksPreview({ children }: { children: ReactNode }) {
|
||||
setSelected(true);
|
||||
}}>
|
||||
{children}
|
||||
<p role="status" className="text-xs text-muted-foreground">{selected ? "已选择会话:组件设计。" : "选择会话引用查看反馈。"}</p>
|
||||
<p role="status" className="text-xs text-muted-foreground">{selected ? t("previews.sessionLinks.selected", { name: sessionMention.title }) : t("previews.sessionLinks.hint")}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function UserTextPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [text, setText] = useState("用 $review 检查 @nanobot 的修改,参考 @design 和 @files。");
|
||||
return <SessionLinksPreview>
|
||||
<label className="grid gap-2 text-xs text-muted-foreground">消息文本
|
||||
<label className="grid gap-2 text-xs text-muted-foreground">{t("previews.userText.message")}
|
||||
<Textarea value={text} onChange={(event) => setText(event.target.value)} />
|
||||
</label>
|
||||
<p className="whitespace-pre-wrap text-sm leading-7"><UserMessageText text={text} cliApps={[cliApp]}
|
||||
@@ -121,6 +127,7 @@ function UserTextPreview() {
|
||||
}
|
||||
|
||||
function CapabilityTokensPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [variant, setVariant] = useState<"message" | "composer">("message");
|
||||
const segments: Array<Exclude<CapabilityMentionSegment, { kind: "text" }>> = [
|
||||
{ kind: "cli", text: "@nanobot", app: cliApp },
|
||||
@@ -128,23 +135,24 @@ function CapabilityTokensPreview() {
|
||||
{ kind: "session", text: "@design", mention: sessionMention },
|
||||
];
|
||||
return <SessionLinksPreview>
|
||||
<StatePicker label="引用位置" value={variant} options={["message", "composer"]} onChange={setVariant} />
|
||||
<StatePicker label={t("previews.capabilityTokens.position")} value={variant} options={["message", "composer"]} onChange={setVariant} />
|
||||
<div className="flex flex-wrap gap-6 text-sm leading-7">{segments.map((segment) =>
|
||||
<CapabilityMentionToken key={segment.kind} segment={segment} variant={variant} />)}</div>
|
||||
</SessionLinksPreview>;
|
||||
}
|
||||
|
||||
function ProductIconsPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [size, setSize] = useState<"16" | "20" | "24">("20");
|
||||
const [selected, setSelected] = useState("ConversationIcon");
|
||||
return <>
|
||||
<StatePicker label="图标尺寸" value={size} options={["16", "20", "24"]} onChange={setSize} />
|
||||
<StatePicker label={t("previews.productIcons.size")} value={size} options={["16", "20", "24"]} onChange={setSize} />
|
||||
<div className="grid grid-cols-2 gap-2 sm:grid-cols-4 lg:grid-cols-6">{Object.entries(ProductIcons).map(([name, Icon]) =>
|
||||
<button key={name} type="button" aria-pressed={selected === name} onClick={() => setSelected(name)}
|
||||
className={cn("flex min-w-0 flex-col items-center gap-2 rounded-control p-3 text-muted-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", selected === name && "bg-muted text-foreground")}>
|
||||
<Icon size={Number(size)} /><span className="max-w-full break-all text-center text-[10px] leading-4">{name.replace(/Icon$/, "")}</span>
|
||||
</button>)}</div>
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">已选择:{selected}</p>
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">{t("previews.productIcons.selected", { name: selected })}</p>
|
||||
</>;
|
||||
}
|
||||
|
||||
@@ -153,34 +161,38 @@ function StartupPreview() {
|
||||
}
|
||||
|
||||
function FileActionsPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [scope, setScope] = useState<"workspace" | "outside" | "unresolved">("workspace");
|
||||
const path = "src/app.tsx";
|
||||
return <>
|
||||
<StatePicker label="文件范围" value={scope} options={["workspace", "outside", "unresolved"]} onChange={setScope} />
|
||||
<StatePicker label={t("previews.fileActions.scope")} value={scope} options={["workspace", "outside", "unresolved"]} onChange={setScope} />
|
||||
<FileActions path={path} metadata={scope === "unresolved" ? undefined : {
|
||||
path: scope === "workspace" ? "D:/workspace/nanobot/src/app.tsx" : "D:/documents/report.tsx",
|
||||
relative_path: scope === "workspace" ? path : null,
|
||||
}}><Button variant="outline">{path}</Button></FileActions>
|
||||
<p className="mt-4 text-xs text-muted-foreground">右键打开复制菜单,也可聚焦文件后按 Shift+F10。</p>
|
||||
<p className="mt-4 text-xs text-muted-foreground">{t("previews.fileActions.hint")}</p>
|
||||
</>;
|
||||
}
|
||||
|
||||
function WebLinksPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [display, setDisplay] = useState<"compact" | "expanded">("compact");
|
||||
const message = useRef<HTMLDivElement>(null);
|
||||
const links = useMessageWebLinks(message, open);
|
||||
return <div className="space-y-4">
|
||||
<StatePicker label="链接菜单宽度" value={display} options={["compact", "expanded"]} onChange={setDisplay} />
|
||||
<StatePicker label={t("previews.webLinks.width")} value={display} options={["compact", "expanded"]} onChange={setDisplay} />
|
||||
<div ref={message} className="text-sm leading-7"><p data-assistant-selectable>
|
||||
查看 <WebLink href={`${window.location.origin}/gallery.html`} className="underline underline-offset-4">组件画廊</WebLink>
|
||||
{" 和 "}<WebLink href={`${window.location.origin}/brand/nanobot_icon_512.png`} className="underline underline-offset-4">品牌图片</WebLink>。
|
||||
<Trans t={t} i18nKey="previews.webLinks.message" components={{
|
||||
gallery: <WebLink href={`${window.location.origin}/gallery.html`} className="underline underline-offset-4" />,
|
||||
brand: <WebLink href={`${window.location.origin}/brand/nanobot_icon_512.png`} className="underline underline-offset-4" />,
|
||||
}} />
|
||||
</p></div>
|
||||
<Button variant="outline" onClick={() => setOpen((value) => !value)}>{open ? "关闭链接菜单" : "查看消息链接"}</Button>
|
||||
<Button variant="outline" onClick={() => setOpen((value) => !value)}>{t(open ? "previews.webLinks.close" : "previews.webLinks.open")}</Button>
|
||||
{open && links.length > 0 ? <div className="rounded-control border p-1">
|
||||
<MessageLinksMenu links={links} onBack={() => setOpen(false)} onClose={() => setOpen(false)} expanded={display === "expanded"} />
|
||||
</div> : null}
|
||||
<p className="text-xs text-muted-foreground">右键链接可复制地址;消息菜单从实际渲染的链接中收集条目。</p>
|
||||
<p className="text-xs text-muted-foreground">{t("previews.webLinks.hint")}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -189,16 +201,17 @@ const initialPanes: WorkbenchPane[] = [
|
||||
];
|
||||
|
||||
function WorkbenchPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [panes, setPanes] = useState(initialPanes);
|
||||
const [active, setActive] = useState("pane-1");
|
||||
const [layout, setLayout] = useState<WorkbenchLayout>("columns");
|
||||
const [ratios, setRatios] = useState<number[]>([]);
|
||||
return <>
|
||||
<StatePicker label="窗格布局" value={layout} options={["columns", "rows", "grid", "bsp", "main-stack"]}
|
||||
<StatePicker label={t("previews.workbench.layout")} value={layout} options={["columns", "rows", "grid", "bsp", "main-stack"]}
|
||||
onChange={(next) => { setLayout(next); setRatios([]); }} />
|
||||
<div className="h-[28rem] overflow-hidden rounded-panel border">
|
||||
<PaneWorkbench panes={panes} activePaneKey={active} layout={layout} showLayoutControl
|
||||
addPaneDisabled={panes.length >= 4} addPaneDisabledLabel="最多四个窗格"
|
||||
addPaneDisabled={panes.length >= 4} addPaneDisabledLabel={t("previews.workbench.limit")}
|
||||
onActivatePane={setActive} onLayoutChange={(next) => { setLayout(next); setRatios([]); }}
|
||||
onAddPane={() => {
|
||||
const next = { key: `pane-${panes.length + 1}`, title: "补充笔记" };
|
||||
@@ -212,26 +225,28 @@ function WorkbenchPreview() {
|
||||
</div>;
|
||||
return <div className="flex min-w-0 flex-1 flex-col gap-3 p-3 pb-8">
|
||||
{context.active && context.headerPortalTarget ? createPortal(header, context.headerPortalTarget) : context.active ? header : <p className="h-10 content-center text-xs text-muted-foreground">{pane.title}</p>}
|
||||
<label className="grid gap-2 text-xs text-muted-foreground">{pane.title}笔记
|
||||
<label className="grid gap-2 text-xs text-muted-foreground">{t("previews.workbench.notes", { title: pane.title })}
|
||||
<Textarea defaultValue={`在${pane.title}窗格中编辑笔记。`} /></label>
|
||||
<p className="text-xs text-muted-foreground">{context.active ? "当前窗格" : "选择此窗格以激活"}</p>
|
||||
<p className="text-xs text-muted-foreground">{t(context.active ? "previews.workbench.active" : "previews.workbench.activate")}</p>
|
||||
</div>;
|
||||
}} />
|
||||
</div>
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">当前:{panes.find((pane) => pane.key === active)?.title}。拖动底部手柄移动窗格,拖动边界调整尺寸。</p>
|
||||
<p role="status" className="mt-4 text-xs text-muted-foreground">{t("previews.workbench.hint", { title: panes.find((pane) => pane.key === active)?.title })}</p>
|
||||
</>;
|
||||
}
|
||||
|
||||
function ConnectionPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [state, setState] = useState<HostConnectionState>("open");
|
||||
return <>
|
||||
<StatePicker label="连接状态" value={state} options={["open", "closed", "connecting", "error"]} onChange={setState} />
|
||||
<div className="flex flex-wrap gap-8"><Sample label="状态与文字"><HostConnectionStatus state={state} /></Sample>
|
||||
<Sample label="紧凑显示"><HostConnectionStatus state={state} compact /></Sample></div>
|
||||
<StatePicker label={t("previews.hostConnection.state")} value={state} options={["open", "closed", "connecting", "error"]} onChange={setState} />
|
||||
<div className="flex flex-wrap gap-8"><Sample label={t("previews.hostConnection.withText")}><HostConnectionStatus state={state} /></Sample>
|
||||
<Sample label={t("previews.hostConnection.compact")}><HostConnectionStatus state={state} compact /></Sample></div>
|
||||
</>;
|
||||
}
|
||||
|
||||
function CompatibilityPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [status, setStatus] = useState<HostCompatibility["status"] | "unchecked">("compatible");
|
||||
const [open, setOpen] = useState(false);
|
||||
const profile: RemoteProfile = {
|
||||
@@ -242,48 +257,48 @@ function CompatibilityPreview() {
|
||||
},
|
||||
};
|
||||
return <>
|
||||
<StatePicker label="版本兼容状态" value={status} options={["compatible", "update_host", "update_client", "unknown", "unchecked"]} onChange={setStatus} />
|
||||
<Button variant="outline" onClick={() => setOpen(true)}>查看兼容详情</Button>
|
||||
<StatePicker label={t("previews.compatibility.state")} value={status} options={["compatible", "update_host", "update_client", "unknown", "unchecked"]} onChange={setStatus} />
|
||||
<Button variant="outline" onClick={() => setOpen(true)}>{t("previews.compatibility.open")}</Button>
|
||||
<HostCompatibilityDialog profile={open ? profile : undefined} clientVersion="0.3.0" onClose={() => setOpen(false)} />
|
||||
</>;
|
||||
}
|
||||
|
||||
const components = "webui/src/components/";
|
||||
export const shellExamples: ComponentExample[] = [
|
||||
{ title: "RenameDialog · 分组与项目改名", files: ["RenameDialog"], Preview: RenamePreview,
|
||||
description: "预览分组和项目使用的改名弹窗;话题在会话列表中行内改名。", options: "调用方提供 dialogTitle、description 和 placeholder。title 设置初值,onConfirm 接收去除两端空白的标题。空标题无法保存。",
|
||||
{ title: "previews.rename.title", files: ["RenameDialog"], Preview: RenamePreview,
|
||||
description: "previews.rename.description", options: "previews.rename.options",
|
||||
code: '<RenameDialog open={open} title={title} dialogTitle="Rename group" description="Give this group a name." placeholder="Group name" onCancel={close} onConfirm={rename} />' },
|
||||
{ title: "DeleteConfirm · 删除确认", files: ["DeleteConfirm"], Preview: DeletePreview,
|
||||
description: "切换单个、批量和关联自动任务的删除确认。", options: "count 控制批量文案;automations 展示关联任务、计划与下次运行时间。确认按钮调用 onConfirm。",
|
||||
{ title: "previews.delete.title", files: ["DeleteConfirm"], Preview: DeletePreview,
|
||||
description: "previews.delete.description", options: "previews.delete.options",
|
||||
code: '<DeleteConfirm open={open} title="组件设计" count={1} automations={jobs} onCancel={close} onConfirm={remove} />' },
|
||||
{ title: "Inline tokens · 命令与会话标识", files: ["SlashCommandText", "InlineTokenHighlight", "SessionHandleLabel"], Preview: InlineTokensPreview,
|
||||
description: "输入命令与会话标识,观察高亮与稳定的会话颜色。", options: "SlashCommandText 接收 command;InlineTokenHighlight 接收 color 和内容;SessionHandleLabel 根据 id 生成颜色。",
|
||||
{ title: "previews.inlineTokens.title", files: ["SlashCommandText", "InlineTokenHighlight", "SessionHandleLabel"], Preview: InlineTokensPreview,
|
||||
description: "previews.inlineTokens.description", options: "previews.inlineTokens.options",
|
||||
code: '<SlashCommandText command="/status" />\n<SessionHandleLabel id={session.id}>@design</SessionHandleLabel>\n<InlineTokenHighlight color="var(--inline-token-highlight)">review</InlineTokenHighlight>' },
|
||||
{ title: "UserMessageText · 消息引用", files: ["UserMessageText"], Preview: UserTextPreview,
|
||||
description: "编辑消息,预览技能、应用、MCP 和会话引用。", options: "text 为原始消息;cliApps、mcpPresets 与 sessionMentions 提供可解析引用。技能使用 $name,其他引用使用 @name。",
|
||||
{ title: "previews.userText.title", files: ["UserMessageText"], Preview: UserTextPreview,
|
||||
description: "previews.userText.description", options: "previews.userText.options",
|
||||
code: '<UserMessageText text={text} cliApps={apps} mcpPresets={presets} sessionMentions={sessions} />' },
|
||||
{ title: "CapabilityMentionToken · 应用引用", files: ["CliAppMentionText"], Preview: CapabilityTokensPreview,
|
||||
description: "比较应用、MCP 与会话引用在输入框和消息中的样式。", options: "segment 指定 cli、mcp 或 session 及其元数据;variant 选择 composer 或 message。示例使用本地品牌图片。",
|
||||
{ title: "previews.capabilityTokens.title", files: ["CliAppMentionText"], Preview: CapabilityTokensPreview,
|
||||
description: "previews.capabilityTokens.description", options: "previews.capabilityTokens.options",
|
||||
code: '<CapabilityMentionToken segment={{ kind: "cli", text: "@nanobot", app }} variant="message" />' },
|
||||
{ title: "Product icons · 产品图标", files: ["icons/product-icons"], Preview: ProductIconsPreview,
|
||||
description: "浏览实际产品图标,切换尺寸并选择高亮状态。", options: "图标接受 LucideProps,例如 size、strokeWidth、className。颜色继承 currentColor,按钮提供可访问的动作名称。",
|
||||
{ title: "previews.productIcons.title", files: ["icons/product-icons"], Preview: ProductIconsPreview,
|
||||
description: "previews.productIcons.description", options: "previews.productIcons.options",
|
||||
code: '<ConversationIcon size={20} />\n<SettingsIcon className="text-muted-foreground" />' },
|
||||
{ title: "StartupShell · 启动占位", files: ["StartupShell"], Preview: StartupPreview,
|
||||
description: "预览应用连接时的安静占位布局。", options: "embedded 使用 section,其余情况使用 main。组件持续提供 aria-busy 与加载状态;占位样式来自应用入口。",
|
||||
{ title: "previews.startup.title", files: ["StartupShell"], Preview: StartupPreview,
|
||||
description: "previews.startup.description", options: "previews.startup.options",
|
||||
code: '<StartupShell embedded />' },
|
||||
{ title: "FileActions · 文件菜单", files: ["FileActions"], Preview: FileActionsPreview,
|
||||
description: "右键文件,体验完整路径、相对路径和引用文本的复制菜单。", options: "path 为引用文本;metadata 提供完整路径与可选相对路径。画廊直接提供元数据,无需加载文件。",
|
||||
{ title: "previews.fileActions.title", files: ["FileActions"], Preview: FileActionsPreview,
|
||||
description: "previews.fileActions.description", options: "previews.fileActions.options",
|
||||
code: '<FileActions path="src/app.tsx" metadata={{ path: "D:/workspace/src/app.tsx", relative_path: "src/app.tsx" }}><Button>app.tsx</Button></FileActions>' },
|
||||
{ title: "Web links · 链接菜单", files: ["WebLink", "MessageLinksMenu"], Preview: WebLinksPreview,
|
||||
description: "打开真实链接菜单,选择消息中的链接并复制地址。", options: "WebLink 接收链接属性;useMessageWebLinks 收集消息中实际渲染的链接。MessageLinksMenu 接收条目、返回与关闭回调,expanded 控制宽度。示例链接均指向本地画廊资源。",
|
||||
{ title: "previews.webLinks.title", files: ["WebLink", "MessageLinksMenu"], Preview: WebLinksPreview,
|
||||
description: "previews.webLinks.description", options: "previews.webLinks.options",
|
||||
code: '<WebLink href={url}>组件画廊</WebLink>\nconst links = useMessageWebLinks(messageRef, open);\n<MessageLinksMenu links={links} onBack={close} onClose={close} expanded />' },
|
||||
{ title: "PaneWorkbench · 多窗格", files: ["workbench/PaneWorkbench"], Preview: WorkbenchPreview,
|
||||
description: "切换布局、激活窗格、添加窗格并调整位置与尺寸。", options: "panes、activePaneKey、layout 与 splitRatios 由调用方控制。renderPane 提供内容;回调将变更写回本地示例状态。窄屏自动显示当前窗格。",
|
||||
{ title: "previews.workbench.title", files: ["workbench/PaneWorkbench"], Preview: WorkbenchPreview,
|
||||
description: "previews.workbench.description", options: "previews.workbench.options",
|
||||
code: '<PaneWorkbench panes={panes} activePaneKey={active} layout={layout} showLayoutControl onActivatePane={setActive} onAddPane={addPane} onLayoutChange={setLayout} onPaneOrderChange={reorder} renderPane={renderPane} />' },
|
||||
{ title: "HostConnectionStatus · 连接状态", files: ["remote/HostConnectionStatus"], Preview: ConnectionPreview,
|
||||
description: "切换已连接、断开、连接中和出错状态。", options: "state 控制图标与文字,compact 隐藏可见文字并保留可访问状态和悬浮标题。",
|
||||
{ title: "previews.hostConnection.title", files: ["remote/HostConnectionStatus"], Preview: ConnectionPreview,
|
||||
description: "previews.hostConnection.description", options: "previews.hostConnection.options",
|
||||
code: '<HostConnectionStatus state="connecting" />\n<HostConnectionStatus state="open" compact />' },
|
||||
{ title: "HostCompatibilityDialog · 版本兼容", files: ["remote/HostCompatibilityDialog"], Preview: CompatibilityPreview,
|
||||
description: "切换兼容检查结果,查看版本、准备说明和升级指南入口。", options: "profile 存在时打开对话框;compatibility 指定报告状态与版本。onClose 由调用方关闭;此组件只展示信息。",
|
||||
{ title: "previews.compatibility.title", files: ["remote/HostCompatibilityDialog"], Preview: CompatibilityPreview,
|
||||
description: "previews.compatibility.description", options: "previews.compatibility.options",
|
||||
code: '<HostCompatibilityDialog profile={selectedProfile} clientVersion="0.3.0" onClose={close} />' },
|
||||
].map((example) => ({ ...example, files: example.files.map((file) => `${components}${file}.tsx`) }));
|
||||
Reference in new issue
Block a user