fix:基本实现相关功能
This commit is contained in:
24
src/shared/types/IReadingReflectionTask.ts
Normal file
24
src/shared/types/IReadingReflectionTask.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 对应数据库中的批次记录 (主任务)
|
||||
*/
|
||||
export interface IReadingReflectionTaskBatch {
|
||||
id: string
|
||||
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[]
|
||||
}
|
||||
36
src/shared/types/reflections.ts
Normal file
36
src/shared/types/reflections.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
/**
|
||||
* 读者职业枚举
|
||||
*/
|
||||
export type Occupation = 'student' | 'teacher' | 'professional' | 'researcher' | 'other'
|
||||
|
||||
/**
|
||||
* 读书心得生成请求任务模型
|
||||
*/
|
||||
export const ReadingReflectionsTaskSchema = z.object({
|
||||
bookName: z.string().min(1, '书名不能为空'),
|
||||
author: z.string().optional(),
|
||||
description: z.string(),
|
||||
occupation: z.enum(['student', 'teacher', 'professional', 'researcher', 'other']),
|
||||
prompt: z.string(),
|
||||
wordCount: z.number().default(1000),
|
||||
quantity: z.number().min(1).max(5).default(1),
|
||||
language: z.enum(['zh', 'en']).optional(),
|
||||
tone: z.string().optional()
|
||||
})
|
||||
export type ReadingReflectionsTask = z.infer<typeof ReadingReflectionsTaskSchema>
|
||||
|
||||
/**
|
||||
* 任务响应结果模型
|
||||
*/
|
||||
export interface ReadingReflectionsResponse {
|
||||
taskId: string
|
||||
reflections: Array<{
|
||||
title: string // 心得标题
|
||||
content: string // 心得正文
|
||||
keywords: string[] // 提取的关键词
|
||||
summary: string // 内容摘要
|
||||
}>
|
||||
status: 'pending' | 'completed' | 'failed'
|
||||
}
|
||||
28
src/shared/utils/logger.ts
Normal file
28
src/shared/utils/logger.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import log from 'electron-log/main'
|
||||
import { EventEmitter } from 'events'
|
||||
|
||||
export const logEvent = new EventEmitter()
|
||||
|
||||
// 自定义不同级别的颜色(仅对控制台有效)
|
||||
log.transports.console.level = 'debug'
|
||||
log.hooks.push((message, transport) => {
|
||||
if (transport === log.transports.console) {
|
||||
if (message.level === 'error') {
|
||||
message.data[0] = `\x1b[31m${message.data[0]}\x1b[0m` // 红色
|
||||
} else if (message.level === 'info') {
|
||||
message.data[0] = `\x1b[32m${message.data[0]}\x1b[0m` // 绿色
|
||||
}
|
||||
}
|
||||
return message
|
||||
})
|
||||
|
||||
/**
|
||||
* 发布日志
|
||||
* @param message 日志信息
|
||||
* */
|
||||
log.hooks.push((message) => {
|
||||
logEvent.emit('log', message)
|
||||
return message
|
||||
})
|
||||
|
||||
export default log
|
||||
Reference in New Issue
Block a user