diff --git a/src/views/Concept/ConceptTimelineModal.js b/src/views/Concept/ConceptTimelineModal.js index 76c411d4..4844056a 100644 --- a/src/views/Concept/ConceptTimelineModal.js +++ b/src/views/Concept/ConceptTimelineModal.js @@ -65,6 +65,21 @@ const shimmerAnimation = keyframes` 100% { transform: translateX(100%); } `; +// 格式化URL,确保有协议前缀 +const formatUrl = (url) => { + if (!url) return null; + // 如果已经有协议前缀,直接返回 + if (url.startsWith('http://') || url.startsWith('https://')) { + return url; + } + // 如果是 // 开头的协议相对URL + if (url.startsWith('//')) { + return 'https:' + url; + } + // 否则添加 https:// 前缀 + return 'https://' + url; +}; + import { getApiBase } from '@utils/apiConfig'; // API配置 - 生产环境通过 api.valuefrontier.cn 代理 @@ -1376,7 +1391,27 @@ const ConceptTimelineModal = ({ bg="whiteAlpha.100" color="white" leftIcon={} - onClick={() => window.open(selectedReport.content_url, '_blank')} + onClick={() => { + const url = formatUrl(selectedReport.content_url); + if (url) { + const newWindow = window.open(url, '_blank'); + if (!newWindow) { + toast({ + title: '请允许弹窗', + description: '浏览器可能阻止了新窗口,请检查地址栏', + status: 'warning', + duration: 3000, + }); + } + } else { + toast({ + title: '链接无效', + description: '该研报暂无有效原文链接', + status: 'error', + duration: 3000, + }); + } + }} _hover={{ bg: 'whiteAlpha.200' }} > 查看原文