完成开户方式图片路径的修改

This commit is contained in:
Lrd
2026-06-26 15:09:40 +08:00
parent 7e2a44c0a1
commit 5ef4719d4e
3 changed files with 18 additions and 4 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
} }
})(); })();
</script> </script>
<script type="module" crossorigin src="/assets/index-CV-e6vqH.js"></script> <script type="module" crossorigin src="/assets/index-gOfCWO4q.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-eLRg4pQk.css"> <link rel="stylesheet" crossorigin href="/assets/index-eLRg4pQk.css">
</head> </head>
<body> <body>
+15 -1
View File
@@ -23,6 +23,20 @@ const formatDateTime = (dateStr: string) => {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}; };
// 安全拼接URL,避免双斜杠
const buildUrl = (path: string): string => {
const baseUrl = import.meta.env.VITE_API_BASE || "http://localhost:8000";
// 如果已经是完整URL(以http://或https://开头),直接返回
if (path.startsWith('http://') || path.startsWith('https://')) {
return path;
}
// 移除路径开头的斜杠(如果有)
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
// 移除baseUrl结尾的斜杠(如果有)
const cleanBase = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
return `${cleanBase}/${cleanPath}`;
};
interface AuthorizationData { interface AuthorizationData {
id: string; id: string;
status: string; status: string;
@@ -363,7 +377,7 @@ const AuthorizationPage: React.FC = () => {
<div style={{ width: '100%', height: 120, marginBottom: 12, borderRadius: 8, overflow: 'hidden' }}> <div style={{ width: '100%', height: 120, marginBottom: 12, borderRadius: 8, overflow: 'hidden' }}>
{item.thumb ? ( {item.thumb ? (
<img <img
src={item.thumb} src={buildUrl(item.thumb)}
alt={item.typeName} alt={item.typeName}
style={{ width: '100%', height: '100%', objectFit: 'cover' }} style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/> />