diff --git a/src/App.vue b/src/App.vue index b1e0142..76e2897 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,6 +17,7 @@ ) === false " /> + @@ -24,6 +25,7 @@ + + diff --git a/src/components/TrackList.vue b/src/components/TrackList.vue index 1da3a8d..33394e8 100644 --- a/src/components/TrackList.vue +++ b/src/components/TrackList.vue @@ -9,21 +9,21 @@
-
Play
-
Play Next
+
{{ $t("contextMenu.play") }}
+
{{ $t("contextMenu.playNext") }}
- Save to my Liked Songs + {{ $t("contextMenu.saveToMyLikedSongs") }}
- Remove from my Liked Songs + {{ $t("contextMenu.removeFromMyLikedSongs") }}
{ if (data.code !== 200) return; if (like === false) { + this.showToast(this.$t("toast.removedFromMyLikedSongs")); this.updateLikedSongs(likedSongs.filter((d) => d !== id)); } else { + this.showToast(this.$t("toast.savedToMyLikedSongs")); likedSongs.push(id); this.updateLikedSongs(likedSongs); } diff --git a/src/store/actions.js b/src/store/actions.js index de32368..76305b7 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -143,4 +143,21 @@ export default { dispatch("nextTrack"); }); }, + showToast({ state, commit }, text) { + if (state.toast.timer !== null) { + clearTimeout(state.toast.timer); + commit("updateToast", { show: false, text: "", timer: null }); + } + commit("updateToast", { + show: true, + text, + timer: setTimeout(() => { + commit("updateToast", { + show: false, + text: state.toast.text, + timer: null, + }); + }, 3200), + }); + }, }; diff --git a/src/store/mutations.js b/src/store/mutations.js index 1dcd342..0c56d6a 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -120,4 +120,7 @@ export default { } ); }, + updateToast(state, toast) { + state.toast = toast; + }, }; diff --git a/src/store/state.js b/src/store/state.js index 469f361..00d1202 100644 --- a/src/store/state.js +++ b/src/store/state.js @@ -7,6 +7,11 @@ export default { clickObjectID: 0, showMenu: false, }, + toast: { + show: false, + text: "", + timer: null, + }, player: JSON.parse(localStorage.getItem("player")), settings: JSON.parse(localStorage.getItem("settings")), data: JSON.parse(localStorage.getItem("data")),