修复刷新页面后音量复原为100%的bug

master
qier222 4 years ago
parent e11ad6bf46
commit b83aeda687

@ -117,6 +117,7 @@ import { isLoggedIn } from "@/utils/auth";
import { userLikedSongsIDs } from "@/api/user"; import { userLikedSongsIDs } from "@/api/user";
import { likeATrack } from "@/api/track"; import { likeATrack } from "@/api/track";
import "@/assets/css/slider.css"; import "@/assets/css/slider.css";
import { Howler } from "howler";
import ButtonIcon from "@/components/ButtonIcon.vue"; import ButtonIcon from "@/components/ButtonIcon.vue";
import VueSlider from "vue-slider-component"; import VueSlider from "vue-slider-component";
@ -145,7 +146,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(["player", "howler", "Howler", "settings", "liked"]), ...mapState(["player", "howler", "settings", "liked"]),
currentTrack() { currentTrack() {
return this.player.currentTrack; return this.player.currentTrack;
}, },
@ -155,7 +156,7 @@ export default {
}, },
set(value) { set(value) {
this.updatePlayerState({ key: "volume", value }); this.updatePlayerState({ key: "volume", value });
this.Howler.volume(value); Howler.volume(value);
}, },
}, },
playing() { playing() {

@ -4,7 +4,7 @@ import state from "./state";
import mutations from "./mutations"; import mutations from "./mutations";
import actions from "./actions"; import actions from "./actions";
import initState from "./initState"; import initState from "./initState";
import { Howl } from "howler"; import { Howl, Howler } from "howler";
if (localStorage.getItem("appVersion") === null) { if (localStorage.getItem("appVersion") === null) {
localStorage.setItem("player", JSON.stringify(initState.player)); localStorage.setItem("player", JSON.stringify(initState.player));
@ -36,5 +36,6 @@ store.state.howler = new Howl({
html5: true, html5: true,
format: ["mp3"], format: ["mp3"],
}); });
Howler.volume(store.state.player.volume);
export default store; export default store;

@ -1,7 +1,4 @@
import { Howler } from "howler";
const initState = { const initState = {
Howler: Howler,
howler: null, howler: null,
liked: { liked: {
songs: [], songs: [],

@ -1,4 +1,4 @@
import { Howl } from "howler"; import { Howl, Howler } from "howler";
import state from "./state"; import state from "./state";
import { shuffleAList } from "@/utils/common"; import { shuffleAList } from "@/utils/common";
@ -10,7 +10,7 @@ export default {
state.player.currentTrack = track; state.player.currentTrack = track;
}, },
replaceMP3(state, mp3) { replaceMP3(state, mp3) {
state.Howler.unload(); Howler.unload();
state.howler = new Howl({ state.howler = new Howl({
src: [mp3], src: [mp3],
autoplay: true, autoplay: true,

@ -1,7 +1,4 @@
import { Howler } from "howler";
export default { export default {
Howler: Howler,
howler: null, howler: null,
liked: { liked: {
songs: [], songs: [],

Loading…
Cancel
Save