Files
digital-pilates/types/goals.ts
richarjiang 4382fb804f feat: 新增目标创建弹窗的重复周期选择功能
- 在目标创建弹窗中添加重复周期选择功能,支持用户选择每日、每周和每月的重复类型
- 实现每周和每月的具体日期选择,用户可自定义选择周几和每月的日期
- 更新相关样式,提升用户体验和界面美观性
- 新增图标资源,替换原有文本图标,增强视觉效果
2025-08-23 15:58:37 +08:00

251 lines
5.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 目标管理相关类型定义
export type RepeatType = 'daily' | 'weekly' | 'monthly';
export type GoalStatus = 'active' | 'paused' | 'completed' | 'cancelled';
export type GoalPriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
// 自定义重复规则
export interface CustomRepeatRule {
weekdays?: number[]; // 0-60为周日
dayOfMonth?: number[]; // 1-31
}
// 提醒设置
export interface ReminderSettings {
enabled: boolean;
weekdays?: number[]; // 0-60为周日
monthDays?: number[]; // 1-31每月几号
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;
}
// 任务相关类型定义
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'overdue' | 'skipped';
// 任务数据结构
export interface Task {
id: string;
goalId: string;
userId: string;
title: string;
description?: string;
startDate: string; // ISO date string
endDate: string; // ISO date string
targetCount: number;
currentCount: number;
status: TaskStatus;
progressPercentage: number;
completedAt?: string; // ISO datetime string
notes?: string;
metadata?: Record<string, any>;
daysRemaining: number;
isToday: boolean;
goal?: {
id: string;
title: string;
repeatType: RepeatType;
frequency: number;
category?: string;
};
}
// 获取任务列表的查询参数
export interface GetTasksQuery {
goalId?: string;
status?: TaskStatus;
startDate?: string;
endDate?: string;
page?: number;
pageSize?: number;
}
// 完成任务的请求数据
export interface CompleteTaskRequest {
count?: number;
notes?: string;
completedAt?: string;
}
// 跳过任务的请求数据
export interface SkipTaskRequest {
reason?: string;
}
// 任务统计信息
export interface TaskStats {
total: number;
pending: number;
inProgress: number;
completed: number;
overdue: number;
skipped: number;
totalProgress: number;
todayTasks: number;
weekTasks: number;
monthTasks: number;
}
// 任务列表项响应
export interface TaskListItem extends Task {
// 继承Task的所有属性
}