fix: 无领涨股题材导致/themes页面崩溃(startsWith null)
东方财富题材列表存在 securityCode 为 null 的题材(如"铟"01726), getStockBoard(null) 调用 startsWith 抛 TypeError,React 渲染崩溃, 页面被错误边界接管。修复 getStockBoard 使其对空值兜底返回主板, 同时保护全部 8 处调用方;ThemeItem.securityCode/securityName 类型 如实标注为 string|null。新增最小回归脚本复现并验证修复。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -97,7 +97,9 @@ export interface BoardInfo {
|
||||
* - 8/4/920开头:北交所(BJB)
|
||||
* - 其他:主板
|
||||
*/
|
||||
export function getStockBoard(code: string): BoardInfo {
|
||||
export function getStockBoard(code: string | null | undefined): BoardInfo {
|
||||
// 题材列表等场景下 securityCode 可能为 null(无领涨股的题材),兜底为主板
|
||||
if (!code) return { board: "main", label: "", className: "" };
|
||||
if (code.startsWith("688")) {
|
||||
return { board: "kcb", label: "科", className: "bg-red-500/10 text-red-500 border-red-500/30" };
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import { getApiBaseUrl } from "@/lib/api-client";
|
||||
export interface ThemeItem {
|
||||
themeCode: string;
|
||||
themeName: string;
|
||||
securityName: string; // 领涨股名称
|
||||
securityCode: string; // 领涨股代码
|
||||
securityName: string | null; // 领涨股名称(无领涨股的题材为 null)
|
||||
securityCode: string | null; // 领涨股代码(无领涨股的题材为 null)
|
||||
codeWithSuffix: string;
|
||||
hotRank: number; // 热度排名
|
||||
f3: number | null; // 领涨股涨幅
|
||||
|
||||
Reference in New Issue
Block a user