diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index b99e2fa..c6718cb 100755 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -12,6 +12,7 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as ThemesRouteImport } from './routes/themes' import { Route as SectorsRouteImport } from './routes/sectors' import { Route as HotMapRouteImport } from './routes/hot-map' +import { Route as CoreStocksRouteImport } from './routes/core-stocks' import { Route as IndexRouteImport } from './routes/index' import { Route as ThemeCodeRouteImport } from './routes/theme.$code' import { Route as StockCodeRouteImport } from './routes/stock.$code' @@ -32,6 +33,11 @@ const HotMapRoute = HotMapRouteImport.update({ path: '/hot-map', getParentRoute: () => rootRouteImport, } as any) +const CoreStocksRoute = CoreStocksRouteImport.update({ + id: '/core-stocks', + path: '/core-stocks', + getParentRoute: () => rootRouteImport, +} as any) const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', @@ -55,6 +61,7 @@ const ShareCodeRoute = ShareCodeRouteImport.update({ export interface FileRoutesByFullPath { '/': typeof IndexRoute + '/core-stocks': typeof CoreStocksRoute '/hot-map': typeof HotMapRoute '/sectors': typeof SectorsRoute '/themes': typeof ThemesRoute @@ -64,6 +71,7 @@ export interface FileRoutesByFullPath { } export interface FileRoutesByTo { '/': typeof IndexRoute + '/core-stocks': typeof CoreStocksRoute '/hot-map': typeof HotMapRoute '/sectors': typeof SectorsRoute '/themes': typeof ThemesRoute @@ -74,6 +82,7 @@ export interface FileRoutesByTo { export interface FileRoutesById { __root__: typeof rootRouteImport '/': typeof IndexRoute + '/core-stocks': typeof CoreStocksRoute '/hot-map': typeof HotMapRoute '/sectors': typeof SectorsRoute '/themes': typeof ThemesRoute @@ -85,6 +94,7 @@ export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '/' + | '/core-stocks' | '/hot-map' | '/sectors' | '/themes' @@ -94,6 +104,7 @@ export interface FileRouteTypes { fileRoutesByTo: FileRoutesByTo to: | '/' + | '/core-stocks' | '/hot-map' | '/sectors' | '/themes' @@ -103,6 +114,7 @@ export interface FileRouteTypes { id: | '__root__' | '/' + | '/core-stocks' | '/hot-map' | '/sectors' | '/themes' @@ -113,6 +125,7 @@ export interface FileRouteTypes { } export interface RootRouteChildren { IndexRoute: typeof IndexRoute + CoreStocksRoute: typeof CoreStocksRoute HotMapRoute: typeof HotMapRoute SectorsRoute: typeof SectorsRoute ThemesRoute: typeof ThemesRoute @@ -144,6 +157,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof HotMapRouteImport parentRoute: typeof rootRouteImport } + '/core-stocks': { + id: '/core-stocks' + path: '/core-stocks' + fullPath: '/core-stocks' + preLoaderRoute: typeof CoreStocksRouteImport + parentRoute: typeof rootRouteImport + } '/': { id: '/' path: '/' @@ -177,6 +197,7 @@ declare module '@tanstack/react-router' { const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, + CoreStocksRoute: CoreStocksRoute, HotMapRoute: HotMapRoute, SectorsRoute: SectorsRoute, ThemesRoute: ThemesRoute, diff --git a/src/routes/core-stocks.tsx b/src/routes/core-stocks.tsx new file mode 100644 index 0000000..e6fb448 --- /dev/null +++ b/src/routes/core-stocks.tsx @@ -0,0 +1,105 @@ +import { createFileRoute, Link } from "@tanstack/react-router"; +import { useQuery } from "@tanstack/react-query"; +import { fetchActiveCoreStocks } from "@/lib/core-stock-api"; +import { ArrowLeft, RefreshCw, Flame } from "lucide-react"; + +export const Route = createFileRoute("/core-stocks")({ + component: CoreStocksPage, +}); + +/** 格式化涨幅,红涨绿跌 */ +function formatGain(v: number | null | undefined): string { + if (v == null) return "·"; + const s = v > 0 ? `+${v.toFixed(2)}%` : `${v.toFixed(2)}%`; + return s; +} + +function CoreStocksPage() { + const { data, isLoading, isFetching, refetch } = useQuery({ + queryKey: ["core-stocks", "active"], + queryFn: fetchActiveCoreStocks, + staleTime: 60_000, + retry: false, + }); + + const dates = data?.dates ?? []; + const stocks = data?.stocks ?? []; + + return ( +
+ 活跃核心股(最近 10 个交易日内上榜)· 按上榜次数排序 · 共 {stocks.length} 只 +
+ + {isLoading ? ( + + ) : dates.length === 0 ? ( +| 股票 | + {dates.map((d) => ( ++ {d.slice(5)} + | + ))} +上榜 | +
|---|---|---|
| + {s.stockName} + {s.stockCode} + | + {dates.map((d) => { + const g = s.dailyGains[d]; + const cls = g == null ? "text-muted-foreground/40" : g >= 0 ? "text-red-500" : "text-green-500"; + return ( ++ {formatGain(g)} + | + ); + })} +
+
+ |
+