From ef6e308ad1154019bb1a0abc586e1430426ac659 Mon Sep 17 00:00:00 2001 From: fish Date: Mon, 6 Jul 2026 14:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E6=95=B0=E9=A1=B5=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=88=86=E6=97=B6=E6=95=B0=E6=8D=AE=E9=9D=A2=E6=9D=BF=EF=BC=8C?= =?UTF-8?q?K=E7=BA=BF=E5=9B=BE=E5=8D=A0=E6=BB=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- serve/frontend/src/pages/Indices.tsx | 84 +++++----------------------- 1 file changed, 15 insertions(+), 69 deletions(-) diff --git a/serve/frontend/src/pages/Indices.tsx b/serve/frontend/src/pages/Indices.tsx index a978310..370ecdb 100644 --- a/serve/frontend/src/pages/Indices.tsx +++ b/serve/frontend/src/pages/Indices.tsx @@ -1,12 +1,11 @@ import { useEffect, useMemo, useState } from 'react' import { useSearchParams } from 'react-router-dom' import { useQuery } from '@tanstack/react-query' -import { Activity, Lock, Search } from 'lucide-react' -import { api, type IndexInstrument, type KlineRow, type MinuteKlineRow } from '@/lib/api' +import { Activity, Search } from 'lucide-react' +import { api, type IndexInstrument, type KlineRow } from '@/lib/api' import { QK } from '@/lib/queryKeys' -import { useCapabilities } from '@/lib/useSharedQueries' + import { EChartsCandlestick, type OHLC } from '@/components/EChartsCandlestick' -import { EChartsIntraday } from '@/components/EChartsIntraday' function defaultRange() { const now = new Date() @@ -64,10 +63,6 @@ export function Indices() { const [selectedDate, setSelectedDate] = useState(null) const [linkedPrice, setLinkedPrice] = useState(null) - // 分时数据需 Pro+ (kline.minute.batch) 能力 - const caps = useCapabilities() - const hasMinuteCap = !!caps.data?.capabilities?.['kline.minute.batch'] - const list = useQuery({ queryKey: QK.indexList, queryFn: api.indexList, @@ -108,23 +103,8 @@ export function Indices() { placeholderData: (prev) => prev, }) - const minute = useQuery({ - queryKey: QK.indexMinute(selectedSymbol, selectedDate ?? ''), - queryFn: () => api.indexMinute(selectedSymbol, selectedDate ?? undefined), - enabled: !!selectedSymbol && !!selectedDate && hasMinuteCap, - placeholderData: (prev) => prev, - }) - const chartRows = useMemo(() => toOHLC(daily.data?.rows ?? []), [daily.data?.rows]) const selectedInfo = [...topRows, ...listRows].find(r => r.symbol === selectedSymbol) || daily.data?.index_info - const minuteRows: MinuteKlineRow[] = minute.data?.rows ?? [] - const selectedIdx = selectedDate ? chartRows.findIndex(r => r.date === selectedDate) : -1 - const prevClose = selectedIdx > 0 - ? chartRows[selectedIdx - 1].close - : chartRows.length >= 2 - ? chartRows[chartRows.length - 2].close - : undefined - useEffect(() => { setSelectedDate(null) setLinkedPrice(null) @@ -221,52 +201,18 @@ export function Indices() { )} {chartRows.length > 0 && ( -
-
- -
-
- {!hasMinuteCap ? ( -
- -
分时数据权限需 Pro+
-
升级套餐后可查看指数分时走势
-
- ) : ( - <> - {minute.isLoading &&
分时加载中…
} - {!minute.isLoading && minuteRows.length === 0 && ( -
- 暂无分时数据 -
- )} - {minuteRows.length > 0 && ( - - )} - - )} -
-
+ )}