title modification
This commit is contained in:
@@ -114,6 +114,6 @@
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script src="/static/admin.js?v=admin-merge-sentence-v1" defer></script>
|
||||
<script src="/static/admin.js?v=admin-course-title-v1" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -181,6 +181,7 @@ function actionCell(video) {
|
||||
play.rel = "noopener";
|
||||
play.textContent = "播放";
|
||||
actions.append(play);
|
||||
actions.append(button("改标题", () => renameVideo(video)));
|
||||
actions.append(button("句子", () => openSentences(video)));
|
||||
actions.append(button("重新处理", () => reprocess(video.video_hash)));
|
||||
const remove = button("删除", () => deleteVideo(video));
|
||||
@@ -198,6 +199,28 @@ function button(label, handler) {
|
||||
return result;
|
||||
}
|
||||
|
||||
async function renameVideo(video) {
|
||||
const title = window.prompt("请输入新的课程标题", video.title || "");
|
||||
if (title === null) return;
|
||||
const cleanedTitle = title.trim();
|
||||
if (!cleanedTitle) {
|
||||
elements.serviceState.textContent = "课程标题不能为空";
|
||||
return;
|
||||
}
|
||||
if (cleanedTitle === video.title) return;
|
||||
try {
|
||||
await api(`/api/v1/admin/videos/${video.video_hash}/title`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ title: cleanedTitle }),
|
||||
});
|
||||
elements.serviceState.textContent = "课程标题已更新";
|
||||
await loadVideos();
|
||||
} catch (error) {
|
||||
elements.serviceState.textContent = `标题修改失败: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
function uploadVideo(event) {
|
||||
event.preventDefault();
|
||||
const file = document.querySelector("#video-file").files[0];
|
||||
|
||||
Reference in New Issue
Block a user