init
@@ -0,0 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db, err := sql.Open("mysql", "root:ttx2011@tcp(db.freeicu.top:32000)/ashare?charset=utf8mb4")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
// List tables
|
||||
rows, _ := db.Query("SHOW TABLES")
|
||||
defer rows.Close()
|
||||
fmt.Println("=== Tables ===")
|
||||
for rows.Next() {
|
||||
var name string
|
||||
rows.Scan(&name)
|
||||
fmt.Println(" ", name)
|
||||
}
|
||||
|
||||
// For each table, describe it and show sample
|
||||
tables := []string{}
|
||||
rows2, _ := db.Query("SHOW TABLES")
|
||||
for rows2.Next() {
|
||||
var name string
|
||||
rows2.Scan(&name)
|
||||
tables = append(tables, name)
|
||||
}
|
||||
rows2.Close()
|
||||
|
||||
for _, t := range tables {
|
||||
fmt.Printf("\n=== DESCRIBE %s ===\n", t)
|
||||
rows3, _ := db.Query(fmt.Sprintf("DESCRIBE %s", t))
|
||||
cols3, _ := rows3.Columns()
|
||||
fmt.Printf("%-20s %-30s %-5s %-5s\n", cols3[0], cols3[1], cols3[2], cols3[3])
|
||||
for rows3.Next() {
|
||||
var field, typ, null, key string
|
||||
var def, extra sql.NullString
|
||||
rows3.Scan(&field, &typ, &null, &key, &def, &extra)
|
||||
fmt.Printf("%-20s %-30s %-5s %-5s\n", field, typ, null, key)
|
||||
}
|
||||
rows3.Close()
|
||||
|
||||
fmt.Printf("\n=== Sample %s (LIMIT 3) ===\n", t)
|
||||
rows4, _ := db.Query(fmt.Sprintf("SELECT * FROM %s LIMIT 3", t))
|
||||
cols4, _ := rows4.Columns()
|
||||
fmt.Println(cols4)
|
||||
for rows4.Next() {
|
||||
vals := make([]interface{}, len(cols4))
|
||||
ptrs := make([]interface{}, len(cols4))
|
||||
for i := range vals {
|
||||
ptrs[i] = &vals[i]
|
||||
}
|
||||
rows4.Scan(ptrs...)
|
||||
for _, v := range vals {
|
||||
switch vt := v.(type) {
|
||||
case []byte:
|
||||
fmt.Printf("%-20s", string(vt))
|
||||
default:
|
||||
fmt.Printf("%-20v", vt)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
rows4.Close()
|
||||
|
||||
// Row count
|
||||
var cnt int
|
||||
db.QueryRow(fmt.Sprintf("SELECT COUNT(*) FROM %s", t)).Scan(&cnt)
|
||||
fmt.Printf("Total rows: %d\n", cnt)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dsn := "root:ttx2011@tcp(db.freeicu.top:32000)/?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
db, err := sql.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
if err := db.Ping(); err != nil {
|
||||
log.Fatalf("connect failed: %v", err)
|
||||
}
|
||||
fmt.Println("Connected to MySQL")
|
||||
|
||||
_, err = db.Exec("CREATE DATABASE IF NOT EXISTS ashareview DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci")
|
||||
if err != nil {
|
||||
log.Fatalf("create database failed: %v", err)
|
||||
}
|
||||
fmt.Println("Database ashareview created")
|
||||
|
||||
// Reconnect with database selected
|
||||
dsn2 := "root:ttx2011@tcp(db.freeicu.top:32000)/ashareview?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
db2, err := sql.Open("mysql", dsn2)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db2.Close()
|
||||
|
||||
_, err = db2.Exec(`
|
||||
CREATE TABLE IF NOT EXISTS a_stock_daily (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
stock_code VARCHAR(10) NOT NULL COMMENT '股票代码',
|
||||
stock_name VARCHAR(50) NOT NULL COMMENT '股票名称',
|
||||
trade_date DATE NOT NULL COMMENT '交易日期',
|
||||
open_price DECIMAL(10,2) COMMENT '开盘价',
|
||||
close_price DECIMAL(10,2) COMMENT '收盘价',
|
||||
high_price DECIMAL(10,2) COMMENT '最高价',
|
||||
low_price DECIMAL(10,2) COMMENT '最低价',
|
||||
volume BIGINT COMMENT '成交量',
|
||||
amount DECIMAL(18,2) COMMENT '成交额',
|
||||
change_pct DECIMAL(10,4) COMMENT '涨跌幅(%)',
|
||||
turnover_rate DECIMAL(10,4) COMMENT '换手率(%)',
|
||||
INDEX idx_trade_date (trade_date),
|
||||
INDEX idx_stock_code (stock_code)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='A股日线行情'`)
|
||||
if err != nil {
|
||||
log.Fatalf("create table failed: %v", err)
|
||||
}
|
||||
fmt.Println("Table a_stock_daily created")
|
||||
|
||||
_, err = db2.Exec(`
|
||||
INSERT INTO a_stock_daily (stock_code, stock_name, trade_date, open_price, close_price, high_price, low_price, volume, amount, change_pct, turnover_rate) VALUES
|
||||
('000001', '平安银行', '2026-05-09', 12.50, 12.85, 12.90, 12.40, 85000000, 1085000000.00, 2.8000, 4.3800),
|
||||
('000002', '万科A', '2026-05-09', 8.20, 7.95, 8.30, 7.85, 120000000, 960000000.00, -3.0500, 6.2500),
|
||||
('000063', '中兴通讯', '2026-05-09', 35.60, 36.20, 36.50, 35.30, 45000000, 1620000000.00, 1.6900, 3.1200),
|
||||
('000333', '美的集团', '2026-05-09', 68.00, 69.50, 69.80, 67.50, 22000000, 1520000000.00, 2.2100, 2.8500),
|
||||
('000338', '潍柴动力', '2026-05-09', 15.80, 15.45, 15.90, 15.30, 38000000, 585000000.00, -2.2200, 3.6700),
|
||||
('000425', '徐工机械', '2026-05-09', 7.50, 7.62, 7.68, 7.45, 55000000, 418000000.00, 1.6000, 4.1200),
|
||||
('000568', '泸州老窖', '2026-05-09', 185.00, 190.50, 191.00, 183.50, 8000000, 1520000000.00, 2.9700, 1.5600),
|
||||
('000625', '长安汽车', '2026-05-09', 14.20, 13.80, 14.35, 13.70, 65000000, 900000000.00, -2.8200, 5.3800),
|
||||
('000651', '格力电器', '2026-05-09', 42.30, 43.10, 43.50, 42.00, 18000000, 776000000.00, 1.8900, 2.1000),
|
||||
('000725', '京东方A', '2026-05-09', 4.80, 4.95, 4.98, 4.75, 200000000, 988000000.00, 3.1300, 5.9200),
|
||||
('000858', '五粮液', '2026-05-09', 156.00, 160.20, 161.00, 155.00, 12000000, 1920000000.00, 2.6900, 1.8300),
|
||||
('000895', '双汇发展', '2026-05-09', 26.50, 26.20, 26.60, 26.10, 15000000, 393000000.00, -1.1300, 2.4500),
|
||||
('000938', '紫光股份', '2026-05-09', 28.30, 29.50, 29.80, 28.00, 25000000, 738000000.00, 4.2400, 3.8900),
|
||||
('002001', '新 和 成', '2026-05-09', 22.10, 21.80, 22.20, 21.60, 18000000, 392000000.00, -1.3600, 2.7800),
|
||||
('002007', '华兰生物', '2026-05-09', 18.60, 19.20, 19.40, 18.40, 28000000, 538000000.00, 3.2300, 3.5600),
|
||||
('002024', '苏宁易购', '2026-05-09', 2.10, 2.05, 2.12, 2.03, 150000000, 308000000.00, -2.3800, 7.2500),
|
||||
('002027', '分众传媒', '2026-05-09', 6.80, 6.95, 7.00, 6.75, 90000000, 626000000.00, 2.2100, 4.8300),
|
||||
('002142', '宁波银行', '2026-05-09', 25.80, 26.30, 26.50, 25.60, 20000000, 526000000.00, 1.9400, 2.9200),
|
||||
('002230', '科大讯飞', '2026-05-09', 52.00, 54.80, 55.20, 51.50, 35000000, 1920000000.00, 5.3800, 4.1200),
|
||||
('002304', '洋河股份', '2026-05-09', 98.00, 96.50, 98.50, 96.00, 10000000, 970000000.00, -1.5300, 1.6800),
|
||||
('002352', '顺丰控股', '2026-05-09', 42.50, 41.80, 42.80, 41.50, 15000000, 627000000.00, -1.6500, 2.3500),
|
||||
('002415', '海康威视', '2026-05-09', 35.20, 36.80, 37.00, 35.00, 50000000, 1840000000.00, 4.5500, 3.7800),
|
||||
('002475', '立讯精密', '2026-05-09', 38.50, 39.60, 39.80, 38.20, 28000000, 1110000000.00, 2.8600, 3.4500),
|
||||
('002493', '荣盛石化', '2026-05-09', 9.80, 9.55, 9.85, 9.50, 60000000, 576000000.00, -2.5500, 4.6800),
|
||||
('002594', '比亚迪', '2026-05-09', 310.00, 325.00, 328.00, 308.00, 15000000, 4870000000.00, 4.8400, 2.5600),
|
||||
('002714', '牧原股份', '2026-05-09', 42.00, 40.80, 42.30, 40.50, 25000000, 1020000000.00, -2.8600, 3.1200),
|
||||
('002841', '视源股份', '2026-05-09', 75.00, 76.80, 77.20, 74.50, 8000000, 614000000.00, 2.4000, 2.1500),
|
||||
('003816', '中国广核', '2026-05-09', 3.80, 3.75, 3.82, 3.73, 80000000, 301000000.00, -1.3200, 5.6200),
|
||||
('600000', '浦发银行', '2026-05-09', 8.50, 8.35, 8.55, 8.30, 70000000, 585000000.00, -1.7600, 4.5200),
|
||||
('600009', '上海机场', '2026-05-09', 38.50, 39.80, 40.00, 38.20, 12000000, 478000000.00, 3.3800, 2.3800),
|
||||
('600016', '民生银行', '2026-05-09', 4.90, 4.85, 4.92, 4.82, 90000000, 437000000.00, -1.0200, 5.1200),
|
||||
('600019', '宝钢股份', '2026-05-09', 7.20, 7.35, 7.40, 7.15, 80000000, 588000000.00, 2.0800, 4.3500),
|
||||
('600028', '中国石化', '2026-05-09', 6.50, 6.62, 6.65, 6.48, 120000000, 795000000.00, 1.8500, 3.9800),
|
||||
('600030', '中信证券', '2026-05-09', 22.80, 23.50, 23.60, 22.60, 40000000, 940000000.00, 3.0700, 3.2800),
|
||||
('600036', '招商银行', '2026-05-09', 38.50, 39.20, 39.50, 38.20, 25000000, 980000000.00, 1.8200, 2.5600),
|
||||
('600048', '保利发展', '2026-05-09', 11.80, 11.50, 11.85, 11.40, 45000000, 518000000.00, -2.5400, 4.8600),
|
||||
('600050', '中国联通', '2026-05-09', 5.80, 5.92, 5.95, 5.78, 100000000, 592000000.00, 2.0700, 6.3500),
|
||||
('600104', '上汽集团', '2026-05-09', 15.20, 14.80, 15.30, 14.70, 35000000, 518000000.00, -2.6300, 3.9200),
|
||||
('600276', '恒瑞医药', '2026-05-09', 48.50, 50.20, 50.50, 48.00, 20000000, 1000000000.00, 3.5100, 2.8600),
|
||||
('600309', '万华化学', '2026-05-09', 85.00, 83.50, 85.50, 83.00, 12000000, 1002000000.00, -1.7600, 2.3500),
|
||||
('600519', '贵州茅台', '2026-05-09', 1750.00, 1795.00, 1800.00, 1740.00, 5000000, 8970000000.00, 2.5700, 0.9800),
|
||||
('600585', '海螺水泥', '2026-05-09', 25.80, 25.20, 25.90, 25.10, 18000000, 454000000.00, -2.3300, 3.1500),
|
||||
('600588', '用友网络', '2026-05-09', 12.50, 11.80, 12.60, 11.70, 30000000, 354000000.00, -5.6000, 4.2800),
|
||||
('600690', '海尔智家', '2026-05-09', 28.50, 29.20, 29.40, 28.30, 22000000, 642000000.00, 2.4600, 2.9800),
|
||||
('600809', '山西汾酒', '2026-05-09', 230.00, 238.00, 240.00, 228.00, 6000000, 1428000000.00, 3.4800, 1.2500),
|
||||
('600887', '伊利股份', '2026-05-09', 32.00, 32.80, 33.00, 31.80, 25000000, 820000000.00, 2.5000, 3.1800),
|
||||
('600893', '航发动力', '2026-05-09', 42.50, 43.60, 44.00, 42.20, 10000000, 436000000.00, 2.5900, 2.6500),
|
||||
('600900', '长江电力', '2026-05-09', 28.50, 28.80, 28.90, 28.40, 20000000, 576000000.00, 1.0500, 1.8500),
|
||||
('601012', '隆基绿能', '2026-05-09', 18.50, 17.80, 18.60, 17.60, 45000000, 801000000.00, -3.7800, 4.5200),
|
||||
('601088', '中国神华', '2026-05-09', 38.00, 38.50, 38.60, 37.80, 15000000, 578000000.00, 1.3200, 2.1500),
|
||||
('601166', '兴业银行', '2026-05-09', 20.50, 21.00, 21.10, 20.30, 30000000, 630000000.00, 2.4400, 3.5600),
|
||||
('601318', '中国平安', '2026-05-09', 52.00, 53.50, 53.80, 51.80, 35000000, 1870000000.00, 2.8800, 3.0200),
|
||||
('601398', '工商银行', '2026-05-09', 5.80, 5.90, 5.92, 5.78, 150000000, 885000000.00, 1.7200, 5.3800),
|
||||
('601628', '中国人寿', '2026-05-09', 35.00, 34.20, 35.20, 34.00, 25000000, 855000000.00, -2.2900, 3.1200),
|
||||
('601668', '中国建筑', '2026-05-09', 6.20, 6.35, 6.38, 6.18, 80000000, 508000000.00, 2.4200, 5.6800),
|
||||
('601688', '华泰证券', '2026-05-09', 18.50, 19.20, 19.30, 18.40, 30000000, 576000000.00, 3.7800, 3.2500),
|
||||
('601728', '中国电信', '2026-05-09', 7.20, 7.35, 7.38, 7.18, 90000000, 662000000.00, 2.0800, 5.9200),
|
||||
('601766', '中国中车', '2026-05-09', 8.20, 7.98, 8.25, 7.92, 60000000, 479000000.00, -2.6800, 4.8500),
|
||||
('601857', '中国石油', '2026-05-09', 8.80, 8.95, 8.98, 8.75, 100000000, 895000000.00, 1.7000, 4.1200),
|
||||
('601888', '中国中免', '2026-05-09', 85.00, 82.50, 85.50, 82.00, 12000000, 990000000.00, -2.9400, 2.5600),
|
||||
('601899', '紫金矿业', '2026-05-09', 18.50, 19.20, 19.30, 18.30, 50000000, 960000000.00, 3.7800, 3.8500),
|
||||
('601919', '中远海控', '2026-05-09', 15.00, 14.50, 15.10, 14.40, 40000000, 580000000.00, -3.3300, 4.3500),
|
||||
('601985', '中国核电', '2026-05-09', 9.80, 10.10, 10.15, 9.75, 50000000, 505000000.00, 3.0600, 4.2800),
|
||||
('603259', '药明康德', '2026-05-09', 62.00, 64.50, 65.00, 61.50, 15000000, 968000000.00, 4.0300, 3.1200),
|
||||
('603288', '海天味业', '2026-05-09', 38.50, 37.80, 38.60, 37.50, 12000000, 454000000.00, -1.8200, 2.1500),
|
||||
('603501', '韦尔股份', '2026-05-09', 105.00, 109.50, 110.00, 104.00, 8000000, 876000000.00, 4.2900, 2.9800),
|
||||
('603986', '兆易创新', '2026-05-09', 120.00, 118.00, 121.00, 117.50, 6000000, 708000000.00, -1.6700, 2.3500),
|
||||
('688981', '中芯国际', '2026-05-09', 85.00, 88.50, 89.00, 84.50, 18000000, 1590000000.00, 4.1200, 3.5600)
|
||||
`)
|
||||
if err != nil {
|
||||
log.Fatalf("insert data failed: %v", err)
|
||||
}
|
||||
fmt.Println("Sample data inserted (65 rows)")
|
||||
fmt.Println("Done!")
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type DBConfig struct {
|
||||
Host string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
DBName string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
DB DBConfig
|
||||
Server struct {
|
||||
Port string
|
||||
}
|
||||
}
|
||||
|
||||
func Load() *Config {
|
||||
cfg := &Config{}
|
||||
|
||||
cfg.DB.Host = getEnv("DB_HOST", "db.freeicu.top")
|
||||
cfg.DB.Port = getEnv("DB_PORT", "32000")
|
||||
cfg.DB.User = getEnv("DB_USER", "root")
|
||||
cfg.DB.Password = getEnv("DB_PASSWORD", "ttx2011")
|
||||
cfg.DB.DBName = getEnv("DB_NAME", "ashare")
|
||||
cfg.Server.Port = getEnv("SERVER_PORT", "8080")
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (c *DBConfig) DSN() string {
|
||||
return fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
c.User, c.Password, c.Host, c.Port, c.DBName)
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
module ashareview-server
|
||||
|
||||
go 1.26.2
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.12.0
|
||||
gorm.io/driver/mysql v1.6.0
|
||||
gorm.io/gorm v1.31.1
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.15.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||
golang.org/x/arch v0.22.0 // indirect
|
||||
golang.org/x/crypto v0.48.0 // indirect
|
||||
golang.org/x/net v0.51.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
)
|
||||
@@ -0,0 +1,101 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
|
||||
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
|
||||
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
|
||||
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
|
||||
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
|
||||
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
|
||||
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
|
||||
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||
@@ -0,0 +1,39 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"ashareview-server/service"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type DashboardHandler struct {
|
||||
svc *service.DashboardService
|
||||
}
|
||||
|
||||
func NewDashboardHandler(svc *service.DashboardService) *DashboardHandler {
|
||||
return &DashboardHandler{svc: svc}
|
||||
}
|
||||
|
||||
func (h *DashboardHandler) GetSummary(c *gin.Context) {
|
||||
summary, err := h.svc.GetSummary()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": summary})
|
||||
}
|
||||
|
||||
func (h *DashboardHandler) GetDailySummary(c *gin.Context) {
|
||||
days, _ := strconv.Atoi(c.DefaultQuery("days", "30"))
|
||||
if days <= 0 || days > 365 {
|
||||
days = 30
|
||||
}
|
||||
data, err := h.svc.GetDailySummary(days)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"data": data})
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"ashareview-server/config"
|
||||
"ashareview-server/handler"
|
||||
"ashareview-server/repository"
|
||||
"ashareview-server/router"
|
||||
"ashareview-server/service"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
|
||||
db, err := gorm.Open(mysql.Open(cfg.DB.DSN()), &gorm.Config{})
|
||||
if err != nil {
|
||||
log.Fatalf("failed to connect database: %v", err)
|
||||
}
|
||||
fmt.Println("Database connected successfully")
|
||||
|
||||
stockRepo := repository.NewStockRepo(db)
|
||||
dashboardSvc := service.NewDashboardService(stockRepo)
|
||||
dashboardHandler := handler.NewDashboardHandler(dashboardSvc)
|
||||
|
||||
r := gin.Default()
|
||||
router.Setup(r, dashboardHandler)
|
||||
|
||||
addr := fmt.Sprintf(":%s", cfg.Server.Port)
|
||||
fmt.Printf("Server running on http://localhost%s\n", addr)
|
||||
if err := r.Run(addr); err != nil {
|
||||
log.Fatalf("failed to start server: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package model
|
||||
|
||||
type StockDaily struct {
|
||||
ID int `gorm:"primaryKey" json:"id"`
|
||||
Code string `gorm:"column:code;type:varchar(10)" json:"code"`
|
||||
Date string `gorm:"column:date;type:date" json:"date"`
|
||||
Open float64 `gorm:"column:open" json:"open"`
|
||||
Close float64 `gorm:"column:close" json:"close"`
|
||||
High float64 `gorm:"column:high" json:"high"`
|
||||
Low float64 `gorm:"column:low" json:"low"`
|
||||
Volume float64 `gorm:"column:volume" json:"volume"`
|
||||
Turnover float64 `gorm:"column:turnover" json:"turnover"`
|
||||
Amplitude float64 `gorm:"column:amplitude" json:"amplitude"`
|
||||
PctChange float64 `gorm:"column:pct_change" json:"pct_change"`
|
||||
Change float64 `gorm:"column:change" json:"change"`
|
||||
TurnoverRate float64 `gorm:"column:turnover_rate" json:"turnover_rate"`
|
||||
}
|
||||
|
||||
func (StockDaily) TableName() string {
|
||||
return "stock_daily"
|
||||
}
|
||||
|
||||
type StockInfo struct {
|
||||
Code string `gorm:"primaryKey;column:code;type:varchar(10)" json:"code"`
|
||||
Name string `gorm:"column:name;type:varchar(50)" json:"name"`
|
||||
IpoDate string `gorm:"column:ipo_date;type:date" json:"ipo_date"`
|
||||
}
|
||||
|
||||
func (StockInfo) TableName() string {
|
||||
return "stock_info"
|
||||
}
|
||||
|
||||
type StockRank struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
PctChange float64 `json:"pct_change"`
|
||||
Close float64 `json:"close"`
|
||||
}
|
||||
|
||||
type DailySummary struct {
|
||||
Date string `json:"date"`
|
||||
TotalStocks int64 `json:"total_stocks"`
|
||||
UpCount int64 `json:"up_count"`
|
||||
DownCount int64 `json:"down_count"`
|
||||
FlatCount int64 `json:"flat_count"`
|
||||
TotalTurnover float64 `json:"total_turnover"`
|
||||
AvgPctChange float64 `json:"avg_pct_change"`
|
||||
}
|
||||
|
||||
type DashboardSummary struct {
|
||||
TotalStocks int64 `json:"total_stocks"`
|
||||
UpCount int64 `json:"up_count"`
|
||||
DownCount int64 `json:"down_count"`
|
||||
FlatCount int64 `json:"flat_count"`
|
||||
TotalTurnover float64 `json:"total_turnover"`
|
||||
AvgPctChange float64 `json:"avg_pct_change"`
|
||||
TopGainers []StockRank `json:"top_gainers"`
|
||||
TopLosers []StockRank `json:"top_losers"`
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"ashareview-server/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StockRepo struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewStockRepo(db *gorm.DB) *StockRepo {
|
||||
return &StockRepo{db: db}
|
||||
}
|
||||
|
||||
func (r *StockRepo) GetLatestTradeDate() (string, error) {
|
||||
var result struct {
|
||||
MaxDate string
|
||||
}
|
||||
err := r.db.Model(&model.StockDaily{}).
|
||||
Select("MAX(date) as max_date").
|
||||
Scan(&result).Error
|
||||
return result.MaxDate, err
|
||||
}
|
||||
|
||||
func (r *StockRepo) GetSummaryByDate(date string) (*model.DashboardSummary, error) {
|
||||
summary := &model.DashboardSummary{}
|
||||
|
||||
r.db.Model(&model.StockDaily{}).
|
||||
Where("date = ?", date).
|
||||
Count(&summary.TotalStocks)
|
||||
|
||||
r.db.Model(&model.StockDaily{}).
|
||||
Where("date = ? AND pct_change > 0", date).
|
||||
Count(&summary.UpCount)
|
||||
|
||||
r.db.Model(&model.StockDaily{}).
|
||||
Where("date = ? AND pct_change < 0", date).
|
||||
Count(&summary.DownCount)
|
||||
|
||||
r.db.Model(&model.StockDaily{}).
|
||||
Where("date = ? AND pct_change = 0", date).
|
||||
Count(&summary.FlatCount)
|
||||
|
||||
var amtResult struct {
|
||||
Total float64
|
||||
Avg float64
|
||||
}
|
||||
r.db.Model(&model.StockDaily{}).
|
||||
Where("date = ?", date).
|
||||
Select("COALESCE(SUM(turnover), 0) as total, COALESCE(AVG(pct_change), 0) as avg").
|
||||
Scan(&amtResult)
|
||||
summary.TotalTurnover = amtResult.Total
|
||||
summary.AvgPctChange = amtResult.Avg
|
||||
|
||||
r.db.Table("stock_daily as sd").
|
||||
Select("sd.code, si.name, sd.pct_change, sd.close").
|
||||
Joins("LEFT JOIN stock_info si ON sd.code = si.code").
|
||||
Where("sd.date = ? AND sd.pct_change IS NOT NULL", date).
|
||||
Order("sd.pct_change DESC").
|
||||
Limit(5).
|
||||
Find(&summary.TopGainers)
|
||||
|
||||
r.db.Table("stock_daily as sd").
|
||||
Select("sd.code, si.name, sd.pct_change, sd.close").
|
||||
Joins("LEFT JOIN stock_info si ON sd.code = si.code").
|
||||
Where("sd.date = ? AND sd.pct_change IS NOT NULL", date).
|
||||
Order("sd.pct_change ASC").
|
||||
Limit(5).
|
||||
Find(&summary.TopLosers)
|
||||
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
func (r *StockRepo) GetDailySummary(days int) ([]model.DailySummary, error) {
|
||||
var result []model.DailySummary
|
||||
|
||||
sub := r.db.Model(&model.StockDaily{}).
|
||||
Select("date, "+
|
||||
"COUNT(*) as total_stocks, "+
|
||||
"SUM(CASE WHEN pct_change > 0 THEN 1 ELSE 0 END) as up_count, "+
|
||||
"SUM(CASE WHEN pct_change < 0 THEN 1 ELSE 0 END) as down_count, "+
|
||||
"SUM(CASE WHEN pct_change = 0 THEN 1 ELSE 0 END) as flat_count, "+
|
||||
"COALESCE(SUM(turnover), 0) as total_turnover, "+
|
||||
"COALESCE(AVG(pct_change), 0) as avg_pct_change").
|
||||
Where("date >= (SELECT MAX(date) FROM stock_daily) - INTERVAL ? DAY", days-1).
|
||||
Group("date")
|
||||
|
||||
err := r.db.Table("(?) as d", sub).
|
||||
Order("d.date ASC").
|
||||
Find(&result).Error
|
||||
|
||||
return result, err
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"ashareview-server/handler"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Setup(r *gin.Engine, dh *handler.DashboardHandler) {
|
||||
api := r.Group("/api")
|
||||
{
|
||||
api.GET("/dashboard/summary", dh.GetSummary)
|
||||
api.GET("/dashboard/daily", dh.GetDailySummary)
|
||||
}
|
||||
|
||||
// Serve frontend static files
|
||||
staticDir := "static"
|
||||
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
|
||||
// Try relative to executable
|
||||
exePath, _ := os.Executable()
|
||||
staticDir = filepath.Join(filepath.Dir(exePath), "static")
|
||||
}
|
||||
|
||||
r.Static("/assets", filepath.Join(staticDir, "assets"))
|
||||
r.StaticFile("/vite.svg", filepath.Join(staticDir, "vite.svg"))
|
||||
|
||||
// SPA fallback: all non-API routes serve index.html
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
path := c.Request.URL.Path
|
||||
if len(path) < 4 || path[:4] != "/api" {
|
||||
indexPath := filepath.Join(staticDir, "index.html")
|
||||
c.File(indexPath)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "not found"})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"ashareview-server/model"
|
||||
"ashareview-server/repository"
|
||||
)
|
||||
|
||||
type DashboardService struct {
|
||||
repo *repository.StockRepo
|
||||
}
|
||||
|
||||
func NewDashboardService(repo *repository.StockRepo) *DashboardService {
|
||||
return &DashboardService{repo: repo}
|
||||
}
|
||||
|
||||
func (s *DashboardService) GetSummary() (*model.DashboardSummary, error) {
|
||||
date, err := s.repo.GetLatestTradeDate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.GetSummaryByDate(date)
|
||||
}
|
||||
|
||||
func (s *DashboardService) GetDailySummary(days int) ([]model.DailySummary, error) {
|
||||
return s.repo.GetDailySummary(days)
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
CREATE DATABASE IF NOT EXISTS ashareview DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
USE ashareview;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS a_stock_daily (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
stock_code VARCHAR(10) NOT NULL COMMENT '股票代码',
|
||||
stock_name VARCHAR(50) NOT NULL COMMENT '股票名称',
|
||||
trade_date DATE NOT NULL COMMENT '交易日期',
|
||||
open_price DECIMAL(10,2) COMMENT '开盘价',
|
||||
close_price DECIMAL(10,2) COMMENT '收盘价',
|
||||
high_price DECIMAL(10,2) COMMENT '最高价',
|
||||
low_price DECIMAL(10,2) COMMENT '最低价',
|
||||
volume BIGINT COMMENT '成交量',
|
||||
amount DECIMAL(18,2) COMMENT '成交额',
|
||||
change_pct DECIMAL(10,4) COMMENT '涨跌幅(%)',
|
||||
turnover_rate DECIMAL(10,4) COMMENT '换手率(%)',
|
||||
INDEX idx_trade_date (trade_date),
|
||||
INDEX idx_stock_code (stock_code)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='A股日线行情';
|
||||
|
||||
INSERT INTO a_stock_daily (stock_code, stock_name, trade_date, open_price, close_price, high_price, low_price, volume, amount, change_pct, turnover_rate) VALUES
|
||||
('000001', '平安银行', '2026-05-09', 12.50, 12.85, 12.90, 12.40, 85000000, 1085000000.00, 2.8000, 4.3800),
|
||||
('000002', '万科A', '2026-05-09', 8.20, 7.95, 8.30, 7.85, 120000000, 960000000.00, -3.0500, 6.2500),
|
||||
('000063', '中兴通讯', '2026-05-09', 35.60, 36.20, 36.50, 35.30, 45000000, 1620000000.00, 1.6900, 3.1200),
|
||||
('000333', '美的集团', '2026-05-09', 68.00, 69.50, 69.80, 67.50, 22000000, 1520000000.00, 2.2100, 2.8500),
|
||||
('000338', '潍柴动力', '2026-05-09', 15.80, 15.45, 15.90, 15.30, 38000000, 585000000.00, -2.2200, 3.6700),
|
||||
('000425', '徐工机械', '2026-05-09', 7.50, 7.62, 7.68, 7.45, 55000000, 418000000.00, 1.6000, 4.1200),
|
||||
('000568', '泸州老窖', '2026-05-09', 185.00, 190.50, 191.00, 183.50, 8000000, 1520000000.00, 2.9700, 1.5600),
|
||||
('000625', '长安汽车', '2026-05-09', 14.20, 13.80, 14.35, 13.70, 65000000, 900000000.00, -2.8200, 5.3800),
|
||||
('000651', '格力电器', '2026-05-09', 42.30, 43.10, 43.50, 42.00, 18000000, 776000000.00, 1.8900, 2.1000),
|
||||
('000725', '京东方A', '2026-05-09', 4.80, 4.95, 4.98, 4.75, 200000000, 988000000.00, 3.1300, 5.9200),
|
||||
('000858', '五粮液', '2026-05-09', 156.00, 160.20, 161.00, 155.00, 12000000, 1920000000.00, 2.6900, 1.8300),
|
||||
('000895', '双汇发展', '2026-05-09', 26.50, 26.20, 26.60, 26.10, 15000000, 393000000.00, -1.1300, 2.4500),
|
||||
('000938', '紫光股份', '2026-05-09', 28.30, 29.50, 29.80, 28.00, 25000000, 738000000.00, 4.2400, 3.8900),
|
||||
('002001', '新 和 成', '2026-05-09', 22.10, 21.80, 22.20, 21.60, 18000000, 392000000.00, -1.3600, 2.7800),
|
||||
('002007', '华兰生物', '2026-05-09', 18.60, 19.20, 19.40, 18.40, 28000000, 538000000.00, 3.2300, 3.5600),
|
||||
('002024', '苏宁易购', '2026-05-09', 2.10, 2.05, 2.12, 2.03, 150000000, 308000000.00, -2.3800, 7.2500),
|
||||
('002027', '分众传媒', '2026-05-09', 6.80, 6.95, 7.00, 6.75, 90000000, 626000000.00, 2.2100, 4.8300),
|
||||
('002142', '宁波银行', '2026-05-09', 25.80, 26.30, 26.50, 25.60, 20000000, 526000000.00, 1.9400, 2.9200),
|
||||
('002230', '科大讯飞', '2026-05-09', 52.00, 54.80, 55.20, 51.50, 35000000, 1920000000.00, 5.3800, 4.1200),
|
||||
('002304', '洋河股份', '2026-05-09', 98.00, 96.50, 98.50, 96.00, 10000000, 970000000.00, -1.5300, 1.6800),
|
||||
('002352', '顺丰控股', '2026-05-09', 42.50, 41.80, 42.80, 41.50, 15000000, 627000000.00, -1.6500, 2.3500),
|
||||
('002415', '海康威视', '2026-05-09', 35.20, 36.80, 37.00, 35.00, 50000000, 1840000000.00, 4.5500, 3.7800),
|
||||
('002475', '立讯精密', '2026-05-09', 38.50, 39.60, 39.80, 38.20, 28000000, 1110000000.00, 2.8600, 3.4500),
|
||||
('002493', '荣盛石化', '2026-05-09', 9.80, 9.55, 9.85, 9.50, 60000000, 576000000.00, -2.5500, 4.6800),
|
||||
('002594', '比亚迪', '2026-05-09', 310.00, 325.00, 328.00, 308.00, 15000000, 4870000000.00, 4.8400, 2.5600),
|
||||
('002714', '牧原股份', '2026-05-09', 42.00, 40.80, 42.30, 40.50, 25000000, 1020000000.00, -2.8600, 3.1200),
|
||||
('002841', '视源股份', '2026-05-09', 75.00, 76.80, 77.20, 74.50, 8000000, 614000000.00, 2.4000, 2.1500),
|
||||
('003816', '中国广核', '2026-05-09', 3.80, 3.75, 3.82, 3.73, 80000000, 301000000.00, -1.3200, 5.6200),
|
||||
('600000', '浦发银行', '2026-05-09', 8.50, 8.35, 8.55, 8.30, 70000000, 585000000.00, -1.7600, 4.5200),
|
||||
('600009', '上海机场', '2026-05-09', 38.50, 39.80, 40.00, 38.20, 12000000, 478000000.00, 3.3800, 2.3800),
|
||||
('600016', '民生银行', '2026-05-09', 4.90, 4.85, 4.92, 4.82, 90000000, 437000000.00, -1.0200, 5.1200),
|
||||
('600019', '宝钢股份', '2026-05-09', 7.20, 7.35, 7.40, 7.15, 80000000, 588000000.00, 2.0800, 4.3500),
|
||||
('600028', '中国石化', '2026-05-09', 6.50, 6.62, 6.65, 6.48, 120000000, 795000000.00, 1.8500, 3.9800),
|
||||
('600030', '中信证券', '2026-05-09', 22.80, 23.50, 23.60, 22.60, 40000000, 940000000.00, 3.0700, 3.2800),
|
||||
('600036', '招商银行', '2026-05-09', 38.50, 39.20, 39.50, 38.20, 25000000, 980000000.00, 1.8200, 2.5600),
|
||||
('600048', '保利发展', '2026-05-09', 11.80, 11.50, 11.85, 11.40, 45000000, 518000000.00, -2.5400, 4.8600),
|
||||
('600050', '中国联通', '2026-05-09', 5.80, 5.92, 5.95, 5.78, 100000000, 592000000.00, 2.0700, 6.3500),
|
||||
('600104', '上汽集团', '2026-05-09', 15.20, 14.80, 15.30, 14.70, 35000000, 518000000.00, -2.6300, 3.9200),
|
||||
('600276', '恒瑞医药', '2026-05-09', 48.50, 50.20, 50.50, 48.00, 20000000, 1000000000.00, 3.5100, 2.8600),
|
||||
('600309', '万华化学', '2026-05-09', 85.00, 83.50, 85.50, 83.00, 12000000, 1002000000.00, -1.7600, 2.3500),
|
||||
('600519', '贵州茅台', '2026-05-09', 1750.00, 1795.00, 1800.00, 1740.00, 5000000, 8970000000.00, 2.5700, 0.9800),
|
||||
('600585', '海螺水泥', '2026-05-09', 25.80, 25.20, 25.90, 25.10, 18000000, 454000000.00, -2.3300, 3.1500),
|
||||
('600588', '用友网络', '2026-05-09', 12.50, 11.80, 12.60, 11.70, 30000000, 354000000.00, -5.6000, 4.2800),
|
||||
('600690', '海尔智家', '2026-05-09', 28.50, 29.20, 29.40, 28.30, 22000000, 642000000.00, 2.4600, 2.9800),
|
||||
('600809', '山西汾酒', '2026-05-09', 230.00, 238.00, 240.00, 228.00, 6000000, 1428000000.00, 3.4800, 1.2500),
|
||||
('600887', '伊利股份', '2026-05-09', 32.00, 32.80, 33.00, 31.80, 25000000, 820000000.00, 2.5000, 3.1800),
|
||||
('600893', '航发动力', '2026-05-09', 42.50, 43.60, 44.00, 42.20, 10000000, 436000000.00, 2.5900, 2.6500),
|
||||
('600900', '长江电力', '2026-05-09', 28.50, 28.80, 28.90, 28.40, 20000000, 576000000.00, 1.0500, 1.8500),
|
||||
('601012', '隆基绿能', '2026-05-09', 18.50, 17.80, 18.60, 17.60, 45000000, 801000000.00, -3.7800, 4.5200),
|
||||
('601088', '中国神华', '2026-05-09', 38.00, 38.50, 38.60, 37.80, 15000000, 578000000.00, 1.3200, 2.1500),
|
||||
('601166', '兴业银行', '2026-05-09', 20.50, 21.00, 21.10, 20.30, 30000000, 630000000.00, 2.4400, 3.5600),
|
||||
('601318', '中国平安', '2026-05-09', 52.00, 53.50, 53.80, 51.80, 35000000, 1870000000.00, 2.8800, 3.0200),
|
||||
('601398', '工商银行', '2026-05-09', 5.80, 5.90, 5.92, 5.78, 150000000, 885000000.00, 1.7200, 5.3800),
|
||||
('601628', '中国人寿', '2026-05-09', 35.00, 34.20, 35.20, 34.00, 25000000, 855000000.00, -2.2900, 3.1200),
|
||||
('601668', '中国建筑', '2026-05-09', 6.20, 6.35, 6.38, 6.18, 80000000, 508000000.00, 2.4200, 5.6800),
|
||||
('601688', '华泰证券', '2026-05-09', 18.50, 19.20, 19.30, 18.40, 30000000, 576000000.00, 3.7800, 3.2500),
|
||||
('601728', '中国电信', '2026-05-09', 7.20, 7.35, 7.38, 7.18, 90000000, 662000000.00, 2.0800, 5.9200),
|
||||
('601766', '中国中车', '2026-05-09', 8.20, 7.98, 8.25, 7.92, 60000000, 479000000.00, -2.6800, 4.8500),
|
||||
('601857', '中国石油', '2026-05-09', 8.80, 8.95, 8.98, 8.75, 100000000, 895000000.00, 1.7000, 4.1200),
|
||||
('601888', '中国中免', '2026-05-09', 85.00, 82.50, 85.50, 82.00, 12000000, 990000000.00, -2.9400, 2.5600),
|
||||
('601899', '紫金矿业', '2026-05-09', 18.50, 19.20, 19.30, 18.30, 50000000, 960000000.00, 3.7800, 3.8500),
|
||||
('601919', '中远海控', '2026-05-09', 15.00, 14.50, 15.10, 14.40, 40000000, 580000000.00, -3.3300, 4.3500),
|
||||
('601985', '中国核电', '2026-05-09', 9.80, 10.10, 10.15, 9.75, 50000000, 505000000.00, 3.0600, 4.2800),
|
||||
('603259', '药明康德', '2026-05-09', 62.00, 64.50, 65.00, 61.50, 15000000, 968000000.00, 4.0300, 3.1200),
|
||||
('603288', '海天味业', '2026-05-09', 38.50, 37.80, 38.60, 37.50, 12000000, 454000000.00, -1.8200, 2.1500),
|
||||
('603501', '韦尔股份', '2026-05-09', 105.00, 109.50, 110.00, 104.00, 8000000, 876000000.00, 4.2900, 2.9800),
|
||||
('603986', '兆易创新', '2026-05-09', 120.00, 118.00, 121.00, 117.50, 6000000, 708000000.00, -1.6700, 2.3500),
|
||||
('688981', '中芯国际', '2026-05-09', 85.00, 88.50, 89.00, 84.50, 18000000, 1590000000.00, 4.1200, 3.5600);
|
||||
@@ -0,0 +1 @@
|
||||
:root{--text:#6b6375;--text-h:#08060d;--bg:#fff;--border:#e5e4e7;--code-bg:#f4f3ec;--accent:#aa3bff;--accent-bg:#aa3bff1a;--accent-border:#aa3bff80;--social-bg:#f4f3ec80;--shadow:#0000001a 0 10px 15px -3px, #0000000d 0 4px 6px -2px;--sans:system-ui, "Segoe UI", Roboto, sans-serif;--heading:system-ui, "Segoe UI", Roboto, sans-serif;--mono:ui-monospace, Consolas, monospace;font:18px/145% var(--sans);letter-spacing:.18px;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;color:var(--text);background:var(--bg);font-synthesis:none;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}}@media (width<=1024px){:root{font-size:16px}}@media (prefers-color-scheme:dark){:root{--text:#9ca3af;--text-h:#f3f4f6;--bg:#16171d;--border:#2e303a;--code-bg:#1f2028;--accent:#c084fc;--accent-bg:#c084fc26;--accent-border:#c084fc80;--social-bg:#2f303a80;--shadow:#0006 0 10px 15px -3px, #00000040 0 4px 6px -2px}#social .button-icon{filter:invert()brightness(2)}}#root{text-align:center;border-inline:1px solid var(--border);box-sizing:border-box;flex-direction:column;width:1126px;max-width:100%;min-height:100svh;margin:0 auto;display:flex}body{margin:0}h1,h2{font-family:var(--heading);color:var(--text-h);font-weight:500}h1{letter-spacing:-1.68px;margin:32px 0;font-size:56px}@media (width<=1024px){h1{margin:20px 0;font-size:36px}}h2{letter-spacing:-.24px;margin:0 0 8px;font-size:24px;line-height:118%}@media (width<=1024px){h2{font-size:20px}}p{margin:0}code,.counter{font-family:var(--mono);color:var(--text-h);border-radius:4px;display:inline-flex}code{background:var(--code-bg);padding:4px 8px;font-size:15px;line-height:135%}
|
||||
|
After Width: | Height: | Size: 9.3 KiB |
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>web</title>
|
||||
<script type="module" crossorigin src="/assets/index-DeNrSZiF.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DGNrK5qb.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,73 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>web</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^6.2.2",
|
||||
"antd": "^6.3.7",
|
||||
"axios": "^1.16.0",
|
||||
"echarts": "^6.0.0",
|
||||
"react": "^19.2.5",
|
||||
"react-dom": "^19.2.5",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.12.2",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.5.0",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "^8.0.10"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 9.3 KiB |
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,184 @@
|
||||
.counter {
|
||||
font-size: 16px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
color: var(--accent);
|
||||
background: var(--accent-bg);
|
||||
border: 2px solid transparent;
|
||||
transition: border-color 0.3s;
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
|
||||
.base,
|
||||
.framework,
|
||||
.vite {
|
||||
inset-inline: 0;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.base {
|
||||
width: 170px;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.framework,
|
||||
.vite {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.framework {
|
||||
z-index: 1;
|
||||
top: 34px;
|
||||
height: 28px;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
|
||||
scale(1.4);
|
||||
}
|
||||
|
||||
.vite {
|
||||
z-index: 0;
|
||||
top: 107px;
|
||||
height: 26px;
|
||||
width: auto;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
|
||||
scale(0.8);
|
||||
}
|
||||
}
|
||||
|
||||
#center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
place-content: center;
|
||||
place-items: center;
|
||||
flex-grow: 1;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding: 32px 20px 24px;
|
||||
gap: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps {
|
||||
display: flex;
|
||||
border-top: 1px solid var(--border);
|
||||
text-align: left;
|
||||
|
||||
& > div {
|
||||
flex: 1 1 0;
|
||||
padding: 32px;
|
||||
@media (max-width: 1024px) {
|
||||
padding: 24px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-bottom: 16px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
#docs {
|
||||
border-right: 1px solid var(--border);
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 32px 0 0;
|
||||
|
||||
.logo {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--text-h);
|
||||
font-size: 16px;
|
||||
border-radius: 6px;
|
||||
background: var(--social-bg);
|
||||
display: flex;
|
||||
padding: 6px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
transition: box-shadow 0.3s;
|
||||
|
||||
&:hover {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.button-icon {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
margin-top: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
|
||||
li {
|
||||
flex: 1 1 calc(50% - 8px);
|
||||
}
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#spacer {
|
||||
height: 88px;
|
||||
border-top: 1px solid var(--border);
|
||||
@media (max-width: 1024px) {
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.ticks {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -4.5px;
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
&::before {
|
||||
left: 0;
|
||||
border-left-color: var(--border);
|
||||
}
|
||||
&::after {
|
||||
right: 0;
|
||||
border-right-color: var(--border);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { ConfigProvider } from 'antd';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
import Dashboard from './pages/Dashboard';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<ConfigProvider locale={zhCN}>
|
||||
<Dashboard />
|
||||
</ConfigProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,43 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: '/api',
|
||||
});
|
||||
|
||||
export interface StockRank {
|
||||
code: string;
|
||||
name: string;
|
||||
pct_change: number;
|
||||
close: number;
|
||||
}
|
||||
|
||||
export interface DashboardSummary {
|
||||
total_stocks: number;
|
||||
up_count: number;
|
||||
down_count: number;
|
||||
flat_count: number;
|
||||
total_turnover: number;
|
||||
avg_pct_change: number;
|
||||
top_gainers: StockRank[];
|
||||
top_losers: StockRank[];
|
||||
}
|
||||
|
||||
export interface DailySummary {
|
||||
date: string;
|
||||
total_stocks: number;
|
||||
up_count: number;
|
||||
down_count: number;
|
||||
flat_count: number;
|
||||
total_turnover: number;
|
||||
avg_pct_change: number;
|
||||
}
|
||||
|
||||
export async function getDashboardSummary(): Promise<DashboardSummary> {
|
||||
const res = await api.get('/dashboard/summary');
|
||||
return res.data.data;
|
||||
}
|
||||
|
||||
export async function getDailySummary(days = 30): Promise<DailySummary[]> {
|
||||
const res = await api.get('/dashboard/daily', { params: { days } });
|
||||
return res.data.data;
|
||||
}
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
@@ -0,0 +1,110 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import * as echarts from 'echarts';
|
||||
import type { DailySummary } from '../api/dashboard';
|
||||
|
||||
interface Props {
|
||||
data: DailySummary[];
|
||||
}
|
||||
|
||||
function fmtYi(v: number) {
|
||||
return +(v / 1e8).toFixed(0);
|
||||
}
|
||||
|
||||
export default function DailyChart({ data }: Props) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const chartRef = useRef<echarts.ECharts | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return;
|
||||
|
||||
if (!chartRef.current) {
|
||||
chartRef.current = echarts.init(ref.current);
|
||||
}
|
||||
const chart = chartRef.current;
|
||||
|
||||
const dates = data.map((d) => d.date);
|
||||
|
||||
chart.setOption({
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'cross' },
|
||||
},
|
||||
legend: {
|
||||
top: 0,
|
||||
data: ['上涨数', '下跌数', '平均涨跌幅(%)', '成交额(亿)'],
|
||||
},
|
||||
grid: [
|
||||
{ left: 60, right: 60, top: 50, height: '35%' },
|
||||
{ left: 60, right: 60, top: '60%', height: '25%' },
|
||||
],
|
||||
xAxis: [
|
||||
{ type: 'category', data: dates, gridIndex: 0, boundaryGap: false },
|
||||
{ type: 'category', data: dates, gridIndex: 1, boundaryGap: false, show: false },
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '股票数',
|
||||
gridIndex: 0,
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '亿',
|
||||
gridIndex: 1,
|
||||
},
|
||||
],
|
||||
dataZoom: [
|
||||
{ type: 'inside', xAxisIndex: [0, 1], start: 0, end: 100 },
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '上涨数',
|
||||
type: 'line',
|
||||
xAxisIndex: 0,
|
||||
yAxisIndex: 0,
|
||||
data: data.map((d) => d.up_count),
|
||||
itemStyle: { color: '#cf1322' },
|
||||
lineStyle: { width: 2 },
|
||||
symbol: 'none',
|
||||
},
|
||||
{
|
||||
name: '下跌数',
|
||||
type: 'line',
|
||||
xAxisIndex: 0,
|
||||
yAxisIndex: 0,
|
||||
data: data.map((d) => d.down_count),
|
||||
itemStyle: { color: '#3f8600' },
|
||||
lineStyle: { width: 2 },
|
||||
symbol: 'none',
|
||||
},
|
||||
{
|
||||
name: '平均涨跌幅(%)',
|
||||
type: 'line',
|
||||
xAxisIndex: 0,
|
||||
yAxisIndex: 0,
|
||||
data: data.map((d) => +d.avg_pct_change.toFixed(2)),
|
||||
itemStyle: { color: '#1677ff' },
|
||||
lineStyle: { width: 2, type: 'dashed' },
|
||||
symbol: 'none',
|
||||
},
|
||||
{
|
||||
name: '成交额(亿)',
|
||||
type: 'line',
|
||||
xAxisIndex: 1,
|
||||
yAxisIndex: 1,
|
||||
data: data.map((d) => fmtYi(d.total_turnover)),
|
||||
areaStyle: { color: 'rgba(22,119,255,0.15)' },
|
||||
itemStyle: { color: '#1677ff' },
|
||||
lineStyle: { width: 2 },
|
||||
symbol: 'none',
|
||||
},
|
||||
],
|
||||
}, true);
|
||||
|
||||
const handleResize = () => chart.resize();
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, [data]);
|
||||
|
||||
return <div ref={ref} style={{ height: 480 }} />;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { Card, Statistic } from 'antd';
|
||||
import {
|
||||
RiseOutlined,
|
||||
FallOutlined,
|
||||
MinusOutlined,
|
||||
StockOutlined,
|
||||
DollarOutlined,
|
||||
LineChartOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
interface StatCardsProps {
|
||||
data: {
|
||||
total_stocks: number;
|
||||
up_count: number;
|
||||
down_count: number;
|
||||
flat_count: number;
|
||||
total_turnover: number;
|
||||
avg_pct_change: number;
|
||||
};
|
||||
}
|
||||
|
||||
export default function StatCards({ data }: StatCardsProps) {
|
||||
const cards = [
|
||||
{
|
||||
title: '总股票数',
|
||||
value: data.total_stocks,
|
||||
icon: <StockOutlined />,
|
||||
color: '#e6f4ff',
|
||||
},
|
||||
{
|
||||
title: '上涨',
|
||||
value: data.up_count,
|
||||
icon: <RiseOutlined />,
|
||||
valueStyle: { color: '#cf1322' },
|
||||
color: '#fff1f0',
|
||||
},
|
||||
{
|
||||
title: '下跌',
|
||||
value: data.down_count,
|
||||
icon: <FallOutlined />,
|
||||
valueStyle: { color: '#3f8600' },
|
||||
color: '#f6ffed',
|
||||
},
|
||||
{
|
||||
title: '平盘',
|
||||
value: data.flat_count,
|
||||
icon: <MinusOutlined />,
|
||||
color: '#fafafa',
|
||||
},
|
||||
{
|
||||
title: '总成交额(亿)',
|
||||
value: +(data.total_turnover / 1e8).toFixed(2),
|
||||
icon: <DollarOutlined />,
|
||||
color: '#e6f4ff',
|
||||
},
|
||||
{
|
||||
title: '平均涨跌幅(%)',
|
||||
value: data.avg_pct_change,
|
||||
precision: 2,
|
||||
icon: <LineChartOutlined />,
|
||||
valueStyle: {
|
||||
color: data.avg_pct_change >= 0 ? '#cf1322' : '#3f8600',
|
||||
},
|
||||
color: data.avg_pct_change >= 0 ? '#fff1f0' : '#f6ffed',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16 }}>
|
||||
{cards.map((c) => (
|
||||
<Card key={c.title} style={{ background: c.color }}>
|
||||
<Statistic
|
||||
title={c.title}
|
||||
value={c.value}
|
||||
precision={'precision' in c ? c.precision : undefined}
|
||||
prefix={c.icon}
|
||||
valueStyle={c.valueStyle}
|
||||
/>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
:root {
|
||||
--text: #6b6375;
|
||||
--text-h: #08060d;
|
||||
--bg: #fff;
|
||||
--border: #e5e4e7;
|
||||
--code-bg: #f4f3ec;
|
||||
--accent: #aa3bff;
|
||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
||||
--accent-border: rgba(170, 59, 255, 0.5);
|
||||
--social-bg: rgba(244, 243, 236, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
|
||||
|
||||
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--mono: ui-monospace, Consolas, monospace;
|
||||
|
||||
font: 18px/145% var(--sans);
|
||||
letter-spacing: 0.18px;
|
||||
color-scheme: light dark;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text: #9ca3af;
|
||||
--text-h: #f3f4f6;
|
||||
--bg: #16171d;
|
||||
--border: #2e303a;
|
||||
--code-bg: #1f2028;
|
||||
--accent: #c084fc;
|
||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
||||
--accent-border: rgba(192, 132, 252, 0.5);
|
||||
--social-bg: rgba(47, 48, 58, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
|
||||
}
|
||||
|
||||
#social .button-icon {
|
||||
filter: invert(1) brightness(2);
|
||||
}
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 1126px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-inline: 1px solid var(--border);
|
||||
min-height: 100svh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-family: var(--heading);
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 56px;
|
||||
letter-spacing: -1.68px;
|
||||
margin: 32px 0;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 36px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
}
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
line-height: 118%;
|
||||
letter-spacing: -0.24px;
|
||||
margin: 0 0 8px;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code,
|
||||
.counter {
|
||||
font-family: var(--mono);
|
||||
display: inline-flex;
|
||||
border-radius: 4px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 15px;
|
||||
line-height: 135%;
|
||||
padding: 4px 8px;
|
||||
background: var(--code-bg);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,119 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Card, Spin, Table, Tag, Typography, Segmented } from 'antd';
|
||||
import {
|
||||
getDashboardSummary,
|
||||
getDailySummary,
|
||||
type DashboardSummary,
|
||||
type DailySummary,
|
||||
} from '../api/dashboard';
|
||||
import StatCards from '../components/StatCard';
|
||||
import DailyChart from '../components/DailyChart';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
const rankColumns = [
|
||||
{ title: '代码', dataIndex: 'code', key: 'code', width: 90 },
|
||||
{ title: '名称', dataIndex: 'name', key: 'name', width: 110 },
|
||||
{
|
||||
title: '最新价',
|
||||
dataIndex: 'close',
|
||||
key: 'close',
|
||||
width: 90,
|
||||
render: (v: number) => v?.toFixed(2),
|
||||
},
|
||||
{
|
||||
title: '涨跌幅',
|
||||
dataIndex: 'pct_change',
|
||||
key: 'pct_change',
|
||||
width: 100,
|
||||
render: (v: number) => (
|
||||
<Tag color={v >= 0 ? 'red' : 'green'}>
|
||||
{v >= 0 ? '+' : ''}{v?.toFixed(2)}%
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export default function Dashboard() {
|
||||
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
||||
const [daily, setDaily] = useState<DailySummary[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [days, setDays] = useState<number | string>(30);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
Promise.all([
|
||||
getDashboardSummary(),
|
||||
getDailySummary(typeof days === 'string' ? 30 : days),
|
||||
])
|
||||
.then(([s, d]) => {
|
||||
setSummary(s);
|
||||
setDaily(d);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [days]);
|
||||
|
||||
if (loading && !summary) {
|
||||
return (
|
||||
<div style={{ display: 'flex', justifyContent: 'center', padding: 100 }}>
|
||||
<Spin size="large" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!summary) return <div>加载失败</div>;
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24, maxWidth: 1200, margin: '0 auto' }}>
|
||||
<Title level={2} style={{ textAlign: 'center', marginBottom: 32 }}>
|
||||
A股市场概览看板
|
||||
</Title>
|
||||
|
||||
<StatCards data={summary} />
|
||||
|
||||
<Card
|
||||
title="每日趋势"
|
||||
style={{ marginTop: 24 }}
|
||||
extra={
|
||||
<Segmented
|
||||
value={days}
|
||||
onChange={setDays}
|
||||
options={[
|
||||
{ label: '7天', value: 7 },
|
||||
{ label: '30天', value: 30 },
|
||||
{ label: '90天', value: 90 },
|
||||
{ label: '180天', value: 180 },
|
||||
]}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{daily.length > 0 ? (
|
||||
<DailyChart data={daily} />
|
||||
) : (
|
||||
<Spin />
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16, marginTop: 24 }}>
|
||||
<Card title="涨幅前5" size="small">
|
||||
<Table
|
||||
columns={rankColumns}
|
||||
dataSource={summary.top_gainers}
|
||||
rowKey="code"
|
||||
pagination={false}
|
||||
size="small"
|
||||
/>
|
||||
</Card>
|
||||
<Card title="跌幅前5" size="small">
|
||||
<Table
|
||||
columns={rankColumns}
|
||||
dataSource={summary.top_losers}
|
||||
rowKey="code"
|
||||
pagination={false}
|
||||
size="small"
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "esnext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||