mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-23 06:04:46 +08:00
feat: auto expand in demo mode
This commit is contained in:
@@ -43,6 +43,7 @@ export default function ChatPage() {
|
|||||||
open: artifactsOpen,
|
open: artifactsOpen,
|
||||||
setOpen: setArtifactsOpen,
|
setOpen: setArtifactsOpen,
|
||||||
setArtifacts,
|
setArtifacts,
|
||||||
|
select: selectArtifact,
|
||||||
selectedArtifact,
|
selectedArtifact,
|
||||||
} = useArtifacts();
|
} = useArtifacts();
|
||||||
const { thread_id: threadIdFromPath } = useParams<{ thread_id: string }>();
|
const { thread_id: threadIdFromPath } = useParams<{ thread_id: string }>();
|
||||||
@@ -75,9 +76,16 @@ export default function ChatPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setArtifacts(thread.values.artifacts);
|
setArtifacts(thread.values.artifacts);
|
||||||
}, [setArtifacts, thread.values.artifacts]);
|
if (env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true") {
|
||||||
|
if (thread?.values?.artifacts?.length > 0) {
|
||||||
|
selectArtifact(thread.values.artifacts[0]!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [selectArtifact, setArtifacts, thread.values.artifacts]);
|
||||||
|
|
||||||
const [todoListCollapsed, setTodoListCollapsed] = useState(true);
|
const [todoListCollapsed, setTodoListCollapsed] = useState(
|
||||||
|
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY !== "true",
|
||||||
|
);
|
||||||
|
|
||||||
const handleSubmit = useSubmitThread({
|
const handleSubmit = useSubmitThread({
|
||||||
isNewThread,
|
isNewThread,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
|
Code2Icon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
|
EyeIcon,
|
||||||
SquareArrowOutUpRightIcon,
|
SquareArrowOutUpRightIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
@@ -31,6 +33,8 @@ import { useI18n } from "@/core/i18n/hooks";
|
|||||||
import { checkCodeFile, getFileName } from "@/core/utils/files";
|
import { checkCodeFile, getFileName } from "@/core/utils/files";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
import { Tooltip } from "../tooltip";
|
||||||
|
|
||||||
import { useArtifacts } from "./context";
|
import { useArtifacts } from "./context";
|
||||||
|
|
||||||
export function ArtifactFileDetail({
|
export function ArtifactFileDetail({
|
||||||
@@ -115,8 +119,16 @@ export function ArtifactFileDetail({
|
|||||||
setViewMode(value as "code" | "preview")
|
setViewMode(value as "code" | "preview")
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ToggleGroupItem value="code">Code</ToggleGroupItem>
|
<Tooltip content={t.common.code}>
|
||||||
<ToggleGroupItem value="preview">Preview</ToggleGroupItem>
|
<ToggleGroupItem value="code">
|
||||||
|
<Code2Icon />
|
||||||
|
</ToggleGroupItem>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip content={t.common.preview}>
|
||||||
|
<ToggleGroupItem value="preview">
|
||||||
|
<EyeIcon />
|
||||||
|
</ToggleGroupItem>
|
||||||
|
</Tooltip>
|
||||||
</ToggleGroup>
|
</ToggleGroup>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createContext, useContext, useState, type ReactNode } from "react";
|
import { createContext, useContext, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
|
import { env } from "@/env";
|
||||||
|
|
||||||
export interface ArtifactsContextType {
|
export interface ArtifactsContextType {
|
||||||
artifacts: string[];
|
artifacts: string[];
|
||||||
@@ -28,7 +29,9 @@ export function ArtifactsProvider({ children }: ArtifactsProviderProps) {
|
|||||||
const [artifacts, setArtifacts] = useState<string[]>([]);
|
const [artifacts, setArtifacts] = useState<string[]>([]);
|
||||||
const [selectedArtifact, setSelectedArtifact] = useState<string | null>(null);
|
const [selectedArtifact, setSelectedArtifact] = useState<string | null>(null);
|
||||||
const [autoSelect, setAutoSelect] = useState(true);
|
const [autoSelect, setAutoSelect] = useState(true);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(
|
||||||
|
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true",
|
||||||
|
);
|
||||||
const [autoOpen, setAutoOpen] = useState(true);
|
const [autoOpen, setAutoOpen] = useState(true);
|
||||||
const { setOpen: setSidebarOpen } = useSidebar();
|
const { setOpen: setSidebarOpen } = useSidebar();
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ export const enUS: Translations = {
|
|||||||
custom: "Custom",
|
custom: "Custom",
|
||||||
notAvailableInDemoMode: "Not available in demo mode",
|
notAvailableInDemoMode: "Not available in demo mode",
|
||||||
loading: "Loading...",
|
loading: "Loading...",
|
||||||
|
code: "Code",
|
||||||
|
preview: "Preview",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export interface Translations {
|
|||||||
custom: string;
|
custom: string;
|
||||||
notAvailableInDemoMode: string;
|
notAvailableInDemoMode: string;
|
||||||
loading: string;
|
loading: string;
|
||||||
|
code: string;
|
||||||
|
preview: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ export const zhCN: Translations = {
|
|||||||
custom: "自定义",
|
custom: "自定义",
|
||||||
notAvailableInDemoMode: "在演示模式下不可用",
|
notAvailableInDemoMode: "在演示模式下不可用",
|
||||||
loading: "加载中...",
|
loading: "加载中...",
|
||||||
|
code: "代码",
|
||||||
|
preview: "预览",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
Reference in New Issue
Block a user