feat(dev-task): 开发任务模块 V1 完整实现

- 核心库:dev-task.ts(类型+状态机+进度计算)、task-worklog.ts(工时)、task-category.ts(字典)、work-item.ts(聚合契约)
- Store:useDevTaskStore(CRUD+状态流转)、useTaskWorklogStore(工时记录)、useTaskCategoryStore(字典管理)
- UI组件:DevTaskTab、DevTaskCreateModal、DevTaskDetailDrawer、DevTaskRow、WorklogPanel、StatusBadge、CategoryChip
- 集成:版本详情页"开发任务"Tab、"与我相关"工作台开发任务分组、任务类型管理页
- 设计文档:spec + 实施计划

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-11 18:02:07 +08:00
parent 8bc23fbf3d
commit a560634091
20 changed files with 3054 additions and 6 deletions

View File

@@ -0,0 +1,65 @@
'use client';
import { create } from 'zustand';
import type { TaskCategory, CategoryGroup } from '@/lib/task-category';
import { PRESET_CATEGORIES } from '@/lib/task-category';
const STORAGE_KEY = 'ftb_task_categories_v1';
function saveLocal(items: TaskCategory[]) {
try { localStorage.setItem(STORAGE_KEY, JSON.stringify(items)); } catch {}
}
function loadLocal(): TaskCategory[] | null {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (raw) return JSON.parse(raw);
} catch {}
return null;
}
interface TaskCategoryState {
categories: TaskCategory[];
fetchCategories: () => void;
addCategory: (name: string, group: CategoryGroup, color?: string) => void;
updateCategory: (id: string, data: Partial<TaskCategory>) => void;
deleteCategory: (id: string) => boolean;
}
export const useTaskCategoryStore = create<TaskCategoryState>((set, get) => ({
categories: PRESET_CATEGORIES,
fetchCategories: () => {
const cached = loadLocal();
if (cached) set({ categories: cached });
},
addCategory: (name, group, color) => {
const list = get().categories;
const item: TaskCategory = {
id: `cat-${Date.now()}`,
name,
group,
color,
sortOrder: list.length + 1,
isSystem: false,
};
const updated = [...list, item];
set({ categories: updated });
saveLocal(updated);
},
updateCategory: (id, data) => {
const updated = get().categories.map((c) => (c.id === id ? { ...c, ...data } : c));
set({ categories: updated });
saveLocal(updated);
},
deleteCategory: (id) => {
const target = get().categories.find((c) => c.id === id);
if (!target || target.isSystem) return false;
const updated = get().categories.filter((c) => c.id !== id);
set({ categories: updated });
saveLocal(updated);
return true;
},
}));