Skip to content

Commit 59f876c

Browse files
committed
fix(#243): 暂时移除 pdf 文件读取
1 parent 74d2c71 commit 59f876c

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

src/app/core/record/mark/control-file.tsx

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import { TooltipButton } from "@/components/tooltip-button"
22
import { FilePlus } from "lucide-react"
33
import { useTranslations } from 'next-intl'
44
import { open } from '@tauri-apps/plugin-dialog';
5-
import { readTextFile, readFile } from "@tauri-apps/plugin-fs";
5+
import { readTextFile } from "@tauri-apps/plugin-fs";
66
import useTagStore from "@/stores/tag";
77
import useMarkStore from "@/stores/mark";
88
import { insertMark } from "@/db/marks";
9-
import { getDocument } from 'pdfjs-dist'
10-
import "pdfjs-dist/build/pdf.worker.mjs";
119

1210
const textFileExtensions = ['txt', 'md', 'csv'];
13-
const fileExtensions = ['pdf']
11+
const fileExtensions: string[] = []
1412

1513
export function ControlFile() {
1614
const t = useTranslations();
@@ -40,29 +38,6 @@ export function ControlFile() {
4038
await fetchTags()
4139
getCurrentTag()
4240
}
43-
if (ext === 'pdf') {
44-
const file = await readFile(path)
45-
getDocument(file).promise.then(pdf => {
46-
const numPages = pdf.numPages;
47-
for (let i = 1; i <= numPages; i++) {
48-
pdf.getPage(i).then(page => {
49-
page.getTextContent().then(content => {
50-
const text = content.items.map(item => {
51-
if ('str' in item) {
52-
return item.str
53-
}
54-
return ''
55-
}).join('');
56-
if (!text) return
57-
insertMark({ tagId: currentTagId, type: 'file', desc: text, content: text })
58-
fetchMarks()
59-
fetchTags()
60-
getCurrentTag()
61-
});
62-
});
63-
}
64-
})
65-
}
6641
}
6742

6843
return (

0 commit comments

Comments
 (0)