refactor(loader): Replace app.getPath with getTempDir in EpubLoader

Use the new getTempDir utility function from file.ts to generate temporary file paths, maintaining consistency with recent file path utility refactoring
This commit is contained in:
kangfenmao 2025-03-09 20:22:46 +08:00
parent 8001144c00
commit e6477f7f77

View File

@ -1,7 +1,7 @@
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters'
import { BaseLoader } from '@llm-tools/embedjs-interfaces'
import { cleanString } from '@llm-tools/embedjs-utils'
import { app } from 'electron'
import { getTempDir } from '@main/utils/file'
import Logger from 'electron-log'
import EPub from 'epub'
import * as fs from 'fs'
@ -160,7 +160,7 @@ export class EpubLoader extends BaseLoader<Record<string, string | number | bool
}
// 使用临时文件而不是内存数组
const tempFilePath = path.join(app.getPath('temp'), `epub-${Date.now()}.txt`)
const tempFilePath = path.join(getTempDir(), `epub-${Date.now()}.txt`)
const writeStream = fs.createWriteStream(tempFilePath)
// 遍历所有章节