diff --git a/client/components/app/MediaPlayerContainer.vue b/client/components/app/MediaPlayerContainer.vue index 474b5a598..294a6907f 100644 --- a/client/components/app/MediaPlayerContainer.vue +++ b/client/components/app/MediaPlayerContainer.vue @@ -548,16 +548,19 @@ export default { } }, - // 获取当前书籍的跳过设置 - getBookSkipSettings() { - if (!this.streamLibraryItem) return null - const bookSkipSettings = this.$store.getters['user/getUserSetting']('bookSkipSettings') || {} - return bookSkipSettings[this.streamLibraryItem.id] || {} + // 获取跳过设置 + getSkipSettings() { + return { + skipIntro: this.$store.getters['user/getUserSetting']('skipIntro'), + introDuration: this.$store.getters['user/getUserSetting']('introDuration'), + skipOutro: this.$store.getters['user/getUserSetting']('skipOutro'), + outroDuration: this.$store.getters['user/getUserSetting']('outroDuration') + } }, // 检查并执行章节intro/outro跳过 checkAndSkipIntroOutro(currentTime) { - const skipSettings = this.getBookSkipSettings() + const skipSettings = this.getSkipSettings() if (!skipSettings) return const doSkipIntro = skipSettings.skipIntro && skipSettings.introDuration > 0 diff --git a/client/components/modals/PlayerSettingsModal.vue b/client/components/modals/PlayerSettingsModal.vue index b7bbd1c6a..b116dd996 100644 --- a/client/components/modals/PlayerSettingsModal.vue +++ b/client/components/modals/PlayerSettingsModal.vue @@ -17,11 +17,10 @@
- - -
-

本书跳过设置

- + +
+

章节跳过设置

+
@@ -30,7 +29,7 @@
- +
@@ -64,9 +63,6 @@ export default { jumpBackwardAmount: 10, playbackRateIncrementDecrementValues: [0.1, 0.05], playbackRateIncrementDecrement: 0.1, - - // 书籍跳过设置 - currentLibraryItemId: null, skipIntro: false, introDuration: 10, skipOutro: false, @@ -99,67 +95,37 @@ export default { this.playbackRateIncrementDecrement = val this.$store.dispatch('user/updateUserSettings', { playbackRateIncrementDecrement: val }) }, - - // 书籍跳过设置方法 setSkipIntro() { - this.updateBookSkipSetting('skipIntro', this.skipIntro) + this.$store.dispatch('user/updateUserSettings', { skipIntro: this.skipIntro }) }, setIntroDuration() { this.introDuration = Math.max(0, Math.min(60, parseInt(this.introDuration) || 0)) - this.updateBookSkipSetting('introDuration', this.introDuration) + this.$store.dispatch('user/updateUserSettings', { introDuration: this.introDuration }) }, setSkipOutro() { - this.updateBookSkipSetting('skipOutro', this.skipOutro) + this.$store.dispatch('user/updateUserSettings', { skipOutro: this.skipOutro }) }, setOutroDuration() { this.outroDuration = Math.max(0, Math.min(60, parseInt(this.outroDuration) || 0)) - this.updateBookSkipSetting('outroDuration', this.outroDuration) - }, - updateBookSkipSetting(key, value) { - if (!this.currentLibraryItemId) return - - const bookSkipSettings = { ...this.$store.getters['user/getUserSetting']('bookSkipSettings') || {} } - if (!bookSkipSettings[this.currentLibraryItemId]) { - bookSkipSettings[this.currentLibraryItemId] = {} - } - bookSkipSettings[this.currentLibraryItemId][key] = value - this.$store.dispatch('user/updateUserSettings', { bookSkipSettings }) + this.$store.dispatch('user/updateUserSettings', { outroDuration: this.outroDuration }) }, settingsUpdated() { this.useChapterTrack = this.$store.getters['user/getUserSetting']('useChapterTrack') this.jumpForwardAmount = this.$store.getters['user/getUserSetting']('jumpForwardAmount') this.jumpBackwardAmount = this.$store.getters['user/getUserSetting']('jumpBackwardAmount') this.playbackRateIncrementDecrement = this.$store.getters['user/getUserSetting']('playbackRateIncrementDecrement') - - // 加载当前书籍的跳过设置 - this.loadBookSkipSettings() - }, - loadBookSkipSettings() { - // 获取当前播放的书籍ID - const mediaPlayerContainer = this.$root.$refs.mediaPlayerContainer || this.$parent.$refs.mediaPlayerContainer - if (mediaPlayerContainer && mediaPlayerContainer.streamLibraryItem) { - this.currentLibraryItemId = mediaPlayerContainer.streamLibraryItem.id - - const bookSkipSettings = this.$store.getters['user/getUserSetting']('bookSkipSettings') || {} - const currentBookSettings = bookSkipSettings[this.currentLibraryItemId] || {} - - this.skipIntro = currentBookSettings.skipIntro || false - this.introDuration = currentBookSettings.introDuration || 10 - this.skipOutro = currentBookSettings.skipOutro || false - this.outroDuration = currentBookSettings.outroDuration || 10 - } else { - this.currentLibraryItemId = null - } + this.skipIntro = this.$store.getters['user/getUserSetting']('skipIntro') || false + this.introDuration = this.$store.getters['user/getUserSetting']('introDuration') || 10 + this.skipOutro = this.$store.getters['user/getUserSetting']('skipOutro') || false + this.outroDuration = this.$store.getters['user/getUserSetting']('outroDuration') || 10 } }, mounted() { this.settingsUpdated() this.$eventBus.$on('user-settings', this.settingsUpdated) - this.$eventBus.$on('playback-session-changed', this.loadBookSkipSettings) }, beforeDestroy() { this.$eventBus.$off('user-settings', this.settingsUpdated) - this.$eventBus.$off('playback-session-changed', this.loadBookSkipSettings) } } diff --git a/client/store/user.js b/client/store/user.js index e8bfb3da3..d702dd386 100644 --- a/client/store/user.js +++ b/client/store/user.js @@ -19,7 +19,10 @@ export const state = () => ({ authorSortDesc: false, jumpForwardAmount: 10, jumpBackwardAmount: 10, - bookSkipSettings: {} // 书籍跳过配置 { [libraryItemId]: { skipIntro, introDuration, skipOutro, outroDuration } } + skipIntro: false, + introDuration: 10, + skipOutro: false, + outroDuration: 10 } })