This commit is contained in:
juneix
2026-04-19 14:12:23 +08:00
parent 5ae163db13
commit 14c5ca32ce
6 changed files with 490 additions and 15 deletions
+32 -7
View File
@@ -1899,16 +1899,36 @@
lucide.createIcons();
}
executeDelete() {
async executeDelete() {
const item = this.state.videos[this.state.currentIndex];
if (!item) return;
fetch(`${this.config.server}/emby/Items/${item.Id}?api_key=${this.config.token}`, {
method: 'DELETE'
}).then(() => {
try {
// 注意:Emby 删除 API 需要管理员账号,普通用户会返回 403
// 必须检查 res.ok,否则 403/404 也会被当成成功处理,导致前端假删除
const res = await fetch(`${this.config.server}/emby/Items/${item.Id}?api_key=${this.config.token}`, {
method: 'DELETE'
});
if (!res.ok) {
// 403:账号无管理权限;404:视频已不存在(也从列表移除)
if (res.status === 403) {
this.showToast('❌ 权限不足,请使用管理员账号');
this.toggleModal('deleteConfirmModal', false);
return;
}
if (res.status !== 404) {
this.showToast(`❌ 删除失败 (${res.status})`);
this.toggleModal('deleteConfirmModal', false);
return;
}
// 404 视为已删除,继续从列表移除
}
this.showToast('✅ 已删除');
this.state.videos.splice(this.state.currentIndex, 1);
this.toggleModal('deleteConfirmModal', false);
if (this.state.viewMode === 'grid') {
this.renderGridView();
} else {
@@ -1916,12 +1936,17 @@
if (this.state.currentIndex >= this.state.videos.length) {
this.state.currentIndex = Math.max(0, this.state.videos.length - 1);
}
// 修复:renderSlides 只重建 DOM,必须再调用 loadVideo+playVideo 才能自动播放
this.renderSlides();
if (this.state.videos.length > 0) {
this.loadVideo(this.state.currentIndex);
this.playVideo(this.state.currentIndex);
}
}
}).catch(() => {
this.showToast('❌ 删除失败');
} catch (e) {
this.showToast('❌ 删除失败:网络错误');
this.toggleModal('deleteConfirmModal', false);
});
}
}
showInterfaceTemp() {