增加阅读是pdf中高亮显示

This commit is contained in:
yhy
2026-08-29 22:46:28 +08:00
parent 3a2438f566
commit 1475f8b3c5
17 changed files with 2125 additions and 95 deletions
@@ -14,14 +14,46 @@ export interface StoredBeat {
ttsStatus: "pending" | "ready" | "failed";
}
export interface StoredSentence {
id: string;
orderIndex: number;
text: string;
translation: string;
page?: number;
searchText?: string;
audioPathEn?: string;
audioPathZh?: string;
ttsEnStatus: "pending" | "ready" | "failed" | "skipped";
ttsZhStatus: "pending" | "ready" | "failed";
}
export interface StoredParagraph {
id: string;
orderIndex: number;
originalText: string;
translation: string;
contextLink: string;
roleInPaper: string;
page?: number;
searchText?: string;
sentences?: StoredSentence[];
audioPathEn?: string;
audioPathZh?: string;
ttsEnStatus: "pending" | "ready" | "failed" | "skipped";
ttsZhStatus: "pending" | "ready" | "failed";
genStatus: "pending" | "ready" | "failed";
}
export interface LectureData {
paperId: string;
cacheKey: string;
/** 1 = summary only, 2 = beats + TTS (Step 1) */
phase?: 1 | 2;
/** 1 = summary, 2 = beats+TTS, 3 = paragraphs+note */
phase?: 1 | 2 | 3;
summary?: SummaryJson;
chunks?: TextChunk[];
beats?: StoredBeat[];
paragraphs?: StoredParagraph[];
noteItemId?: string;
extractChars?: number;
extractSource?: string;
updatedAt: number;
@@ -89,7 +121,27 @@ export function isStep1Ready(data: LectureData | undefined): boolean {
return data.beats.some((b) => b.ttsStatus === "ready" && b.audioPath);
}
export function isStep2Ready(data: LectureData | undefined): boolean {
if (!data?.paragraphs?.length) return false;
return data.paragraphs.some(
(p) => p.genStatus === "ready" && p.ttsZhStatus === "ready" && p.audioPathZh,
);
}
export function isLectureComplete(data: LectureData | undefined): boolean {
return isStep1Ready(data) && isStep2Ready(data);
}
export function playableBeats(data: LectureData | undefined): StoredBeat[] {
if (!data?.beats) return [];
return data.beats.filter((b) => b.ttsStatus === "ready" && b.audioPath);
}
export function playableParagraphs(
data: LectureData | undefined,
): StoredParagraph[] {
if (!data?.paragraphs) return [];
return data.paragraphs.filter(
(p) => p.genStatus === "ready" && p.ttsZhStatus === "ready" && p.audioPathZh,
);
}