| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- // 文档类型枚举
- export enum DocumentType {
- UserRequirement = 'user_requirement', // 用户原始需求
- Requirement = 'requirement', // 需求文档
- Technical = 'technical', // 技术文档
- Implementation = 'implementation', // 业务实现
- Test = 'test' // 测试文档
- }
-
- // 文档类型显示名称映射
- export const DocumentTypeDisplayName: Record<DocumentType, string> = {
- [DocumentType.UserRequirement]: '用户原始需求',
- [DocumentType.Requirement]: '需求文档',
- [DocumentType.Technical]: '技术文档',
- [DocumentType.Implementation]: '业务实现',
- [DocumentType.Test]: '测试文档'
- };
-
- // 文档类型图标映射
- export const DocumentTypeIcon: Record<DocumentType, string> = {
- [DocumentType.UserRequirement]: 'description',
- [DocumentType.Requirement]: 'assignment',
- [DocumentType.Technical]: 'code',
- [DocumentType.Implementation]: 'architecture',
- [DocumentType.Test]: 'bug_report'
- };
-
- // 文档会话信息
- export interface DocumentSession {
- id: string; // 文档唯一ID (DocumentType值)
- sessionId: string; // 对应会话ID
- title: string; // 文档标题 (显示名称)
- content: string; // 从SSE获取的内容
- type: DocumentType; // 文档类型
- lastUpdated: Date; // 最后更新时间
- isLoading?: boolean; // 是否正在加载
- hasContent?: boolean; // 是否有内容
- }
-
- // 项目文档会话映射
- export interface ProjectDocumentSessions {
- projectId: string; // 项目ID
- documents: {
- [DocumentType.UserRequirement]?: string; // 用户原始需求会话ID
- [DocumentType.Requirement]?: string; // 需求文档会话ID
- [DocumentType.Technical]?: string; // 技术文档会话ID
- [DocumentType.Implementation]?: string; // 业务实现会话ID
- [DocumentType.Test]?: string; // 测试文档会话ID
- };
- }
-
- // 获取文档类型顺序(按照显示顺序)
- export function getDocumentTypeOrder(): DocumentType[] {
- return [
- DocumentType.UserRequirement,
- DocumentType.Requirement,
- DocumentType.Technical,
- DocumentType.Implementation,
- DocumentType.Test
- ];
- }
-
- // 从会话ID获取文档类型
- export function getDocumentTypeFromSessionId(sessionId: string, projectDocs: ProjectDocumentSessions): DocumentType | null {
- for (const docType of getDocumentTypeOrder()) {
- if (projectDocs.documents[docType] === sessionId) {
- return docType;
- }
- }
- return null;
- }
-
- // 创建空的文档会话数组(用于初始化)
- export function createEmptyDocumentSessions(projectId: string): DocumentSession[] {
- return getDocumentTypeOrder().map(docType => ({
- id: docType,
- sessionId: '',
- title: DocumentTypeDisplayName[docType],
- content: '',
- type: docType,
- lastUpdated: new Date(),
- isLoading: false,
- hasContent: false
- }));
- }
|