前端重构: - 新增 api/ 目录统一管理所有 API 请求 - 所有 stores 和 pages 改为使用 api 模块 - 修复日期格式化函数,支持 Date 对象和 ISO 字符串 - 修复 TransactionItem 使用 CategoryIcon 组件 - 优化 ChartWrapper 区分 H5 和小程序环境 后端修复: - 修复 auth 中间件 PUBLIC_PATHS 缺少 demo-login - 修复备份工具命令注入漏洞,改用 execFile - 修复 stats 路由 type 参数验证 - 优化分类排序为批量 SQL 更新 - 合并迁移和删除为数据库事务原子操作 - 修复交易和统计日期返回格式 - 新增自动备份功能(启动时备份)
41 lines
957 B
TypeScript
41 lines
957 B
TypeScript
import { request } from '@/utils/request'
|
|
|
|
/** 概览数据 */
|
|
export interface Overview {
|
|
expense: number
|
|
income: number
|
|
count: number
|
|
daily: number
|
|
}
|
|
|
|
/** 分类统计 */
|
|
export interface CategoryStat {
|
|
id: number
|
|
name: string
|
|
icon: string
|
|
color: string
|
|
amount: number
|
|
count: number
|
|
}
|
|
|
|
/** 趋势数据点 */
|
|
export interface TrendPoint {
|
|
date: string
|
|
amount: number
|
|
}
|
|
|
|
/** 获取概览数据 */
|
|
export function getOverview(params?: { month?: string; startDate?: string; endDate?: string }) {
|
|
return request<Overview>({ url: '/stats/overview', data: params })
|
|
}
|
|
|
|
/** 获取分类统计 */
|
|
export function getCategoryStats(month?: string, type: string = 'expense') {
|
|
return request<CategoryStat[]>({ url: '/stats/category', data: { month, type } })
|
|
}
|
|
|
|
/** 获取趋势数据 */
|
|
export function getTrend(month?: string, type: string = 'expense') {
|
|
return request<TrendPoint[]>({ url: '/stats/trend', data: { month, type } })
|
|
}
|