feat: implement getFilePath method in FileManager and update KnowledgeContent to use it

- Added getFilePath method in FileManager to construct file paths based on file ID and extension.
- Updated KnowledgeContent to utilize the new getFilePath method for opening file paths, improving code clarity and maintainability.
This commit is contained in:
kangfenmao 2025-05-20 18:04:01 +08:00
parent 4838a02785
commit e0774e49cc
2 changed files with 6 additions and 1 deletions

View File

@ -328,7 +328,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
key={item.id}
fileInfo={{
name: (
<ClickableSpan onClick={() => window.api.file.openPath(file.path)}>
<ClickableSpan onClick={() => window.api.file.openPath(FileManager.getFilePath(file))}>
<Ellipsis>
<Tooltip title={file.origin_name}>{file.origin_name}</Tooltip>
</Ellipsis>

View File

@ -70,6 +70,11 @@ class FileManager {
return file
}
static getFilePath(file: FileType) {
const filesPath = store.getState().runtime.filesPath
return filesPath + '/' + file.id + file.ext
}
static async deleteFile(id: string, force: boolean = false): Promise<void> {
const file = await this.getFile(id)