feat(desktop): ✨ 优化一些逻辑
1. 优化通知配置 2. 优化命名规范 3. 优化代码逻辑
This commit is contained in:
32
src/shared/types/IConfig.ts
Normal file
32
src/shared/types/IConfig.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
/**
|
||||
* 大模型类型枚举
|
||||
* */
|
||||
export type LLMType = 'reading' | 'summary'
|
||||
|
||||
/**
|
||||
* 定义大模型配置
|
||||
* */
|
||||
export const ILLMConfigSchema = z.object({
|
||||
type: z.enum(['reading', 'summary']), // 明确支持 reading
|
||||
config: z.object({
|
||||
apiKey: z.string(), // api key
|
||||
baseURL: z.string(), // base url
|
||||
modelName: z.string(), // 模型名称
|
||||
temperature: z.number() // 模型温度
|
||||
})
|
||||
})
|
||||
export type ILLMConfig = z.infer<typeof ILLMConfigSchema>
|
||||
|
||||
/**
|
||||
* 定义通知配置
|
||||
* */
|
||||
export const INoticeConfigSchema = z.object({
|
||||
masterSwitch: z.boolean().default(true), // 总开关
|
||||
taskCompleted: z.boolean().default(true), // 任务完成时提醒
|
||||
taskFailed: z.boolean().default(true), // 任务失败时提醒
|
||||
silentMode: z.boolean().default(false) // 静默模式(仅弹窗无声音)
|
||||
})
|
||||
|
||||
export type INoticeConfig = z.infer<typeof INoticeConfigSchema>
|
||||
@@ -1,3 +1,40 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
/**
|
||||
* 读者职业枚举
|
||||
*/
|
||||
export type Occupation = 'student' | 'teacher' | 'professional' | 'researcher' | 'other'
|
||||
|
||||
/**
|
||||
* 读书心得生成请求任务模型
|
||||
*/
|
||||
export const IReadingReflectionsTaskSchema = 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 IReadingReflectionsTask = z.infer<typeof IReadingReflectionsTaskSchema>
|
||||
|
||||
/**
|
||||
* 任务响应结果模型
|
||||
*/
|
||||
export interface IReadingReflectionsResponse {
|
||||
taskId: string
|
||||
reflections: Array<{
|
||||
title: string // 心得标题
|
||||
content: string // 心得正文
|
||||
keywords: string[] // 提取的关键词
|
||||
summary: string // 内容摘要
|
||||
}>
|
||||
status: 'pending' | 'completed' | 'failed'
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应数据库中的批次记录 (主任务)
|
||||
*/
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
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'
|
||||
}
|
||||
Reference in New Issue
Block a user