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 ( -
- - - -
+ + + ); } if (content.startsWith('blob:') && language === 'audio') { return ( -
+
@@ -112,7 +112,7 @@ const EditorContent = ({ if (content.startsWith('blob:') && language === 'video') { return ( -
+
@@ -129,7 +129,7 @@ const EditorContent = ({ const { language, content } = activeFile; if (language === 'markdown') { return ( - + ); @@ -137,17 +137,9 @@ const EditorContent = ({ if (language === 'svg') { const svgUri = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(content)}`; return ( -
- - - -
+ + + ); } } @@ -226,6 +218,8 @@ const EditorContent = ({ flexDirection="column" borderRadius={'md'} bg={'white'} + minH={0} + h="100%" > setViewMode(v as 'source' | 'preview')} @@ -287,7 +281,7 @@ const EditorContent = ({ - + {renderFileContent()}