feat(desktop): 实现一些功能

1. 实现了用户阅读画像

2. 实现了全局检索功能
This commit is contained in:
2026-01-11 14:40:31 +08:00
parent 75cc9dc06d
commit 48fb287aa7
25 changed files with 1059 additions and 145 deletions

View File

@@ -21,41 +21,27 @@ export const IReadingReflectionsTaskSchema = z.object({
})
export type IReadingReflectionsTask = z.infer<typeof IReadingReflectionsTaskSchema>
/**
* 任务响应结果模型
*/
export interface IReadingReflectionsResponse {
taskId: string
reflections: Array<{
title: string // 心得标题
content: string // 心得正文
keywords: string[] // 提取的关键词
summary: string // 内容摘要
}>
status: 'pending' | 'completed' | 'failed'
}
/**
* 对应数据库中的批次记录 (主任务)
*/
export interface IReadingReflectionTaskBatch {
id: string
bookName: string
totalCount: number
status: string
progress: number
createdAt: Date
items?: IReadingReflectionTaskItem[]
id: string //任务ID
bookName: string // 书籍名称
totalCount: number // 生成数量
status: string // 生成状态
progress: number // 进度
createdAt: Date // 创建时间
items?: IReadingReflectionTaskItem[] // 子任务模块
}
/**
* 对应数据库中的具体任务项 (子任务)
*/
export interface IReadingReflectionTaskItem {
id: string
status: 'PENDING' | 'WRITING' | 'COMPLETED' | 'FAILED'
progress: number
content?: string
title?: string
summary?: string
keywords?: string[]
id: string // 子任务ID
status: 'PENDING' | 'WRITING' | 'COMPLETED' | 'FAILED' // 任务状态
progress: number // 进度
content?: string // 生成内容
title?: string // 生成标题
summary?: string // 生成摘要
keywords?: string[] // 关键词
}

View File

@@ -0,0 +1,24 @@
/**
* 高亮坐标信息
*/
export interface HighlightInfo {
start: number // 关键词在原始字符串中的起始索引(从 0 开始)
length: number // 关键词的长度
}
/**
* 完整的搜索结果接口
*/
export interface ISearch {
id: string
bookName: string
title: string
content: string
contentSnippet: string // 截取的正文片段
createdAt: string
// 对应的坐标数组
titleHighlights: HighlightInfo[]
contentHighlights: HighlightInfo[]
bookHighlights: HighlightInfo[]
}

View File

@@ -0,0 +1,36 @@
/**
* 用户阅读画像统计模型
*/
export interface IUserReadingPersona {
// 维度 1: 领域深度 (Domain Depth)
// 根据关键词(keywords)的聚合频次计算,反映用户在特定领域的钻研程度
domainDepth: {
name: string // 领域名称 (如:认知心理学、前端技术)
score: number // 0-100 的得分
bookCount: number // 该领域下的书籍数量
}[]
// 维度 2: 知识广度 (Knowledge Breadth)
// 根据书名(bookName)和关键词的跨度计算,反映阅读类别的多样性
breadthScore: number
// 维度 3: 产出效率 (Output Efficiency)
// 基于 wordCount(要求字数) 与实际 content(生成内容) 的比例,以及完成频率
efficiencyScore: number
// 维度 4: 角色成熟度 (Persona Maturity)
// 基于 occupation(职业) 字段。例如 student 偏向基础吸收researcher 偏向深度批判
maturityScore: number
// 维度 5: 语言能力 (Language Versatility)
// 基于 language(zh/en) 的分布比例
languageScore: number
// 原始统计辅助数据
stats: {
totalWords: number // 累计生成的心得总字数
totalBooks: number // 累计阅读并生成过心得的书籍总数
topKeywords: string[] // 出现频率最高的 Top 10 关键词
mostUsedOccupation: string // 最常使用的阅读者身份
}
}