- 新增用户登录页面与API端点(/api/auth/login、/api/auth/logout、/api/auth/me) - 引入基于密码哈希的认证机制,支持默认管理员账号登录 - 创建访问控制模块(lib/access-control.ts),实现基于角色的权限验证 - 在现有API端点中集成权限检查,限制非管理员用户只能访问其所属项目数据 - 更新应用布局,要求用户登录后才能访问主界面 - 扩展用户表结构,增加用户名和密码哈希字段 - 调整项目、KR、目标、会议记录等资源的查询逻辑,根据用户权限过滤数据 - 改进管理页面(指标、模板)的删除操作,使用确认对话框替代直接确认 - 优化“我的KR”页面,为管理员提供全员KR概览视图 - 修复.gitignore文件中的拼写错误(.trae → .travis) - 添加数据库迁移脚本,支持任务直接关联项目、禁用RLS、添加求助字段等 - 配置Next.js以支持独立输出和子路径部署
226 lines
5.6 KiB
TypeScript
226 lines
5.6 KiB
TypeScript
export type UserRole = 'owner' | 'pm' | 'member';
|
|
export type ProjectStatus = 'green' | 'yellow' | 'red';
|
|
export type Direction = 'increase' | 'decrease';
|
|
export type PeriodType = 'custom' | '3d' | '1w' | '2w' | 'monthly';
|
|
export type ReasonCode = 'RESOURCE' | 'DEPENDENCY' | 'DECISION' | 'SCOPE' | 'EXECUTION' | 'OTHER';
|
|
|
|
export interface User {
|
|
id: string;
|
|
name: string;
|
|
role: UserRole;
|
|
avatar_url: string | null;
|
|
username: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Project {
|
|
id: string;
|
|
name: string;
|
|
description: string | null;
|
|
owner_id: string | null;
|
|
pm_id: string | null;
|
|
project_type: string;
|
|
status: ProjectStatus;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface ProjectMember {
|
|
project_id: string;
|
|
user_id: string;
|
|
}
|
|
|
|
export interface Objective {
|
|
id: string;
|
|
project_id: string;
|
|
title: string;
|
|
description: string | null;
|
|
period_start: string;
|
|
period_end: string;
|
|
created_by: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface KR {
|
|
id: string;
|
|
project_id: string;
|
|
objective_id: string | null;
|
|
period_type: PeriodType;
|
|
period_name: string | null;
|
|
period_start: string;
|
|
period_end: string;
|
|
title: string;
|
|
metric_name: string;
|
|
unit: string;
|
|
direction: Direction;
|
|
target_value: number;
|
|
current_value: number;
|
|
owner_user_id: string | null;
|
|
confidence: number;
|
|
status: ProjectStatus;
|
|
reason_code: ReasonCode | null;
|
|
note: string | null;
|
|
need_owner_help: boolean;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Checkin {
|
|
id: string;
|
|
kr_id: string;
|
|
project_id: string;
|
|
user_id: string | null;
|
|
date: string;
|
|
current_value: number;
|
|
delta_value: number | null;
|
|
confidence: number;
|
|
status_snapshot: ProjectStatus;
|
|
reason_code: ReasonCode | null;
|
|
note: string | null;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface Meeting {
|
|
id: string;
|
|
project_id: string;
|
|
period_start: string;
|
|
period_end: string;
|
|
summary: string;
|
|
decisions: string | null;
|
|
risks: string | null;
|
|
next_period_commitments: string | null;
|
|
created_by: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Metric {
|
|
id: string;
|
|
name: string;
|
|
unit: string;
|
|
direction: Direction;
|
|
category: string | null;
|
|
is_active: boolean;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface TemplateItem {
|
|
title: string;
|
|
metricName: string;
|
|
unit: string;
|
|
direction: Direction;
|
|
targetValue: number;
|
|
}
|
|
|
|
export interface Template {
|
|
id: string;
|
|
name: string;
|
|
description: string | null;
|
|
project_type: string | null;
|
|
tags: string[];
|
|
items: TemplateItem[];
|
|
is_active: boolean;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Task {
|
|
id: string;
|
|
kr_id: string | null;
|
|
project_id: string | null;
|
|
title: string;
|
|
description: string | null;
|
|
status: 'todo' | 'in_progress' | 'expected' | 'done';
|
|
priority: number;
|
|
urgency: number;
|
|
owner_user_id: string | null;
|
|
executor_ids: string[];
|
|
start_date: string | null;
|
|
end_date: string | null;
|
|
help_requested_to_user_id: string | null;
|
|
help_requested_by_user_id: string | null;
|
|
help_requested_at: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface TaskStep {
|
|
id: string;
|
|
task_id: string;
|
|
content: string;
|
|
note: string | null;
|
|
executor_id: string | null;
|
|
start_date: string | null;
|
|
end_date: string | null;
|
|
is_completed: boolean;
|
|
help_requested_to_user_id: string | null;
|
|
help_requested_by_user_id: string | null;
|
|
help_requested_at: string | null;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface Database {
|
|
public: {
|
|
Tables: {
|
|
users: {
|
|
Row: User;
|
|
Insert: Omit<User, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<User, 'id' | 'created_at'>>;
|
|
};
|
|
projects: {
|
|
Row: Project;
|
|
Insert: Omit<Project, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Project, 'id' | 'created_at'>>;
|
|
};
|
|
project_members: {
|
|
Row: ProjectMember;
|
|
Insert: ProjectMember;
|
|
Update: Partial<ProjectMember>;
|
|
};
|
|
objectives: {
|
|
Row: Objective;
|
|
Insert: Omit<Objective, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Objective, 'id' | 'created_at'>>;
|
|
};
|
|
krs: {
|
|
Row: KR;
|
|
Insert: Omit<KR, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<KR, 'id' | 'created_at'>>;
|
|
};
|
|
checkins: {
|
|
Row: Checkin;
|
|
Insert: Omit<Checkin, 'id' | 'created_at'> & { id?: string };
|
|
Update: Partial<Omit<Checkin, 'id' | 'created_at'>>;
|
|
};
|
|
meetings: {
|
|
Row: Meeting;
|
|
Insert: Omit<Meeting, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Meeting, 'id' | 'created_at'>>;
|
|
};
|
|
metrics: {
|
|
Row: Metric;
|
|
Insert: Omit<Metric, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Metric, 'id' | 'created_at'>>;
|
|
};
|
|
templates: {
|
|
Row: Template;
|
|
Insert: Omit<Template, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Template, 'id' | 'created_at'>>;
|
|
};
|
|
tasks: {
|
|
Row: Task;
|
|
Insert: Omit<Task, 'id' | 'created_at' | 'updated_at'> & { id?: string };
|
|
Update: Partial<Omit<Task, 'id' | 'created_at'>>;
|
|
};
|
|
task_steps: {
|
|
Row: TaskStep;
|
|
Insert: Omit<TaskStep, 'id' | 'created_at'> & { id?: string };
|
|
Update: Partial<Omit<TaskStep, 'id' | 'created_at'>>;
|
|
};
|
|
};
|
|
};
|
|
}
|