diff --git a/projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx b/projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx index e98de6d9f5..52620ca9e4 100644 --- a/projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx +++ b/projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx @@ -319,6 +319,7 @@ const SandboxEditor = ({ appId, chatId, outLinkAuthData }: Props) => { display={'flex'} flex={1} w={0} + minH={0} flexDirection="column" bg="myGray.25" > diff --git a/projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx b/projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx index 125e20d946..3864e3be93 100644 --- a/projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx +++ b/projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx @@ -53,9 +53,11 @@ const EditorContent = ({ const [generatingLink, setGeneratingLink] = useState(false); const openedFilesRef = useLatest(openedFiles); - // 切换文件时,如果新文件不支持预览模式,重置为 source + // 切换文件时,如果新文件支持预览则切换到预览模式,否则重置为源码模式。 useEffect(() => { - if (!getSupportsPreviewToggle(activeFile?.language) && viewMode === 'preview') { + if (getSupportsPreviewToggle(activeFile?.language)) { + setViewMode('preview'); + } else { setViewMode('source'); } }, [activeFilePath]); @@ -92,17 +94,15 @@ const EditorContent = ({ if (content.startsWith('blob:') && language === 'image') { return ( -