diff --git a/.DS_Store b/.DS_Store index 768d495..76ef1b7 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/en/index.html b/en/index.html index c476608..d2239ff 100644 --- a/en/index.html +++ b/en/index.html @@ -598,16 +598,29 @@ this.state.isAutoplay = this.config.autoplay !== false; + // Sync UI based on loaded stated + if (this.dom.muteBtn) { + const iconName = this.state.isMuted ? 'volume-x' : 'volume-2'; + const iconColor = this.state.isMuted ? 'text-secondary' : 'stroke-white'; + this.dom.muteBtn.innerHTML = `
`; + } + if (this.dom.scaleBtn) { + this.dom.scaleBtn.innerHTML = `
`; + } + const viewBtn = this.dom.viewModeBtn; viewBtn.innerHTML = ``; const playBtn = this.dom.playModeBtn; - playBtn.innerHTML = ``; + // If random mode is saved, show shuffle icon. Otherwise show repeat/repeat-1 based on isAutoplay + const isSeq = this.state.playMode === 'sequence'; + const playIcon = isSeq ? (this.state.isAutoplay ? 'repeat' : 'repeat-1') : 'shuffle'; + playBtn.innerHTML = ``; lucide.createIcons(); if (this.config.server && this.config.token) { - this.fetchVideos(); + this.fetchVideos(this.state.currentLibraryId); } else { setTimeout(() => this.toggleModal('profilePage', true), 500); } @@ -636,6 +649,22 @@ this.config.autoplay = localStorage.getItem('emby_autoplay') !== 'false'; this.config.deleteMode = localStorage.getItem('emby_delete_mode') === 'true'; + const savedScale = localStorage.getItem('emby_is_scale_fill'); + if (savedScale !== null) this.state.isScaleFill = savedScale === 'true'; + + const savedMute = localStorage.getItem('emby_is_muted'); + if (savedMute !== null) this.state.isMuted = savedMute === 'true'; + + const savedPlayMode = localStorage.getItem('emby_play_mode'); + if (savedPlayMode !== null) this.state.playMode = savedPlayMode; + + const savedLibId = localStorage.getItem('emby_lib_id'); + const savedLibType = localStorage.getItem('emby_lib_type'); + if (savedLibId) { + this.state.currentLibraryId = savedLibId; + this.state.currentLibraryType = savedLibType || 'library'; + } + if (this.dom.configServer) this.dom.configServer.value = this.config.server; if (this.dom.configUser) this.dom.configUser.value = this.config.user; if (this.dom.configPwd && this.config.token) { @@ -1592,6 +1621,8 @@ div.onclick = () => { this.state.currentLibraryId = pl.Id; this.state.currentLibraryType = 'playlist'; + localStorage.setItem('emby_lib_id', pl.Id); + localStorage.setItem('emby_lib_type', 'playlist'); this.state.currentTab = 'home'; this.updateTabHighlight(); this.fetchVideos(pl.Id); @@ -1616,6 +1647,8 @@ div.onclick = () => { this.state.currentLibraryId = lib.Id; this.state.currentLibraryType = 'library'; + localStorage.setItem('emby_lib_id', lib.Id); + localStorage.setItem('emby_lib_type', 'library'); this.state.currentTab = 'home'; this.updateTabHighlight(); this.fetchVideos(lib.Id); @@ -1781,6 +1814,7 @@ togglePlayMode() { const isSeq = this.state.playMode === 'sequence'; this.state.playMode = isSeq ? 'random' : 'sequence'; + localStorage.setItem('emby_play_mode', this.state.playMode); const btn = this.dom.playModeBtn; btn.innerHTML = ``; @@ -1848,6 +1882,7 @@ toggleScaleMode() { this.state.isScaleFill = !this.state.isScaleFill; + localStorage.setItem('emby_is_scale_fill', this.state.isScaleFill); const videos = document.querySelectorAll('.video-fullscreen'); videos.forEach((v, index) => { v.classList.remove('object-cover', 'object-contain'); @@ -1991,6 +2026,7 @@ this.dom.muteBtn.onclick = (e) => { e.stopPropagation(); this.state.isMuted = !this.state.isMuted; + localStorage.setItem('emby_is_muted', this.state.isMuted); const slideIdx = (this.state.currentIndex % 3 + 3) % 3; const v = document.getElementById(`video-p${slideIdx}`); diff --git a/zh/index.html b/zh/index.html index daec2bb..c6cff91 100644 --- a/zh/index.html +++ b/zh/index.html @@ -629,22 +629,35 @@ this.loadFavorites(); this.bindEvents(); - // 根据配置设置自动连播状态(只影响视频自动播放,不隐藏界面) this.state.isAutoplay = this.config.autoplay !== false; + // 根据持久化状态同步 UI 图标 + if (this.dom.muteBtn) { + const iconName = this.state.isMuted ? 'volume-x' : 'volume-2'; + const iconColor = this.state.isMuted ? 'text-secondary' : 'stroke-white'; + this.dom.muteBtn.innerHTML = `
`; + } + if (this.dom.scaleBtn) { + this.dom.scaleBtn.innerHTML = `
`; + } + // 初始化视图模式按钮图标(默认竖版,显示gallery-vertical) const viewBtn = this.dom.viewModeBtn; viewBtn.innerHTML = ``; - // 初始化播放模式按钮图标(根据自动连播配置) + // 初始化播放模式按钮图标 const playBtn = this.dom.playModeBtn; - playBtn.innerHTML = ``; + // 若为随机模式,显示 shuffle;否则根据是否自动连播显示 repeat 或 repeat-1 + const isSeq = this.state.playMode === 'sequence'; + const playIcon = isSeq ? (this.state.isAutoplay ? 'repeat' : 'repeat-1') : 'shuffle'; + playBtn.innerHTML = ``; lucide.createIcons(); // 检查配置并启动 if (this.config.server && this.config.token) { - this.fetchVideos(); + // 若存在上次保存的库/播放列表,优先加载 + this.fetchVideos(this.state.currentLibraryId); } else { setTimeout(() => this.toggleModal('profilePage', true), 500); } @@ -674,6 +687,23 @@ this.config.autoplay = localStorage.getItem('emby_autoplay') !== 'false'; this.config.deleteMode = localStorage.getItem('emby_delete_mode') === 'true'; + // 读取高频交互状态 + const savedScale = localStorage.getItem('emby_is_scale_fill'); + if (savedScale !== null) this.state.isScaleFill = savedScale === 'true'; + + const savedMute = localStorage.getItem('emby_is_muted'); + if (savedMute !== null) this.state.isMuted = savedMute === 'true'; + + const savedPlayMode = localStorage.getItem('emby_play_mode'); + if (savedPlayMode !== null) this.state.playMode = savedPlayMode; + + const savedLibId = localStorage.getItem('emby_lib_id'); + const savedLibType = localStorage.getItem('emby_lib_type'); + if (savedLibId) { + this.state.currentLibraryId = savedLibId; + this.state.currentLibraryType = savedLibType || 'library'; + } + // 填充 UI if (this.dom.configServer) this.dom.configServer.value = this.config.server; if (this.dom.configUser) this.dom.configUser.value = this.config.user; @@ -1691,12 +1721,14 @@ favDiv.innerHTML = `收藏夹${isFavSelected ? '' : ''}`; favDiv.onclick = () => { this.state.currentLibraryId = 'favorites'; + this.state.currentLibraryType = 'favorites'; + localStorage.setItem('emby_lib_id', 'favorites'); + localStorage.setItem('emby_lib_type', 'favorites'); this.state.currentTab = 'favorites'; if (this.state.favorites.size === 0) { this.showToast('暂无收藏'); return; } - this.state.currentLibraryType = 'favorites'; this.fetchVideos(); this.toggleModal('libraryModal', false); }; @@ -1717,6 +1749,8 @@ div.onclick = () => { this.state.currentLibraryId = pl.Id; this.state.currentLibraryType = 'playlist'; + localStorage.setItem('emby_lib_id', pl.Id); + localStorage.setItem('emby_lib_type', 'playlist'); this.state.currentTab = 'home'; this.updateTabHighlight(); this.fetchVideos(pl.Id); @@ -1741,6 +1775,8 @@ div.onclick = () => { this.state.currentLibraryId = lib.Id; this.state.currentLibraryType = 'library'; + localStorage.setItem('emby_lib_id', lib.Id); + localStorage.setItem('emby_lib_type', 'library'); this.state.currentTab = 'home'; this.updateTabHighlight(); this.fetchVideos(lib.Id); @@ -1767,6 +1803,8 @@ } this.state.currentLibraryId = 'favorites'; this.state.currentLibraryType = 'favorites'; + localStorage.setItem('emby_lib_id', 'favorites'); + localStorage.setItem('emby_lib_type', 'favorites'); this.fetchVideos(); this.toggleModal('libraryModal', false); }; @@ -1922,6 +1960,7 @@ togglePlayMode() { const isSeq = this.state.playMode === 'sequence'; this.state.playMode = isSeq ? 'random' : 'sequence'; + localStorage.setItem('emby_play_mode', this.state.playMode); const btn = this.dom.playModeBtn; btn.innerHTML = ``; @@ -1997,6 +2036,7 @@ toggleScaleMode() { this.state.isScaleFill = !this.state.isScaleFill; + localStorage.setItem('emby_is_scale_fill', this.state.isScaleFill); const videos = document.querySelectorAll('.video-fullscreen'); videos.forEach((v, index) => { v.classList.remove('object-cover', 'object-contain'); @@ -2146,6 +2186,7 @@ this.dom.muteBtn.onclick = (e) => { e.stopPropagation(); this.state.isMuted = !this.state.isMuted; + localStorage.setItem('emby_is_muted', this.state.isMuted); const slideIdx = (this.state.currentIndex % 3 + 3) % 3; const v = document.getElementById(`video-p${slideIdx}`);