mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 23:44:16 +08:00
检测逻辑(复权因子分水岭): - 无 key / 乱填(连单只日K都拿不到) → none 档,不存 key,走 free-api 服务器 - 免费有效 key(有日K无复权) → free 档,存 key,走 free-api 服务器 - 付费 key(有复权) → starter/pro/expert,走 api.tickflow.org 主要改动: - save_tickflow_key 改为先探后存:无效 key 不持久化,前端提示「Key 无效」 - none/free 档统一走 TickFlow.free(),实时行情开关置灰 - tiers.yaml 新增 none 档,free 档补 kline.daily.batch - 注册 CapabilityDenied 全局 handler → 403(此前返 500) - /health mode 三态化,watchlist 无行情能力时提前 return - 看板页 none 档显示黄色升级提示(含邀请码超链接) 版本: 0.1.36
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
"""API 路由 — Phase 0 仅 /health 与 /api/capabilities。"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app import __version__
|
|
from app.tickflow import client as tf_client
|
|
from app.tickflow.policy import detect_capabilities, tier_label
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health() -> dict:
|
|
return {
|
|
"status": "ok",
|
|
"version": __version__,
|
|
# 三态: none(无key/无效) / free(免费key) / api_key(付费档)
|
|
"mode": tf_client.current_mode(),
|
|
}
|
|
|
|
|
|
@router.get("/api/capabilities")
|
|
def capabilities() -> dict:
|
|
"""前端用来决定哪些功能可用、哪些灰显。"""
|
|
capset = detect_capabilities()
|
|
return {
|
|
"label": tier_label(),
|
|
"capabilities": capset.to_dict(),
|
|
}
|
|
|
|
|
|
@router.post("/api/capabilities/redetect")
|
|
def redetect() -> dict:
|
|
"""用户在设置页"重新检测"按钮。"""
|
|
capset = detect_capabilities(force=True)
|
|
return {
|
|
"label": tier_label(),
|
|
"capabilities": capset.to_dict(),
|
|
}
|