Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
546b2a89
authored
Apr 13, 2026
by
DigHuang
Committed by
GitHub
Apr 13, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: optimize sandbox editor layout and improve preview mode switching logic (#6746)
parent
fbdc8e4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
24 deletions
+19
-24
projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx
+1
-0
projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx
+18
-24
No files found.
projects/app/src/pageComponents/chat/SandboxEditor/Editor.tsx
View file @
546b2a89
...
@@ -319,6 +319,7 @@ const SandboxEditor = ({ appId, chatId, outLinkAuthData }: Props) => {
...
@@ -319,6 +319,7 @@ const SandboxEditor = ({ appId, chatId, outLinkAuthData }: Props) => {
display=
{
'flex'
}
display=
{
'flex'
}
flex=
{
1
}
flex=
{
1
}
w=
{
0
}
w=
{
0
}
minH=
{
0
}
flexDirection=
"column"
flexDirection=
"column"
bg=
"myGray.25"
bg=
"myGray.25"
>
>
...
...
projects/app/src/pageComponents/chat/SandboxEditor/components/EditorContent.tsx
View file @
546b2a89
...
@@ -53,9 +53,11 @@ const EditorContent = ({
...
@@ -53,9 +53,11 @@ const EditorContent = ({
const
[
generatingLink
,
setGeneratingLink
]
=
useState
(
false
);
const
[
generatingLink
,
setGeneratingLink
]
=
useState
(
false
);
const
openedFilesRef
=
useLatest
(
openedFiles
);
const
openedFilesRef
=
useLatest
(
openedFiles
);
// 切换文件时,如果新文件
不支持预览模式,重置为 source
// 切换文件时,如果新文件
支持预览则切换到预览模式,否则重置为源码模式。
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
getSupportsPreviewToggle
(
activeFile
?.
language
)
&&
viewMode
===
'preview'
)
{
if
(
getSupportsPreviewToggle
(
activeFile
?.
language
))
{
setViewMode
(
'preview'
);
}
else
{
setViewMode
(
'source'
);
setViewMode
(
'source'
);
}
}
},
[
activeFilePath
]);
},
[
activeFilePath
]);
...
@@ -92,17 +94,15 @@ const EditorContent = ({
...
@@ -92,17 +94,15 @@ const EditorContent = ({
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'image'
)
{
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'image'
)
{
return
(
return
(
<
Center
h=
"full"
bg=
"myGray.50"
borderRadius=
"md"
p=
{
4
}
>
<
Box
h=
"full"
overflow=
"auto"
>
<
Box
position=
"relative"
maxW=
"100%"
maxH=
"100%"
>
<
MyPhotoView
src=
{
content
}
alt=
{
name
}
maxW=
"100%"
objectFit=
"contain"
/>
<
MyPhotoView
src=
{
content
}
alt=
{
name
}
maxW=
"100%"
maxH=
"100%"
objectFit=
"contain"
/>
</
Box
>
</
Box
>
</
Center
>
);
);
}
}
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'audio'
)
{
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'audio'
)
{
return
(
return
(
<
Center
h=
"full"
bg=
"myGray.50"
borderRadius=
"md"
>
<
Center
h=
"full"
>
<
audio
controls
src=
{
content
}
>
<
audio
controls
src=
{
content
}
>
Your browser does not support the audio element.
Your browser does not support the audio element.
</
audio
>
</
audio
>
...
@@ -112,7 +112,7 @@ const EditorContent = ({
...
@@ -112,7 +112,7 @@ const EditorContent = ({
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'video'
)
{
if
(
content
.
startsWith
(
'blob:'
)
&&
language
===
'video'
)
{
return
(
return
(
<
Center
h=
"full"
bg=
"myGray.50"
borderRadius=
"md"
p=
{
4
}
>
<
Center
h=
"full"
>
<
video
controls
src=
{
content
}
style=
{
{
maxWidth
:
'100%'
,
maxHeight
:
'100%'
}
}
>
<
video
controls
src=
{
content
}
style=
{
{
maxWidth
:
'100%'
,
maxHeight
:
'100%'
}
}
>
Your browser does not support the video element.
Your browser does not support the video element.
</
video
>
</
video
>
...
@@ -129,7 +129,7 @@ const EditorContent = ({
...
@@ -129,7 +129,7 @@ const EditorContent = ({
const
{
language
,
content
}
=
activeFile
;
const
{
language
,
content
}
=
activeFile
;
if
(
language
===
'markdown'
)
{
if
(
language
===
'markdown'
)
{
return
(
return
(
<
Box
h=
"full"
overflow=
"auto"
bg=
"white"
>
<
Box
h=
"full"
overflow
Y
=
"auto"
bg=
"white"
>
<
Markdown
source=
{
content
}
/>
<
Markdown
source=
{
content
}
/>
</
Box
>
</
Box
>
);
);
...
@@ -137,17 +137,9 @@ const EditorContent = ({
...
@@ -137,17 +137,9 @@ const EditorContent = ({
if
(
language
===
'svg'
)
{
if
(
language
===
'svg'
)
{
const
svgUri
=
`data:image/svg+xml;charset=utf-8,
${
encodeURIComponent
(
content
)}
`
;
const
svgUri
=
`data:image/svg+xml;charset=utf-8,
${
encodeURIComponent
(
content
)}
`
;
return
(
return
(
<
Center
h=
"full"
bg=
"myGray.50"
borderRadius=
"md"
p=
{
4
}
>
<
Box
h=
"full"
overflow=
"auto"
>
<
Box
position=
"relative"
maxW=
"100%"
maxH=
"100%"
>
<
MyPhotoView
src=
{
svgUri
}
alt=
{
activeFile
.
name
}
maxW=
"100%"
objectFit=
"contain"
/>
<
MyPhotoView
</
Box
>
src=
{
svgUri
}
alt=
{
activeFile
.
name
}
maxW=
"100%"
maxH=
"100%"
objectFit=
"contain"
/>
</
Box
>
</
Center
>
);
);
}
}
}
}
...
@@ -226,6 +218,8 @@ const EditorContent = ({
...
@@ -226,6 +218,8 @@ const EditorContent = ({
flexDirection=
"column"
flexDirection=
"column"
borderRadius=
{
'md'
}
borderRadius=
{
'md'
}
bg=
{
'white'
}
bg=
{
'white'
}
minH=
{
0
}
h=
"100%"
>
>
<
Flex
<
Flex
align=
"center"
align=
"center"
...
@@ -254,8 +248,8 @@ const EditorContent = ({
...
@@ -254,8 +248,8 @@ const EditorContent = ({
{
getSupportsPreviewToggle
(
activeFile
?.
language
)
&&
(
{
getSupportsPreviewToggle
(
activeFile
?.
language
)
&&
(
<
FillRowTabs
<
FillRowTabs
list=
{
[
list=
{
[
{
label
:
t
(
'chat:sandbox_
source'
),
value
:
'source
'
},
{
label
:
t
(
'chat:sandbox_
preview'
),
value
:
'preview
'
},
{
label
:
t
(
'chat:sandbox_
preview'
),
value
:
'preview
'
}
{
label
:
t
(
'chat:sandbox_
source'
),
value
:
'source
'
}
]
}
]
}
value=
{
viewMode
}
value=
{
viewMode
}
onChange=
{
(
v
)
=>
setViewMode
(
v
as
'source'
|
'preview'
)
}
onChange=
{
(
v
)
=>
setViewMode
(
v
as
'source'
|
'preview'
)
}
...
@@ -287,7 +281,7 @@ const EditorContent = ({
...
@@ -287,7 +281,7 @@ const EditorContent = ({
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
<
Box
flex=
{
1
}
borderColor=
"myGray.200"
overflow=
"hidden"
>
<
Box
flex=
{
1
}
overflow=
"hidden"
position=
"relative"
zIndex=
{
1
}
minH=
{
0
}
>
{
renderFileContent
()
}
{
renderFileContent
()
}
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment