fix:修复kyc图片请求问题
This commit is contained in:
@@ -134,18 +134,41 @@ const getStatusColor = (status: string) => {
|
||||
}
|
||||
};
|
||||
//李工杰作 图片请求url组装
|
||||
const parseFile = (path:string)=>{
|
||||
// const parseFile = (path:string)=>{
|
||||
// let baseUrl = import.meta.env.VITE_SERVICE_BASE_URL;
|
||||
// if (baseUrl.indexOf('/') !== -1){
|
||||
// try {
|
||||
// const parsedUrl = new URL(baseUrl);
|
||||
// baseUrl = parsedUrl.host;
|
||||
// } catch (error) {
|
||||
// console.error('Invalid URL:', error);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return `//${baseUrl}/file${path}`
|
||||
// }
|
||||
const parseFile = (path: string) => {
|
||||
let baseUrl = import.meta.env.VITE_SERVICE_BASE_URL;
|
||||
if (baseUrl.indexOf('/') !== -1){
|
||||
|
||||
// 移除末尾的斜杠
|
||||
baseUrl = baseUrl.replace(/\/+$/, '');
|
||||
|
||||
// 如果 baseUrl 是完整的 URL,则提取主机名
|
||||
if (baseUrl.includes('://')) {
|
||||
try {
|
||||
const parsedUrl = new URL(baseUrl);
|
||||
baseUrl = parsedUrl.host;
|
||||
} catch (error) {
|
||||
console.error('Invalid URL:', error);
|
||||
return null;
|
||||
console.error('无效的 URL:', error);
|
||||
return path; // URL 解析失败时返回原始路径
|
||||
}
|
||||
}
|
||||
return `//${baseUrl}/file${path}`
|
||||
|
||||
// 处理 baseUrl 可能只是主机名或 IP 的情况
|
||||
baseUrl = baseUrl.replace(/^https?:\/\//, '');
|
||||
|
||||
// 构造最终的 URL,确保格式正确
|
||||
return `//${baseUrl}/file${path.startsWith('/') ? path : '/' + path}`;
|
||||
}
|
||||
const getStatusText = (status: string) => {
|
||||
switch (status) {
|
||||
|
||||
Reference in New Issue
Block a user