diff --git a/src/store/initLocalStorage.js b/src/store/initLocalStorage.js index dce2c85..cf43eb9 100644 --- a/src/store/initLocalStorage.js +++ b/src/store/initLocalStorage.js @@ -1,9 +1,13 @@ import { playlistCategories } from "@/utils/staticData"; +console.log("[debug][initLocalStorage.js]"); +const enabledPlaylistCategories = playlistCategories + .filter((c) => c.enable) + .map((c) => c.name); + let localStorage = { player: {}, settings: { - playlistCategories, lang: null, appearance: "auto", musicQuality: 320000, @@ -20,6 +24,7 @@ let localStorage = { enableDiscordRichPresence: false, enableGlobalShortcut: true, showLibraryDefault: false, + enabledPlaylistCategories, }, data: { user: {}, diff --git a/src/store/mutations.js b/src/store/mutations.js index 70ed9c6..a30b6ce 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -22,16 +22,16 @@ export default { state.data[key] = value; }, togglePlaylistCategory(state, name) { - let cat = state.settings.playlistCategories.find((c) => c.name === name); - cat.enable = !cat.enable; - state.settings.playlistCategories = state.settings.playlistCategories.map( - (c) => { - if (c.name === name) { - return cat; - } - return c; - } + const index = state.settings.enabledPlaylistCategories.findIndex( + (c) => c.name === name ); + if (index !== -1) { + state.settings.enabledPlaylistCategories = state.settings.enabledPlaylistCategories.filter( + (c) => c.name !== name + ); + } else { + state.settings.enabledPlaylistCategories.push(name); + } }, updateToast(state, toast) { state.toast = toast; diff --git a/src/utils/staticData.js b/src/utils/staticData.js index 2f4c417..c4ccbf0 100644 --- a/src/utils/staticData.js +++ b/src/utils/staticData.js @@ -11,7 +11,6 @@ export const byAppleMusic = [ name: "\u4e2d\u563b\u5408\u74a7", id: 5277771961, }, - { coverImgUrl: "https://p1.music.126.net/cPaBXr1wZSg86ddl47AK7Q==/109951165375130918.jpg", @@ -38,6 +37,11 @@ export const playlistCategories = [ enable: true, bigCat: "static", }, + // { + // name: "For You", + // enable: true, + // bigCat: "static", + // }, { name: "推荐歌单", enable: true, diff --git a/src/utils/updateApp.js b/src/utils/updateApp.js index bd1b565..59d5654 100644 --- a/src/utils/updateApp.js +++ b/src/utils/updateApp.js @@ -4,20 +4,20 @@ import pkg from "../../package.json"; const updateSetting = () => { const parsedSettings = JSON.parse(localStorage.getItem("settings")); const { - playlistCategories, showUnavailableSongInGreyStyle, automaticallyCacheSongs, nyancatStyle, showLyricsTranslation, minimizeToTray, + enabledPlaylistCategories, } = initLocalStorage.settings; const settings = { - playlistCategories, showUnavailableSongInGreyStyle, automaticallyCacheSongs, nyancatStyle, showLyricsTranslation, minimizeToTray, + enabledPlaylistCategories, ...parsedSettings, }; diff --git a/src/views/explore.vue b/src/views/explore.vue index 0ac4aff..4711d5a 100644 --- a/src/views/explore.vue +++ b/src/views/explore.vue @@ -3,13 +3,13 @@