diff --git a/app/routes/entry-modules._index.tsx b/app/routes/entry-modules._index.tsx index cb695d0..ef0688d 100644 --- a/app/routes/entry-modules._index.tsx +++ b/app/routes/entry-modules._index.tsx @@ -48,6 +48,18 @@ interface LoaderData { error?: string; } +function resolveModuleLogoUrl(path?: string | null): string | null { + if (!path) { + return null; + } + + if (path.startsWith("/images/") || path.startsWith("http://") || path.startsWith("https://")) { + return path; + } + + return `${DOCUMENT_URL}${path}`; +} + // 🔑 客户端加载函数 - 在浏览器端执行,axios-client 会自动添加 JWT export async function clientLoader({ request }: ClientLoaderFunctionArgs) { try { @@ -259,11 +271,10 @@ export default function EntryModulesList() { title: 'Logo图片', width: '150px', render: (_: any, record: EntryModule) => { - if (!record.path) { + const logoUrl = resolveModuleLogoUrl(record.path); + if (!logoUrl) { return 未上传; } - - const logoUrl = `${DOCUMENT_URL}${record.path}`; const hasFailed = failedImages.has(record.id!); return ( diff --git a/app/routes/entry-modules.new.tsx b/app/routes/entry-modules.new.tsx index e7efb0e..226dacc 100644 --- a/app/routes/entry-modules.new.tsx +++ b/app/routes/entry-modules.new.tsx @@ -79,6 +79,18 @@ const AREA_OPTIONS = [ { value: "省局", label: "省局" } ]; +function resolveModuleLogoUrl(path?: string | null): string | null { + if (!path) { + return null; + } + + if (path.startsWith("/images/") || path.startsWith("http://") || path.startsWith("https://")) { + return path; + } + + return `${DOCUMENT_URL}${path}`; +} + // 入口模块新建/编辑组件 export default function EntryModuleNew() { const navigate = useNavigate(); @@ -106,7 +118,7 @@ export default function EntryModuleNew() { ); const [logoFile, setLogoFile] = useState(null); const [logoPreview, setLogoPreview] = useState( - module?.path ? `${DOCUMENT_URL}${module.path}` : null + resolveModuleLogoUrl(module?.path) ); const [isSubmitting, setIsSubmitting] = useState(false);