fix: 修复无法正常选择文本文档的问题

This commit is contained in:
kangfenmao 2024-10-12 14:56:17 +08:00
parent 1ccb5edda7
commit de5db4f805
6 changed files with 8 additions and 8 deletions

View File

@ -174,7 +174,7 @@ class FileManager {
} }
public readFile = async (_: Electron.IpcMainInvokeEvent, id: string): Promise<string> => { public readFile = async (_: Electron.IpcMainInvokeEvent, id: string): Promise<string> => {
const filePath = id.includes('/') ? id : path.join(this.storageDir, id) const filePath = path.join(this.storageDir, id)
if (documentExts.includes(path.extname(filePath))) { if (documentExts.includes(path.extname(filePath))) {
return await officeParser.parseOfficeAsync(filePath) return await officeParser.parseOfficeAsync(filePath)

View File

@ -90,7 +90,7 @@
"input.send": "Send", "input.send": "Send",
"input.pause": "Pause", "input.pause": "Pause",
"input.settings": "Settings", "input.settings": "Settings",
"input.upload": "Upload image or text file", "input.upload": "Upload image or document file",
"input.context_count.tip": "Context Count", "input.context_count.tip": "Context Count",
"input.estimated_tokens.tip": "Estimated tokens", "input.estimated_tokens.tip": "Estimated tokens",
"settings.temperature": "Temperature", "settings.temperature": "Temperature",

View File

@ -90,7 +90,7 @@
"input.send": "发送", "input.send": "发送",
"input.pause": "暂停", "input.pause": "暂停",
"input.settings": "设置", "input.settings": "设置",
"input.upload": "上传图片或纯文本文件", "input.upload": "上传图片或文档",
"input.context_count.tip": "上下文数", "input.context_count.tip": "上下文数",
"input.estimated_tokens.tip": "预估 token 数", "input.estimated_tokens.tip": "预估 token 数",
"settings.temperature": "模型温度", "settings.temperature": "模型温度",

View File

@ -90,7 +90,7 @@
"input.send": "發送", "input.send": "發送",
"input.pause": "暫停", "input.pause": "暫停",
"input.settings": "設定", "input.settings": "設定",
"input.upload": "上傳圖片或文檔", "input.upload": "上傳圖片或文檔",
"input.context_count.tip": "上下文數量", "input.context_count.tip": "上下文數量",
"input.estimated_tokens.tip": "預估 Token 數", "input.estimated_tokens.tip": "預估 Token 數",
"settings.temperature": "溫度", "settings.temperature": "溫度",

View File

@ -15,7 +15,9 @@ interface Props {
const AttachmentButton: FC<Props> = ({ model, files, setFiles, ToolbarButton }) => { const AttachmentButton: FC<Props> = ({ model, files, setFiles, ToolbarButton }) => {
const { t } = useTranslation() const { t } = useTranslation()
const extensions = isVisionModel(model) ? [...imageExts, ...textExts, ...documentExts] : [...textExts] const extensions = isVisionModel(model)
? [...imageExts, ...documentExts, ...textExts]
: [...documentExts, ...textExts]
const onSelectFile = async () => { const onSelectFile = async () => {
if (files.length > 0) { if (files.length > 0) {

View File

@ -17,10 +17,8 @@ async function getFileContent(file: FileType) {
return '' return ''
} }
const fileId = file.id + file.ext
if (file.type === FileTypes.TEXT) { if (file.type === FileTypes.TEXT) {
return await window.api.file.read(fileId) return await window.api.file.read(file.id + file.ext)
} }
return '' return ''