diff --git a/src/views/user-center/kyc/index.vue b/src/views/user-center/kyc/index.vue index 0a07492..bcf6c55 100644 --- a/src/views/user-center/kyc/index.vue +++ b/src/views/user-center/kyc/index.vue @@ -153,22 +153,20 @@ const parseFile = (path: string) => { // 移除末尾的斜杠 baseUrl = baseUrl.replace(/\/+$/, ''); - // 如果 baseUrl 是完整的 URL,则提取主机名 + // 从完整 URL 中提取域名部分 if (baseUrl.includes('://')) { try { - const parsedUrl = new URL(baseUrl); - baseUrl = parsedUrl.host; + const url = new URL(baseUrl); + baseUrl = url.host; // 这将获取域名和端口(如果有的话) } catch (error) { - console.error('无效的 URL:', error); - return path; // URL 解析失败时返回原始路径 + console.error('Invalid URL:', error); + // 如果解析失败,使用原始值的域名部分 + baseUrl = baseUrl.replace(/^https?:\/\//, '').split('/')[0]; } } - // 处理 baseUrl 可能只是主机名或 IP 的情况 - baseUrl = baseUrl.replace(/^https?:\/\//, ''); - - // 构造最终的 URL,确保格式正确 - return `//${baseUrl}/file${path.startsWith('/') ? path : '/' + path}`; + // 构造最终的 URL + return `${path.startsWith('/') ? path : '/' + path}`; } const getStatusText = (status: string) => { switch (status) {