From 20b2afb0fcc7fc6dabf3b1d5023a788f646a2357 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Mon, 13 Jul 2026 20:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=BB=E5=B8=82=E5=80=BC?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=20&=20=E6=9D=BF=E5=9D=97?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=95=B0=E6=8D=AE=E5=90=88=E5=B9=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 后端: 修正腾讯API字段索引偏移 (total_market_cap [43]→[45], pb [45]→[46]),并处理市值单位转换(亿→元) 2. 前端: 板块切换时同步清空旧数据 + 显示加载态,避免新旧 数据合并闪现 Co-Authored-By: Claude --- backend/services/tencent.py | 11 ++++++----- src/routes/sectors.tsx | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/backend/services/tencent.py b/backend/services/tencent.py index 098424e..615028a 100644 --- a/backend/services/tencent.py +++ b/backend/services/tencent.py @@ -142,11 +142,11 @@ async def fetch_quote(code: str) -> Optional[dict]: return None text = resp.content.decode("gbk", errors="replace") parts = parse_tencent_data(text) - if not parts or len(parts) < 46: + if not parts or len(parts) < 47: return None # 字段索引:1=名称, 3=当前价, 4=昨收, 5=今开, 6=成交量(手) # 7=外盘, 8=内盘, 31=涨跌额, 32=涨跌幅%, 33=最高, 34=最低, 37=成交额(万) - # 38=换手率%, 39=市盈率, 43=总市值, 44=流通市值, 45=市净率 + # 38=换手率%, 39=市盈率, 43=振幅%, 44=流通市值(亿), 45=总市值(亿), 46=市净率 name = parts[1] or "" current_price = float(parts[3]) if parts[3] else 0 yesterday_close = float(parts[4]) if parts[4] else 0 @@ -161,9 +161,10 @@ async def fetch_quote(code: str) -> Optional[dict]: inner_disk = float(parts[8]) if parts[8] else 0 turnover_rate = float(parts[38]) if parts[38] else 0 # 换手率% pe = float(parts[39]) if parts[39] else 0 # 市盈率 - total_market_cap = float(parts[43]) if parts[43] else 0 # 总市值 - circulating_market_cap = float(parts[44]) if parts[44] else 0 # 流通市值 - pb = float(parts[45]) if parts[45] else 0 # 市净率 + # 腾讯API返回的市值单位是亿, formatMoney期望元, 需×1e8 + total_market_cap = float(parts[45]) * 1e8 if parts[45] else 0 # 总市值(亿→元) + circulating_market_cap = float(parts[44]) * 1e8 if parts[44] else 0 # 流通市值(亿→元) + pb = float(parts[46]) if parts[46] else 0 # 市净率 if not name or current_price == 0: return None diff --git a/src/routes/sectors.tsx b/src/routes/sectors.tsx index 6fb6eac..2f7e0da 100644 --- a/src/routes/sectors.tsx +++ b/src/routes/sectors.tsx @@ -75,7 +75,13 @@ function SectorsPage() { {TABS.map((t) => (