From 5d301364fb7eff6f025ab147a9baaaf8c7e55a29 Mon Sep 17 00:00:00 2001 From: gaoziman <2942894660@qq.com> Date: Sun, 28 Dec 2025 01:30:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B1=BB=E5=9E=8B):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E6=91=98=E8=A6=81=E5=8A=9F=E8=83=BD=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 定义摘要长度类型 (short/standard/detailed) - 定义摘要风格类型 (bullet/narrative) - 添加摘要状态、数据等接口定义 - 配置摘要长度和风格的默认选项 - 导出模块入口文件 --- .../features/SummaryGenerator/index.ts | 31 +++++++ .../features/SummaryGenerator/types.ts | 80 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 src/components/features/SummaryGenerator/index.ts create mode 100644 src/components/features/SummaryGenerator/types.ts diff --git a/src/components/features/SummaryGenerator/index.ts b/src/components/features/SummaryGenerator/index.ts new file mode 100644 index 0000000..7dcf0f9 --- /dev/null +++ b/src/components/features/SummaryGenerator/index.ts @@ -0,0 +1,31 @@ +/** + * 智能摘要功能模块 + * + * 提供 AI 自动生成对话摘要的能力 + */ + +// 组件导出 +export { SummaryButton } from './SummaryButton'; +export { SummaryModal } from './SummaryModal'; +export { SummaryOptions } from './SummaryOptions'; +export { SummaryContent } from './SummaryContent'; + +// Hook 导出 +export { useSummary } from './useSummary'; + +// 类型导出 +export type { + SummaryLength, + SummaryStyle, + SummaryOptions as SummaryOptionsType, + SummaryStatus, + SummaryData, + SummaryMessage, + GenerateSummaryRequest, + GenerateSummaryResponse, + UseSummaryReturn, + ModalView, +} from './types'; + +// 常量导出 +export { SUMMARY_LENGTH_CONFIG, SUMMARY_STYLE_CONFIG } from './types'; diff --git a/src/components/features/SummaryGenerator/types.ts b/src/components/features/SummaryGenerator/types.ts new file mode 100644 index 0000000..9e21a1b --- /dev/null +++ b/src/components/features/SummaryGenerator/types.ts @@ -0,0 +1,80 @@ +/** + * 智能摘要功能类型定义 + */ + +// 摘要长度选项 +export type SummaryLength = 'short' | 'standard' | 'detailed'; + +// 摘要风格选项 +export type SummaryStyle = 'bullet' | 'narrative'; + +// 摘要生成选项 +export interface SummaryOptions { + length: SummaryLength; + style: SummaryStyle; +} + +// 摘要长度配置 +export const SUMMARY_LENGTH_CONFIG: Record = { + short: { label: '简短', description: '约50字的核心要点', maxWords: 50 }, + standard: { label: '标准', description: '约150字的详细摘要', maxWords: 150 }, + detailed: { label: '详细', description: '约300字的完整分析', maxWords: 300 }, +}; + +// 摘要风格配置 +export const SUMMARY_STYLE_CONFIG: Record = { + bullet: { label: '要点式', description: '结构化的要点列表' }, + narrative: { label: '叙述式', description: '连贯的段落描述' }, +}; + +// 摘要生成状态 +export type SummaryStatus = 'idle' | 'generating' | 'completed' | 'error'; + +// 摘要数据 +export interface SummaryData { + content: string; // 摘要内容(Markdown) + generatedAt: Date; // 生成时间 + messageCount: number; // 分析的消息数 + options: SummaryOptions; // 生成时使用的选项 +} + +// 摘要生成请求 +export interface GenerateSummaryRequest { + conversationId: string; + options: SummaryOptions; +} + +// 摘要生成响应 +export interface GenerateSummaryResponse { + success: boolean; + summary?: string; + error?: string; + messageCount?: number; +} + +// useSummary Hook 返回类型 +export interface UseSummaryReturn { + // 状态 + status: SummaryStatus; + summary: SummaryData | null; + error: string | null; + streamingContent: string; + + // 选项 + options: SummaryOptions; + setOptions: (options: Partial) => void; + + // 操作 + generate: (conversationId: string, messages: SummaryMessage[]) => Promise; + reset: () => void; + saveSummary: (conversationId: string) => Promise; +} + +// 用于摘要生成的消息格式 +export interface SummaryMessage { + role: 'user' | 'assistant'; + content: string; +} + +// Modal 状态 +export type ModalView = 'options' | 'generating' | 'result';