@@ -6,7 +6,6 @@ import { toast } from "@/hooks/use-toast"
66import useArticleStore from "@/stores/article"
77import useVectorStore from "@/stores/vector"
88import { readTextFile } from "@tauri-apps/plugin-fs"
9- import { computedParentPath } from "@/lib/path"
109import { useState , useEffect } from "react"
1110import { useTranslations } from "next-intl"
1211
@@ -21,7 +20,7 @@ interface VectorKnowledgeMenuProps {
2120
2221export function VectorKnowledgeMenu ( { item, hasVector, onVectorUpdated } : VectorKnowledgeMenuProps ) {
2322 const t = useTranslations ( 'article.file' )
24- const { vectorIndexedFiles , clearFileVector, checkFileVectorIndexed } = useArticleStore ( )
23+ const { clearFileVector, checkFileVectorIndexed } = useArticleStore ( )
2524 const [ autoCalcEnabled , setAutoCalcEnabled ] = useState ( true )
2625 const [ excludeFromKB , setExcludeFromKB ] = useState ( false )
2726
@@ -43,22 +42,20 @@ export function VectorKnowledgeMenu({ item, hasVector, onVectorUpdated }: Vector
4342
4443 try {
4544 // 读取文件内容
46- const { getFilePathOptions, getWorkspacePath } = await import ( '@/lib/workspace' )
47- const workspace = await getWorkspacePath ( )
48- const path = computedParentPath ( item )
49- const pathOptions = await getFilePathOptions ( path )
45+ const { getFilePathOptions } = await import ( '@/lib/workspace' )
46+ const pathOptions = await getFilePathOptions ( item . name )
5047
5148 let content = ''
52- if ( workspace . isCustom ) {
53- content = await readTextFile ( pathOptions . path )
54- } else {
49+ if ( pathOptions . baseDir ) {
5550 content = await readTextFile ( pathOptions . path , { baseDir : pathOptions . baseDir } )
51+ } else {
52+ content = await readTextFile ( pathOptions . path )
5653 }
5754
5855 // 执行向量计算
5956 const vectorStore = useVectorStore . getState ( )
6057 if ( vectorStore . isVectorDbEnabled ) {
61- await vectorStore . processDocument ( path , content )
58+ await vectorStore . processDocument ( pathOptions . path , content )
6259
6360 // 更新向量索引状态
6461 await checkFileVectorIndexed ( item . name )
0 commit comments