Skip to content

Commit 04aea79

Browse files
authored
Merge pull request #17 from LeafCreeper/copilot/add-switch-to-transcript-button
feat: Add transcript/summary toggle button in course detail view
2 parents 0d7abf8 + 51b5d19 commit 04aea79

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

frontend/index.html

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@
8888
</svg>
8989
</button>
9090
<!-- Edit (detail view, desktop) -->
91+
<button x-show="view === 'detail' && currentLecture?.transcript"
92+
@click="showTranscript = !showTranscript"
93+
class="hidden md:block text-sm bg-gray-100 text-gray-700 px-3 py-1.5 rounded-lg hover:bg-gray-200"
94+
x-text="showTranscript ? '切换到摘要' : '切换到转录'">
95+
</button>
9196
<button x-show="view === 'detail' && currentLecture?.state === 'ready'"
9297
@click="startEdit()"
9398
class="hidden md:block text-sm bg-blue-500 text-white px-3 py-1.5 rounded-lg hover:bg-blue-600">
@@ -309,17 +314,31 @@ <h4 class="font-medium text-gray-800 text-sm truncate" x-text="lec.sub_title ||
309314
<template x-if="currentLecture">
310315
<div>
311316
<!-- Metadata -->
312-
<p x-show="currentLecture.summary_model"
317+
<p x-show="!showTranscript && currentLecture.summary_model"
313318
class="text-xs text-gray-400 mb-4">
314319
Generated by <span x-text="currentLecture.summary_model"></span>
315320
</p>
316321

317322
<!-- Rendered summary -->
318-
<div class="prose"
323+
<div x-show="!showTranscript"
324+
class="prose"
319325
x-html="renderMd(currentLecture.summary || '')"
320-
x-effect="currentLecture && $nextTick(() => activateKaTeX($el))">
326+
x-effect="!showTranscript && currentLecture && $nextTick(() => activateKaTeX($el))">
327+
</div>
328+
329+
<!-- Transcript -->
330+
<div x-show="showTranscript"
331+
class="prose whitespace-pre-wrap text-sm text-gray-700"
332+
x-text="currentLecture.transcript || ''">
321333
</div>
322334

335+
<!-- Mobile toggle button -->
336+
<button x-show="currentLecture.transcript"
337+
@click="showTranscript = !showTranscript"
338+
class="md:hidden fixed left-5 bottom-24 text-xs bg-gray-100 text-gray-700 px-3 py-2 rounded-full shadow hover:bg-gray-200 z-20"
339+
x-text="showTranscript ? '切换到摘要' : '切换到转录'">
340+
</button>
341+
323342
<!-- FAB edit button (mobile) -->
324343
<button x-show="currentLecture.state === 'ready'"
325344
@click="startEdit()"

frontend/js/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ document.addEventListener("alpine:init", () => {
122122
currentCourse: null, currentLecture: null,
123123
searchQuery: "", searchResults: [],
124124
editText: "", editPreview: false, saving: false,
125+
showTranscript: false,
125126
commitSha: null,
126127
setup: { token: "", stuid: "", uispsw: "", dashscope: "", smtp: "" },
127128
setupError: "", setupTesting: false,
@@ -201,7 +202,7 @@ document.addEventListener("alpine:init", () => {
201202
this.currentCourse = this.courses.find(x => x.course_id === params.courseId) || { course_id: params.courseId, title: "...", teacher: "" };
202203
this.lectures = ICS.db.getLectures(params.courseId);
203204
}
204-
else if (view === "detail" && params.subId) { this.currentLecture = ICS.db.getLecture(params.subId); }
205+
else if (view === "detail" && params.subId) { this.currentLecture = ICS.db.getLecture(params.subId); this.showTranscript = false; }
205206
else if (view === "edit") { this.editText = this.currentLecture?.summary || ""; this.editPreview = false; }
206207
this.view = view;
207208
},

0 commit comments

Comments
 (0)