From 3258325daa15a95a96c7c0a9cd9d0e4b8f1f575a Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 27 Aug 2026 10:16:38 +0800 Subject: [PATCH] feat(kline): add configurable external stock link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置页新增「个股详情外链」: 可填 URL 模板(占位符 {code}/{market}/{symbol}), 信息条第一行右侧显示外链图标(新标签打开)。留空关闭。 - 新建 lib/stock-external-link.ts: load/save/build + scheme 白名单(http/https) + symbol 形状守卫 - storage.ts 新增 stockExternalTemplate kv Co-Authored-By: Claude --- frontend/src/components/StockInfoBar.tsx | 18 ++++++++++-- frontend/src/lib/stock-external-link.ts | 36 ++++++++++++++++++++++++ frontend/src/lib/storage.ts | 3 ++ frontend/src/pages/settings/System.tsx | 28 +++++++++++++++++- 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 frontend/src/lib/stock-external-link.ts diff --git a/frontend/src/components/StockInfoBar.tsx b/frontend/src/components/StockInfoBar.tsx index 84737cf..7f01ebd 100644 --- a/frontend/src/components/StockInfoBar.tsx +++ b/frontend/src/components/StockInfoBar.tsx @@ -1,10 +1,11 @@ import { useState, type ReactNode } from 'react' -import { Settings2, RadioTower, Star } from 'lucide-react' +import { Settings2, RadioTower, Star, ExternalLink } from 'lucide-react' import type { KlineRow, FinancialMetricRecord } from '@/lib/api' import { fmtPrice, fmtBigNum, fmtVolume } from '@/lib/format' import { ListColumnCustomizer } from '@/components/ListColumnCustomizer' import { WatchlistAddMenu } from '@/components/WatchlistAddMenu' import { INFO_GROUPS, type ColumnConfig } from '@/lib/stock-info-fields' +import { buildStockExternalUrl, loadStockExternalTemplate } from '@/lib/stock-external-link' const BULL = '#C74040' const BEAR = '#2D9B65' @@ -235,6 +236,8 @@ export function StockInfoBar({ ) } + const extUrl = buildStockExternalUrl(loadStockExternalTemplate(), symbol) + return (
{/* Row 1: code, name, price, change, change% */} @@ -250,8 +253,19 @@ export function StockInfoBar({ {isUp ? '+' : ''}{fmtPrice(chgPct)}% - {/* 右侧操作按钮:加自选 + 加监控 + 信息条配置 */} + {/* 右侧操作按钮:外链 + 加自选 + 加监控 + 信息条配置 */}
+ {extUrl && ( + + + + )} {inWatchlist && onRemoveFromWatchlist ? (
+
+
+ +

个股详情外链

+
+ +
+
+
详情页 URL 模板
+
{"支持 {code} {market} {symbol} · 留空关闭外链"}
+
+ { + setExtTpl(e.target.value) + saveStockExternalTemplate(e.target.value) + }} + placeholder="https://..." + spellCheck={false} + className="w-[26rem] max-w-[60%] h-8 px-2.5 rounded-btn border border-border bg-base text-xs font-mono text-foreground focus:border-accent/50 focus:outline-none" + /> +
+
+