架构:新建 lib/workspace-engine.ts - aggregateWorkItems(): 从所有 store 统一聚合"与我相关"数据 - 每个 WorkItem 包含:type, title, status, completed, productName, projectName, versionName, versionId - 新增模块只需在引擎中添加聚合逻辑,工作台自动展示 - 解决了之前各模块增加内容但工作台无法关联的问题 功能改动: 1. 每个任务显示完整上下文:产品 / 项目 / 版本 2. 版本名可点击跳转到版本详情 3. 所有任务(含已完成)统一展示,已完成半透明+绿色勾 4. 左侧增加"显示已完成"开关 5. 待办/已完成计数统计 6. 统一卡片样式:类型标签 + 状态 + 编号 + 标题 + 优先级 7. Bug 额外显示严重程度标签 8. 列表默认排序:未完成在前,已完成在后 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
128 lines
3.5 KiB
TypeScript
128 lines
3.5 KiB
TypeScript
import type { VersionPlan } from './version-plan';
|
|
import type { DevTask } from './dev-task';
|
|
import type { TestCase } from './test-case';
|
|
import type { Bug } from './bug';
|
|
|
|
export type WorkItemType = 'plan_research' | 'plan_product' | 'plan_ui' | 'devTask' | 'testCase' | 'bug';
|
|
|
|
export interface WorkItem {
|
|
id: string;
|
|
type: WorkItemType;
|
|
title: string;
|
|
status: string;
|
|
completed: boolean;
|
|
productName: string;
|
|
projectName: string;
|
|
versionName: string;
|
|
versionId: string;
|
|
priority?: string;
|
|
extra?: Record<string, any>;
|
|
raw: VersionPlan | DevTask | TestCase | Bug;
|
|
}
|
|
|
|
interface VersionContext {
|
|
id: string;
|
|
name: string;
|
|
productName: string;
|
|
projectName: string;
|
|
}
|
|
|
|
export function aggregateWorkItems(
|
|
userName: string,
|
|
plans: VersionPlan[],
|
|
devTasks: DevTask[],
|
|
testCases: TestCase[],
|
|
bugs: Bug[],
|
|
versionMap: Map<string, VersionContext>,
|
|
requirementVersionMap: Map<string, string>,
|
|
): WorkItem[] {
|
|
const items: WorkItem[] = [];
|
|
|
|
// Plans: owner === userName
|
|
plans.filter((p) => p.owner === userName).forEach((p) => {
|
|
const ver = versionMap.get(p.versionId);
|
|
items.push({
|
|
id: p.id,
|
|
type: p.type === 'research' ? 'plan_research' : p.type === 'product' ? 'plan_product' : 'plan_ui',
|
|
title: p.title,
|
|
status: p.status,
|
|
completed: p.status === 'completed',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: p.versionId,
|
|
extra: { startTime: p.startTime, endTime: p.endTime },
|
|
raw: p,
|
|
});
|
|
});
|
|
|
|
// DevTasks: assigneeId === userName
|
|
devTasks.filter((t) => t.assigneeId === userName).forEach((t) => {
|
|
const versionId = requirementVersionMap.get(t.requirementId) ?? '';
|
|
const ver = versionMap.get(versionId);
|
|
items.push({
|
|
id: t.id,
|
|
type: 'devTask',
|
|
title: t.title,
|
|
status: t.status,
|
|
completed: t.status === 'submitted',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId,
|
|
priority: t.priority,
|
|
extra: { taskNo: t.taskNo, dueDate: t.dueDate },
|
|
raw: t,
|
|
});
|
|
});
|
|
|
|
// TestCases: assigneeId === userName
|
|
testCases.filter((c) => c.assigneeId === userName).forEach((c) => {
|
|
const ver = versionMap.get(c.versionId);
|
|
items.push({
|
|
id: c.id,
|
|
type: 'testCase',
|
|
title: c.title,
|
|
status: c.status,
|
|
completed: c.status === 'passed',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: c.versionId,
|
|
priority: c.priority,
|
|
extra: { caseNo: c.caseNo },
|
|
raw: c,
|
|
});
|
|
});
|
|
|
|
// Bugs: assigneeId === userName
|
|
bugs.filter((b) => b.assigneeId === userName).forEach((b) => {
|
|
const ver = versionMap.get(b.versionId);
|
|
items.push({
|
|
id: b.id,
|
|
type: 'bug',
|
|
title: b.title,
|
|
status: b.status,
|
|
completed: b.status === 'closed' || b.status === 'rejected',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: b.versionId,
|
|
priority: b.priority,
|
|
extra: { bugNo: b.bugNo, severity: b.severity },
|
|
raw: b,
|
|
});
|
|
});
|
|
|
|
return items;
|
|
}
|
|
|
|
export const WORK_ITEM_TYPE_LABEL: Record<WorkItemType, string> = {
|
|
plan_research: '调研',
|
|
plan_product: '产品方案',
|
|
plan_ui: 'UI设计',
|
|
devTask: '开发任务',
|
|
testCase: '测试用例',
|
|
bug: 'Bug',
|
|
};
|