From fe1ae83b73603b1adf27831fd6995e2dee866b2f Mon Sep 17 00:00:00 2001 From: qier222 Date: Wed, 9 Dec 2020 17:19:43 +0800 Subject: [PATCH] feat: add 'Show unavailable song in grey style' to settings #74 --- src/components/TrackListItem.vue | 5 +++- src/store/initLocalStorage.js | 1 + src/utils/updateApp.js | 2 ++ src/views/playlist.vue | 5 +++- src/views/settings.vue | 43 ++++++++++++++++++++++++++------ 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/components/TrackListItem.vue b/src/components/TrackListItem.vue index 1a6ecb3..c086c16 100644 --- a/src/components/TrackListItem.vue +++ b/src/components/TrackListItem.vue @@ -84,6 +84,7 @@ import { isAccountLoggedIn } from "@/utils/auth"; import ArtistsInLine from "@/components/ArtistsInLine.vue"; import ExplicitSymbol from "@/components/ExplicitSymbol.vue"; +import { mapState } from "vuex"; export default { name: "TrackListItem", @@ -95,6 +96,7 @@ export default { return { hover: false, trackStyle: {} }; }, computed: { + ...mapState(["settings"]), imgUrl() { if (this.track.al !== undefined) return this.track.al.picUrl; if (this.track.album !== undefined) return this.track.album.picUrl; @@ -125,7 +127,8 @@ export default { }, trackClass() { let trackClass = [this.type]; - if (!this.track.playable) trackClass.push("disable"); + if (!this.track.playable && this.settings.showUnavailableSongGrey) + trackClass.push("disable"); if (this.isPlaying) trackClass.push("playing"); if (this.focus) trackClass.push("focus"); return trackClass; diff --git a/src/store/initLocalStorage.js b/src/store/initLocalStorage.js index 810c030..b447190 100644 --- a/src/store/initLocalStorage.js +++ b/src/store/initLocalStorage.js @@ -23,6 +23,7 @@ export default { musicQuality: 320000, showGithubIcon: true, showPlaylistsByAppleMusic: true, + showUnavailableSongInGreyStyle: true, }, data: { user: {}, diff --git a/src/utils/updateApp.js b/src/utils/updateApp.js index 9ce4946..86bd02f 100644 --- a/src/utils/updateApp.js +++ b/src/utils/updateApp.js @@ -5,6 +5,8 @@ const updateSetting = () => { const parsedSettings = JSON.parse(localStorage.getItem("settings")); const setting = { playlistCategories: initLocalStorage?.settings?.playlistCategories, + showUnavailableSongInGreyStyle: + initLocalStorage?.settings?.showUnavailableSongInGreyStyle, ...parsedSettings, }; diff --git a/src/views/playlist.vue b/src/views/playlist.vue index cf5ab61..94b1cde 100644 --- a/src/views/playlist.vue +++ b/src/views/playlist.vue @@ -91,8 +91,11 @@ :iconClass="playlist.subscribed ? 'heart-solid' : 'heart'" :iconButton="true" :horizontalPadding="0" - color="grey" + :color="playlist.subscribed ? 'blue' : 'grey'" :textColor="playlist.subscribed ? '#335eea' : ''" + :backgroundColor=" + playlist.subscribed ? 'var(--color-secondary-bg)' : '' + " @click.native="likePlaylist" > diff --git a/src/views/settings.vue b/src/views/settings.vue index a40be5a..f88135c 100644 --- a/src/views/settings.vue +++ b/src/views/settings.vue @@ -76,7 +76,7 @@
-
Automatically Cache Songs
+
Automatically cache songs
@@ -93,7 +93,7 @@
Cached {{ tracksCache.length }} Songs ({{ tracksCache.size }})
Cached {{ tracksCache.length }} songs ({{ tracksCache.size }})
@@ -102,7 +102,7 @@
-
Show Github Icon
+
Show Github icon
@@ -118,7 +118,23 @@
-
Show Playlists by Apple Music
+
Show unavailable song in grey style
+
+
+
+ + +
+
+
+
+
+
Show playlists by Apple Music
@@ -215,6 +231,17 @@ export default { }); }, }, + showUnavailableSongInGreyStyle: { + get() { + return this.settings.showUnavailableSongInGreyStyle; + }, + set(value) { + this.$store.commit("updateSettings", { + key: "showUnavailableSongInGreyStyle", + value, + }); + }, + }, showPlaylistsByAppleMusic: { get() { if (this.settings.showPlaylistsByAppleMusic === undefined) return true; @@ -450,7 +477,7 @@ h2 { -webkit-transition: 0.4s ease; transition: 0.4s ease; height: 32px; - width: 68px; + width: 52px; background: var(--color-secondary-bg); border-radius: 8px; } @@ -461,7 +488,7 @@ h2 { -webkit-transition: 0.2s cubic-bezier(0.24, 0, 0.5, 1); transition: 0.2s cubic-bezier(0.24, 0, 0.5, 1); height: 32px; - width: 68px; + width: 52px; top: 0; left: 0; border-radius: 8px; @@ -476,7 +503,7 @@ h2 { transition: 0.35s cubic-bezier(0.54, 1.6, 0.5, 1); background: #fff; height: 20px; - width: 28px; + width: 20px; top: 6px; left: 6px; border-radius: 6px; @@ -487,6 +514,6 @@ h2 { transition: width 0.2s cubic-bezier(0, 0, 0, 0.1); } .toggle input:checked + label:after { - left: 34px; + left: 26px; }