无界 onlineTicket 对接 MaxKey 与 consumer 接口并用 sub 登录;新增 setup_writing 写作配置确认流;定时任务创建弹窗限制多行高度并支持滚动。
95 lines
3.0 KiB
TypeScript
95 lines
3.0 KiB
TypeScript
import { useEffect, useRef, useState } from "react";
|
|
import type { GroupImperativeHandle } from "react-resizable-panels";
|
|
|
|
import {
|
|
ResizableHandle,
|
|
ResizablePanel,
|
|
ResizablePanelGroup,
|
|
} from "@/components/ui/resizable";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
import { useCanvasUIContext } from "../../contexts/CanvasUIContext";
|
|
import { CanvasStreamProvider } from "../../contexts/CanvasStreamContext";
|
|
import { CanvasChatPanel } from "../chat/CanvasChatPanel";
|
|
import { CanvasArtifactPanel } from "../artifact/CanvasArtifactPanel";
|
|
import { AIWritingPanel } from "../ai-writing/AIWritingPanel";
|
|
import { AIWritingProvider } from "../../contexts/AIWritingContext";
|
|
import { WritingFormProvider } from "../../contexts/WritingFormContext";
|
|
|
|
const LAYOUT_COLLAPSED = { chat: 0, artifact: 100 };
|
|
const LAYOUT_DEFAULT = { chat: 35, artifact: 65 };
|
|
|
|
type LeftMode = "chat" | "writing";
|
|
|
|
export function CanvasResizableLayout() {
|
|
const { isChatCollapsed } = useCanvasUIContext();
|
|
const layoutRef = useRef<GroupImperativeHandle>(null);
|
|
const [leftMode, setLeftMode] = useState<LeftMode>("chat");
|
|
|
|
useEffect(() => {
|
|
layoutRef.current?.setLayout(
|
|
isChatCollapsed ? LAYOUT_COLLAPSED : LAYOUT_DEFAULT,
|
|
);
|
|
}, [isChatCollapsed]);
|
|
|
|
return (
|
|
<CanvasStreamProvider>
|
|
<div className="flex-1 min-h-0 overflow-hidden">
|
|
<ResizablePanelGroup
|
|
orientation="horizontal"
|
|
groupRef={layoutRef}
|
|
className="h-full"
|
|
>
|
|
<ResizablePanel
|
|
id="chat"
|
|
defaultSize={35}
|
|
minSize={0}
|
|
collapsible
|
|
collapsedSize={0}
|
|
className="overflow-hidden flex flex-col"
|
|
>
|
|
{/* 模式切换标签栏 */}
|
|
<div className="flex shrink-0 border-b bg-muted/30">
|
|
{(["chat", "writing"] as LeftMode[]).map((mode) => (
|
|
<button
|
|
key={mode}
|
|
onClick={() => setLeftMode(mode)}
|
|
className={cn(
|
|
"flex-1 py-1.5 text-xs font-medium transition-colors",
|
|
leftMode === mode
|
|
? "border-b-2 border-primary text-foreground"
|
|
: "text-muted-foreground hover:text-foreground",
|
|
)}
|
|
>
|
|
{mode === "chat" ? "对话" : "AI 写作"}
|
|
</button>
|
|
))}
|
|
</div>
|
|
|
|
<div className="flex-1 min-h-0 overflow-hidden">
|
|
{leftMode === "chat" ? <CanvasChatPanel /> : (
|
|
<AIWritingProvider>
|
|
<WritingFormProvider>
|
|
<AIWritingPanel />
|
|
</WritingFormProvider>
|
|
</AIWritingProvider>
|
|
)}
|
|
</div>
|
|
</ResizablePanel>
|
|
|
|
<ResizableHandle withHandle />
|
|
|
|
<ResizablePanel
|
|
id="artifact"
|
|
defaultSize={65}
|
|
minSize={40}
|
|
className="overflow-hidden"
|
|
>
|
|
<CanvasArtifactPanel />
|
|
</ResizablePanel>
|
|
</ResizablePanelGroup>
|
|
</div>
|
|
</CanvasStreamProvider>
|
|
);
|
|
}
|