mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 15:34:16 +08:00
96 lines
4.0 KiB
TypeScript
96 lines
4.0 KiB
TypeScript
/**
|
|
* 集中管理所有 React Query key。
|
|
*
|
|
* - 新增查询只需在此加一行,所有消费方自动引用。
|
|
* - SSE invalidation 基于 SSE_INVALIDATE_PREFIXES 列表,新增 key 无需改 useQuoteStream。
|
|
*/
|
|
|
|
// ===== Query Key 工厂 =====
|
|
|
|
export const QK = {
|
|
// 全局 / 共享 (Layout 预取)
|
|
capabilities: ['capabilities'] as const,
|
|
settings: ['settings'] as const,
|
|
endpoints: ['endpoints'] as const,
|
|
version: ['version'] as const,
|
|
preferences: ['preferences'] as const,
|
|
dataSources: ['data-sources'] as const,
|
|
quoteStatus: ['quote-status'] as const,
|
|
quoteInterval: ['quote-interval'] as const,
|
|
overviewMarket: (asOf?: string) => ['overview-market', asOf ?? 'latest'] as const,
|
|
indexQuotes: ['index-quotes'] as const,
|
|
indexList: ['index-list'] as const,
|
|
|
|
// Watchlist
|
|
watchlist: ['watchlist'] as const,
|
|
watchlistQuotes: ['watchlist-quotes'] as const,
|
|
watchlistEnriched: (ext?: string) => ['watchlist-enriched', ext] as const,
|
|
watchlistKlineBatch: (symbols: string) => ['watchlist-kline-batch', symbols] as const,
|
|
// 不用 watchlist- 前缀: 避免被 SSE quotes_updated 高频失效(expert 1s/pro 2s)
|
|
// 导致每次都拉 TickFlow 触限流。分时图用固定 refetchInterval 刷新即可。
|
|
minuteBatch: (symbols: string) => ['minute-batch', symbols] as const,
|
|
instrumentSearch: (q: string) => ['instrument-search', q] as const,
|
|
|
|
// Screener
|
|
screener: ['screener'] as const,
|
|
screenerStrategies: ['screener-strategies'] as const,
|
|
screenerCached: (ext?: string) => ['screener-cached', ext] as const,
|
|
screenerKlineBatch: (symbols: string) => ['screener-kline-batch', symbols] as const,
|
|
marketSnapshot: ['market-snapshot'] as const,
|
|
limitLadder: (asOf?: string) => ['limit-ladder', asOf] as const,
|
|
|
|
// Backtest
|
|
backtestStatus: ['backtest-status'] as const,
|
|
|
|
// Data / Pipeline
|
|
dataStatus: ['data-status'] as const,
|
|
pipelineJobs: ['pipeline-jobs'] as const,
|
|
pipelineJob: (id: string) => ['pipeline-job', id] as const,
|
|
extData: ['ext-data'] as const,
|
|
extDataRows: (id: string, date?: string, limit?: number, columns?: string) => ['ext-data-rows', id, date, limit, columns] as const,
|
|
analysisMenus: ['analysis-menus'] as const,
|
|
analysisMenu: (id: string) => ['analysis-menu', id] as const,
|
|
|
|
// Kline
|
|
kline: (symbol: string, start: string, end: string, extColumns?: string) =>
|
|
['kline', symbol, start, end, extColumns ?? ''] as const,
|
|
stockLevels: (symbol: string, days?: number) => ['stock-levels', symbol, days ?? 120] as const,
|
|
klineMinute: (symbol: string, date: string) =>
|
|
['kline-minute', symbol, date] as const,
|
|
indexDaily: (symbol: string, start: string, end: string) =>
|
|
['index-daily', symbol, start, end] as const,
|
|
indexMinute: (symbol: string, date: string) =>
|
|
['index-minute', symbol, date] as const,
|
|
|
|
// Schema
|
|
extDataSchemaAll: ['ext-data-schema-all'] as const,
|
|
tableSchema: (table: string) => ['table-schema', table] as const,
|
|
|
|
// Custom Signals
|
|
customSignals: ['custom-signals'] as const,
|
|
customSignalsOptions: ['custom-signals-options'] as const,
|
|
|
|
// Monitor (监控规则 + 触发记录)
|
|
monitorRules: ['monitor-rules'] as const,
|
|
monitorRuleOptions: ['monitor-rule-options'] as const,
|
|
alerts: (source?: string) => ['alerts', source ?? ''] as const,
|
|
|
|
// AI 大盘复盘
|
|
reviewReports: ['review-reports'] as const,
|
|
|
|
// 概念涨幅轮动矩阵
|
|
rpsRotation: (days: number) => ['rps-rotation', days] as const,
|
|
} as const
|
|
|
|
// ===== SSE 应该 invalidate 的 key 前缀列表 =====
|
|
// 新增需要 SSE 推送的查询,只需在此加一行
|
|
|
|
export const SSE_INVALIDATE_PREFIXES = [
|
|
'watchlist',
|
|
'quote-status',
|
|
'index-quotes',
|
|
'overview-market',
|
|
'limit-ladder',
|
|
'screener',
|
|
] as const
|