Initial AlphaPulse implementation: news crawler and Binance klines
- Backend (FastAPI, SQLAlchemy 2, Alembic): single-admin cookie auth, news/crawler/market APIs with SSE and WebSocket streaming - Crawler (Scrapy + Scrapy-Redis): wscn_news, wscn_live, cls_depth, cls_telegraph spiders, idempotent upserts with revisions, raw response archiving, per-source subprocess supervision, restart and backoff - Market worker: full-history Binance spot/USD-M kline backfill, realtime WS stream, hourly and on-reconnect catch-up - Frontend (Vue 3, Element Plus, UnoCSS, KLineChart): news feed, crawler console with live logs, Binance-style chart page - Deploy: docker compose, nginx site, migrate and daily backup scripts
This commit is contained in:
commit
aabc81ba5b
88 files changed
+12603
No files matched your search
@@ -0,0 +1,10 @@
|
||||
/** 订阅 SSE 事件;组件卸载时关闭。断线由浏览器自动重连 */
|
||||
export function useEventSource<T>(url: string, event: string, onMessage: (data: T) => void) {
|
||||
const connected = ref(false)
|
||||
const source = new EventSource(url)
|
||||
source.addEventListener("open", () => connected.value = true)
|
||||
source.addEventListener("error", () => connected.value = false)
|
||||
source.addEventListener(event, e => onMessage(JSON.parse((e as MessageEvent).data)))
|
||||
onBeforeUnmount(() => source.close())
|
||||
return { connected }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { listSources } from "@/apis/crawler"
|
||||
|
||||
const names = ref<Record<string, string>>({})
|
||||
|
||||
/** 来源 code → 中文名,全局只请求一次 */
|
||||
export function useSourceNames() {
|
||||
if (Object.keys(names.value).length === 0) {
|
||||
listSources().then((info) => {
|
||||
names.value = Object.fromEntries(info.sources.map(s => [s.code, s.name]))
|
||||
})
|
||||
}
|
||||
return names
|
||||
}
|
||||
Reference in new issue
Block a user