fix(Concept): 修复历史时间轴研报查看原文按钮无反应

- 添加 formatUrl 函数自动补全 URL 协议前缀(http/https)
- 处理缺少协议或协议相对路径的 URL
- 添加弹窗拦截提示和无效链接错误提示

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-15 18:03:00 +08:00
parent affff859b0
commit 1eb8361249

View File

@@ -65,6 +65,21 @@ const shimmerAnimation = keyframes`
100% { transform: translateX(100%); } 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'; import { getApiBase } from '@utils/apiConfig';
// API配置 - 生产环境通过 api.valuefrontier.cn 代理 // API配置 - 生产环境通过 api.valuefrontier.cn 代理
@@ -1376,7 +1391,27 @@ const ConceptTimelineModal = ({
bg="whiteAlpha.100" bg="whiteAlpha.100"
color="white" color="white"
leftIcon={<ExternalLinkIcon />} leftIcon={<ExternalLinkIcon />}
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' }} _hover={{ bg: 'whiteAlpha.200' }}
> >
查看原文 查看原文