mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 17:54:15 +08:00
监控引擎 (backend): - MonitorRuleEngine 统一规则引擎,支持策略/信号/价格/行情四种类型 - JSONL 追加存储 (alert_store.py),支持分页 + 清理 - alert/monitor_rules CRUD API + seed 演示数据 - POST /api/kline/instruments/names 批量股票名称查询 - SSE strategy_alert 事件触发前端通知 前端通知体系: - AlertToast 自定义弹窗 (Framer Motion + AnimatePresence) - Web Audio API 合成音效 (12种预设,无需音频文件) - 侧边栏角标 (monitorBadge.ts) localStorage 持久化未读数 - pendingSeen 机制解决 markSeen/setCurrentTotal 竞态 - 系统设置页: 通知开关 + 最大条数 + 音效选择 - 菜单设置页: 角标数字开关 监控中心 (Monitor.tsx): - 双栏布局: 左侧实时告警列表 + 右侧规则管理 - RulesList 股票代码后显示中文名称 - RuleEditor 完整规则编辑器组件 - 告警支持查看详情 (StockPreviewDialog) Dashboard: - MonitorWidget: Top 10 实时告警卡片 Dev 页面: - 一键填充演示告警 + 规则 + 分钟探测 - 可视化 SSE 事件流查看 其他: - v0.1.19 → v0.1.28 (VERSION 从 pyproject.toml 读取) - dev.ps1/dev.sh 添加 --host 0.0.0.0 (局域网访问) - 修复 Screener.tsx presets.length 可选链 - README 截图表格更新 (6张) + 监控章节重写 - 删除 MinuteDataProbe 页面 (合并至 Dev)
87 lines
3.6 KiB
TypeScript
87 lines
3.6 KiB
TypeScript
import { createBrowserRouter, Navigate } from 'react-router-dom'
|
|
import { Layout } from './components/Layout'
|
|
import { Watchlist } from './pages/Watchlist'
|
|
import { Screener } from './pages/Screener'
|
|
import { Backtest } from './pages/Backtest'
|
|
import { Financials } from './pages/Financials'
|
|
import { Onboarding } from './pages/Onboarding'
|
|
import { Data } from './pages/Data'
|
|
import { Monitor } from './pages/Monitor'
|
|
import { Trading } from './pages/Trading'
|
|
import { Dashboard } from './pages/Dashboard'
|
|
import { AnalysisDetail } from './pages/AnalysisDetail'
|
|
import { ConceptAnalysis } from './pages/ConceptAnalysis'
|
|
import { IndustryAnalysis } from './pages/IndustryAnalysis'
|
|
import { StockAnalysis } from './pages/StockAnalysis'
|
|
import { LimitUpLadder } from './pages/LimitUpLadder'
|
|
import { Branding } from './pages/Branding'
|
|
import { Settings } from './pages/Settings'
|
|
import { Indices } from './pages/Indices'
|
|
import { Dev } from './pages/Dev'
|
|
import { useSettings } from './lib/useSharedQueries'
|
|
import { Logo } from './components/Logo'
|
|
|
|
// 首次使用守卫 —— 未完成向导则重定向到 /onboarding
|
|
// 只挂在根路由上;/onboarding 本身不被守卫,避免循环重定向。
|
|
// settings 由 Layout 预取,守卫判定不产生额外请求。
|
|
function OnboardingGuard({ children }: { children: React.ReactNode }) {
|
|
const settings = useSettings()
|
|
|
|
// 加载中:显示极简全屏占位,避免闪屏
|
|
if (settings.isLoading) {
|
|
return (
|
|
<div className="min-h-screen bg-base grid place-items-center">
|
|
<div className="flex flex-col items-center gap-3 text-muted">
|
|
<Logo size={28} className="text-foreground" />
|
|
<div className="text-xs">加载中…</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
// 查询出错或字段缺失时不拦截 —— 宁可放行,也不把用户卡在空白页
|
|
if (settings.data && settings.data.onboarding_completed === false) {
|
|
return <Navigate to="/onboarding" replace />
|
|
}
|
|
|
|
return <>{children}</>
|
|
}
|
|
|
|
export const router = createBrowserRouter([
|
|
{ path: '/onboarding', element: <Onboarding /> },
|
|
{
|
|
path: '/',
|
|
element: (
|
|
<OnboardingGuard>
|
|
<Layout />
|
|
</OnboardingGuard>
|
|
),
|
|
children: [
|
|
{ index: true, element: <Dashboard /> },
|
|
{ path: 'overview', element: <Navigate to="/" replace /> },
|
|
{ path: 'analysis', element: <Navigate to="/settings?tab=ext-pages" replace /> },
|
|
{ path: 'analysis/:menuId', element: <AnalysisDetail /> },
|
|
{ path: 'concept-analysis', element: <ConceptAnalysis /> },
|
|
{ path: 'industry-analysis', element: <IndustryAnalysis /> },
|
|
{ path: 'stock-analysis', element: <StockAnalysis /> },
|
|
{ path: 'watchlist', element: <Watchlist /> },
|
|
{ path: 'screener', element: <Screener /> },
|
|
{ path: 'backtest', element: <Backtest /> },
|
|
{ path: 'financials', element: <Financials /> },
|
|
{ path: 'data', element: <Data /> },
|
|
{ path: 'monitor', element: <Monitor /> },
|
|
{ path: 'trading', element: <Trading /> },
|
|
{ path: 'limit-ladder', element: <LimitUpLadder /> },
|
|
{ path: 'indices', element: <Indices /> },
|
|
{ path: 'branding', element: <Branding /> },
|
|
{ path: 'settings', element: <Settings /> },
|
|
// 隐藏路由:开发者工具(不暴露在菜单,仅供调试)
|
|
{ path: 'dev', element: <Dev /> },
|
|
// 旧路由兼容重定向
|
|
{ path: 'settings/keys', element: <Navigate to="/settings?tab=account" replace /> },
|
|
{ path: 'settings/ai', element: <Navigate to="/settings?tab=ai" replace /> },
|
|
{ path: 'settings/queries', element: <Navigate to="/settings?tab=queries" replace /> },
|
|
],
|
|
},
|
|
])
|