feat: 完善目标管理功能及相关组件
- 新增创建目标弹窗,支持用户输入目标信息并提交 - 实现目标数据的转换,支持将目标转换为待办事项和时间轴事件 - 优化目标页面,集成Redux状态管理,处理目标的创建、完成和错误提示 - 更新时间轴组件,支持动态显示目标安排 - 编写目标管理功能实现文档,详细描述功能和组件架构
This commit is contained in:
180
types/goals.ts
Normal file
180
types/goals.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
// 目标管理相关类型定义
|
||||
|
||||
export type RepeatType = 'daily' | 'weekly' | 'monthly' | 'custom';
|
||||
|
||||
export type GoalStatus = 'active' | 'paused' | 'completed' | 'cancelled';
|
||||
|
||||
export type GoalPriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||
|
||||
// 自定义重复规则
|
||||
export interface CustomRepeatRule {
|
||||
type: 'weekly' | 'monthly';
|
||||
weekdays?: number[]; // 0-6,0为周日
|
||||
monthDays?: number[]; // 1-31
|
||||
interval?: number; // 间隔周数或月数
|
||||
}
|
||||
|
||||
// 提醒设置
|
||||
export interface ReminderSettings {
|
||||
enabled: boolean;
|
||||
weekdays?: number[]; // 0-6,0为周日
|
||||
sound?: string;
|
||||
vibration?: boolean;
|
||||
}
|
||||
|
||||
// 目标数据结构
|
||||
export interface Goal {
|
||||
id: string;
|
||||
userId: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
repeatType: RepeatType;
|
||||
frequency: number;
|
||||
customRepeatRule?: CustomRepeatRule;
|
||||
startDate: string; // ISO date string
|
||||
endDate?: string; // ISO date string
|
||||
startTime: number; // HH:mm format
|
||||
endTime: number; // HH:mm format
|
||||
status: GoalStatus;
|
||||
completedCount: number;
|
||||
targetCount?: number;
|
||||
category?: string;
|
||||
priority: GoalPriority;
|
||||
hasReminder: boolean;
|
||||
reminderTime?: string; // HH:mm format
|
||||
reminderSettings?: ReminderSettings;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
// 目标完成记录
|
||||
export interface GoalCompletion {
|
||||
id: string;
|
||||
goalId: string;
|
||||
userId: string;
|
||||
completedAt: string; // ISO datetime string
|
||||
completionCount: number;
|
||||
notes?: string;
|
||||
metadata?: Record<string, any>;
|
||||
}
|
||||
|
||||
// 创建目标的请求数据
|
||||
export interface CreateGoalRequest {
|
||||
title: string;
|
||||
description?: string;
|
||||
repeatType: RepeatType;
|
||||
frequency: number;
|
||||
customRepeatRule?: CustomRepeatRule;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
startTime?: number; // 单位:分钟
|
||||
endTime?: number; // 单位:分钟
|
||||
targetCount?: number;
|
||||
category?: string;
|
||||
priority: GoalPriority;
|
||||
hasReminder: boolean;
|
||||
reminderTime?: string;
|
||||
reminderSettings?: ReminderSettings;
|
||||
}
|
||||
|
||||
// 更新目标的请求数据
|
||||
export interface UpdateGoalRequest {
|
||||
title?: string;
|
||||
description?: string;
|
||||
repeatType?: RepeatType;
|
||||
frequency?: number;
|
||||
customRepeatRule?: CustomRepeatRule;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
targetCount?: number;
|
||||
category?: string;
|
||||
priority?: GoalPriority;
|
||||
hasReminder?: boolean;
|
||||
reminderTime?: string;
|
||||
reminderSettings?: ReminderSettings;
|
||||
status?: GoalStatus;
|
||||
}
|
||||
|
||||
// 记录目标完成的请求数据
|
||||
export interface CompleteGoalRequest {
|
||||
completionCount?: number;
|
||||
notes?: string;
|
||||
completedAt?: string;
|
||||
}
|
||||
|
||||
// 获取目标列表的查询参数
|
||||
export interface GetGoalsQuery {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
status?: GoalStatus;
|
||||
repeatType?: RepeatType;
|
||||
category?: string;
|
||||
search?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
sortBy?: 'createdAt' | 'updatedAt' | 'priority' | 'title' | 'startDate';
|
||||
sortOrder?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
// 获取目标完成记录的查询参数
|
||||
export interface GetGoalCompletionsQuery {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
}
|
||||
|
||||
// 批量操作目标的请求数据
|
||||
export interface BatchGoalOperationRequest {
|
||||
goalIds: string[];
|
||||
action: 'pause' | 'resume' | 'complete' | 'delete';
|
||||
}
|
||||
|
||||
// 批量操作结果
|
||||
export interface BatchGoalOperationResult {
|
||||
goalId: string;
|
||||
success: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// 目标统计信息
|
||||
export interface GoalStats {
|
||||
total: number;
|
||||
active: number;
|
||||
completed: number;
|
||||
paused: number;
|
||||
cancelled: number;
|
||||
byCategory: Record<string, number>;
|
||||
byRepeatType: Record<RepeatType, number>;
|
||||
totalCompletions: number;
|
||||
thisWeekCompletions: number;
|
||||
thisMonthCompletions: number;
|
||||
}
|
||||
|
||||
// API响应格式
|
||||
export interface ApiResponse<T> {
|
||||
code: number;
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
// 分页响应格式
|
||||
export interface PaginatedResponse<T> {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
list: T[];
|
||||
}
|
||||
|
||||
// 目标详情响应(包含完成记录)
|
||||
export interface GoalDetailResponse extends Goal {
|
||||
progressPercentage: number;
|
||||
daysRemaining?: number;
|
||||
completions: GoalCompletion[];
|
||||
}
|
||||
|
||||
// 目标列表项响应
|
||||
export interface GoalListItem extends Goal {
|
||||
progressPercentage: number;
|
||||
daysRemaining?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user