看股功能更新
This commit is contained in:
@@ -7,6 +7,7 @@ import type {
|
||||
EventBacktestResponse,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
MarketOverview,
|
||||
PreviewResponse,
|
||||
ScreenerQueryItem,
|
||||
ScreenerRunRequest,
|
||||
@@ -160,6 +161,13 @@ export async function getStockPreview(
|
||||
return (await res.json()) as PreviewResponse;
|
||||
}
|
||||
|
||||
// ---------- 大盘总览(主页) ----------
|
||||
export async function getMarketOverview(): Promise<MarketOverview> {
|
||||
const res = await apiFetch('/api/market/overview');
|
||||
if (!res.ok) throw new ApiError(await readError(res, '获取大盘行情失败'), res.status);
|
||||
return (await res.json()) as MarketOverview;
|
||||
}
|
||||
|
||||
export async function getStocks(params: {
|
||||
search?: string;
|
||||
market?: string;
|
||||
|
||||
@@ -347,3 +347,31 @@ export interface EventBacktestResponse {
|
||||
trades: EventTrade[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
// ---------- 大盘总览(主页) ----------
|
||||
export interface IndexQuote {
|
||||
code: string; // 000001.SH / HKTECH / DJI
|
||||
name: string; // 上证指数 / 恒生科技 / 道琼斯
|
||||
region: 'cn' | 'hk' | 'us';
|
||||
close: number | null;
|
||||
change: number | null;
|
||||
pct_chg: number | null;
|
||||
trade_date: string | null; // 最近交易日(ISO)
|
||||
spark: number[]; // 近 N 日收盘(旧 -> 新)
|
||||
spark_dates: string[]; // 与 spark 对齐的交易日(YYYYMMDD)
|
||||
}
|
||||
|
||||
export interface MarketStats {
|
||||
trade_date: string | null;
|
||||
total_mv: number | null; // 沪深总市值(亿元)
|
||||
float_mv: number | null; // 沪深流通市值(亿元)
|
||||
amount: number | null; // 两市成交额(亿元)
|
||||
turnover: number | null; // 换手率 %(沪市口径)
|
||||
}
|
||||
|
||||
export interface MarketOverview {
|
||||
updated_at: string;
|
||||
indexes: IndexQuote[];
|
||||
stats: MarketStats | null;
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterLink } from 'vue-router';
|
||||
|
||||
// 首页:三大功能入口(看股 / 选股 / 回测)
|
||||
import MarketOverview from '@/components/MarketOverview.vue';
|
||||
|
||||
// 首页:大盘行情总览 + 三大功能入口(看股 / 选股 / 回测)
|
||||
const features = [
|
||||
{
|
||||
to: '/stocks',
|
||||
@@ -29,6 +31,8 @@ const features = [
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-5xl">
|
||||
<MarketOverview />
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<RouterLink
|
||||
v-for="f in features"
|
||||
|
||||
Reference in New Issue
Block a user