feat: 在首页新增每日洞察卡,集成AI服务提供个性化财务分析。
This commit is contained in:
@@ -299,21 +299,39 @@ let dailyInsightCache: {
|
||||
} | null = null;
|
||||
|
||||
export interface DailyInsightContext {
|
||||
// 今日数据
|
||||
todaySpend: number;
|
||||
yesterdaySpend: number;
|
||||
|
||||
// 预算数据
|
||||
monthlyBudget: number;
|
||||
monthlySpent: number;
|
||||
monthProgress: number; // 0-1
|
||||
budgetRemaining?: number; // 剩余预算
|
||||
daysRemaining?: number; // 剩余天数
|
||||
|
||||
// 历史数据
|
||||
lastWeekSpend?: number; // 上周同日
|
||||
weeklyTotal?: number; // 本周累计
|
||||
last7DaysSpend?: number[];// 最近7天支出数组
|
||||
avgDailySpend?: number; // 日均支出
|
||||
|
||||
// 分类分析
|
||||
topCategory?: { name: string; amount: number };
|
||||
top3Categories?: { name: string; amount: number }[]; // 本月前三分类
|
||||
|
||||
// 交易详情
|
||||
maxTransaction?: { note: string; amount: number };
|
||||
lastWeekSpend?: number;
|
||||
todayTransactionCount?: number; // 今日交易笔数
|
||||
|
||||
// 用户习惯
|
||||
streakDays?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AI-powered daily insight
|
||||
*/
|
||||
export async function getDailyInsight(context: DailyInsightContext): Promise<{ spending: string; budget: string }> {
|
||||
export async function getDailyInsight(context: DailyInsightContext): Promise<{ spending: string; budget: string; emoji?: string; tip?: string }> {
|
||||
// Hash needs to include new fields
|
||||
const currentHash = JSON.stringify(context);
|
||||
const NOW = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user