From 1eb8361249a0e86f9a203e89ffe3ca83b44ce335 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Mon, 15 Dec 2025 18:03:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(Concept):=20=E4=BF=AE=E5=A4=8D=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=97=B6=E9=97=B4=E8=BD=B4=E7=A0=94=E6=8A=A5=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=8E=9F=E6=96=87=E6=8C=89=E9=92=AE=E6=97=A0=E5=8F=8D?= =?UTF-8?q?=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 formatUrl 函数自动补全 URL 协议前缀(http/https) - 处理缺少协议或协议相对路径的 URL - 添加弹窗拦截提示和无效链接错误提示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/views/Concept/ConceptTimelineModal.js | 37 ++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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' }} > 查看原文