Fixed the problem of abnormal display of front-end page pictures in docker deployment

This commit is contained in:
userName
2025-09-06 16:10:42 +08:00
parent df72fa9366
commit 9ba895fa8d
3 changed files with 10 additions and 32 deletions

View File

@@ -52,7 +52,8 @@ const MarkdownViewer: FC<MarkdownViewerProps> = ({ status }) => {
const [modelName, setModelName] = useState<string>('')
const [style, setStyle] = useState<string>('')
const [createTime, setCreateTime] = useState<string>('')
const baseURL = String(import.meta.env.VITE_API_BASE_URL).replace('/api','') || ''
// 确保baseURL没有尾部斜杠
const baseURL = (String(import.meta.env.VITE_API_BASE_URL || '').replace('/api','') || '').replace(/\/$/, '')
const getCurrentTask = useTaskStore.getState().getCurrentTask
const currentTask = useTaskStore(state => state.getCurrentTask())
const taskStatus = currentTask?.status || 'PENDING'
@@ -307,14 +308,14 @@ const MarkdownViewer: FC<MarkdownViewerProps> = ({ status }) => {
// Enhanced image with zoom capability
img: ({ node, ...props }) =>{
let src = baseURL +props.src
// Fix the URL by removing the 'undefined' prefix if it exists
let src = props.src
if (src.startsWith('/')) {
src = baseURL + src
}
props.src = src
return(
<div className="my-8 flex justify-center">
<Zoom>
<img

View File

@@ -24,7 +24,8 @@ interface NoteHistoryProps {
const NoteHistory: FC<NoteHistoryProps> = ({ onSelect, selectedId }) => {
const tasks = useTaskStore(state => state.tasks)
const removeTask = useTaskStore(state => state.removeTask)
const baseURL = import.meta.env.VITE_API_BASE_URL || 'api/'
// 确保baseURL没有尾部斜杠
const baseURL = (String(import.meta.env.VITE_API_BASE_URL || 'api')).replace(/\/$/, '')
const [rawSearch, setRawSearch] = useState('')
const [search, setSearch] = useState('')
const fuse = new Fuse(tasks, {
@@ -101,7 +102,7 @@ const NoteHistory: FC<NoteHistoryProps> = ({ onSelect, selectedId }) => {
src={
task.audioMeta.cover_url
? baseURL+`/image_proxy?url=${encodeURIComponent(task.audioMeta.cover_url)}`
? `${baseURL}/image_proxy?url=${encodeURIComponent(task.audioMeta.cover_url)}`
: '/placeholder.png'
}
alt="封面"