mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
fix: bugs
This commit is contained in:
parent
7d580e7113
commit
5355caa4e4
7 changed files with 72 additions and 59 deletions
15
src/App.vue
15
src/App.vue
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<Navbar ref="navbar" v-show="showNavbar" />
|
<Navbar v-show="showNavbar" ref="navbar" />
|
||||||
<main>
|
<main>
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<router-view v-if="$route.meta.keepAlive"></router-view>
|
<router-view v-if="$route.meta.keepAlive"></router-view>
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
<router-view v-if="!$route.meta.keepAlive"></router-view>
|
<router-view v-if="!$route.meta.keepAlive"></router-view>
|
||||||
</main>
|
</main>
|
||||||
<transition name="slide-up">
|
<transition name="slide-up">
|
||||||
<Player v-if="enablePlayer" ref="player" v-show="showPlayer"
|
<Player v-if="enablePlayer" v-show="showPlayer" ref="player"
|
||||||
/></transition>
|
/></transition>
|
||||||
<Toast />
|
<Toast />
|
||||||
<ModalAddTrackToPlaylist v-if="isAccountLoggedIn" />
|
<ModalAddTrackToPlaylist v-if="isAccountLoggedIn" />
|
||||||
<ModalNewPlaylist v-if="isAccountLoggedIn" />
|
<ModalNewPlaylist v-if="isAccountLoggedIn" />
|
||||||
<transition name="slide-up" v-if="enablePlayer">
|
<transition v-if="enablePlayer" name="slide-up">
|
||||||
<Lyrics v-show="this.$store.state.showLyrics" />
|
<Lyrics v-show="showLyrics" />
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -28,6 +28,7 @@ import Toast from "./components/Toast.vue";
|
||||||
import { ipcRenderer } from "./electron/ipcRenderer";
|
import { ipcRenderer } from "./electron/ipcRenderer";
|
||||||
import { isAccountLoggedIn } from "@/utils/auth";
|
import { isAccountLoggedIn } from "@/utils/auth";
|
||||||
import Lyrics from "./views/lyrics.vue";
|
import Lyrics from "./views/lyrics.vue";
|
||||||
|
import { mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
|
|
@ -45,6 +46,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState(["showLyrics"]),
|
||||||
isAccountLoggedIn() {
|
isAccountLoggedIn() {
|
||||||
return isAccountLoggedIn();
|
return isAccountLoggedIn();
|
||||||
},
|
},
|
||||||
|
|
@ -177,7 +179,10 @@ a {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's get this party started */
|
main::-webkit-scrollbar {
|
||||||
|
width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ export default {
|
||||||
},
|
},
|
||||||
togglePlaylistCategory(state, name) {
|
togglePlaylistCategory(state, name) {
|
||||||
const index = state.settings.enabledPlaylistCategories.findIndex(
|
const index = state.settings.enabledPlaylistCategories.findIndex(
|
||||||
(c) => c.name === name
|
(c) => c === name
|
||||||
);
|
);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
state.settings.enabledPlaylistCategories = state.settings.enabledPlaylistCategories.filter(
|
state.settings.enabledPlaylistCategories = state.settings.enabledPlaylistCategories.filter(
|
||||||
(c) => c.name !== name
|
(c) => c !== name
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
state.settings.enabledPlaylistCategories.push(name);
|
state.settings.enabledPlaylistCategories.push(name);
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,13 @@ export default class {
|
||||||
this._loadSelfFromLocalStorage();
|
this._loadSelfFromLocalStorage();
|
||||||
if (this._enabled) {
|
if (this._enabled) {
|
||||||
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
||||||
this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
this._howler?.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
||||||
setInterval(
|
setInterval(
|
||||||
() =>
|
() =>
|
||||||
localStorage.setItem("playerCurrentTrackTime", this._howler.seek()),
|
localStorage.setItem(
|
||||||
|
"playerCurrentTrackTime",
|
||||||
|
this._howler?.seek()
|
||||||
|
),
|
||||||
1000
|
1000
|
||||||
);
|
);
|
||||||
}); // update audio source and init howler
|
}); // update audio source and init howler
|
||||||
|
|
@ -408,7 +411,7 @@ export default class {
|
||||||
// TODO: 切换歌曲时增加加载中的状态
|
// TODO: 切换歌曲时增加加载中的状态
|
||||||
const [trackID, index] = this._getNextTrack();
|
const [trackID, index] = this._getNextTrack();
|
||||||
if (trackID === undefined) {
|
if (trackID === undefined) {
|
||||||
this._howler.stop();
|
this._howler?.stop();
|
||||||
this._playing = false;
|
this._playing = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -434,14 +437,14 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
pause() {
|
pause() {
|
||||||
this._howler.pause();
|
this._howler?.pause();
|
||||||
this._playing = false;
|
this._playing = false;
|
||||||
document.title = "YesPlayMusic";
|
document.title = "YesPlayMusic";
|
||||||
this._pauseDiscordPresence(this._currentTrack);
|
this._pauseDiscordPresence(this._currentTrack);
|
||||||
}
|
}
|
||||||
play() {
|
play() {
|
||||||
if (this._howler.playing()) return;
|
if (this._howler?.playing()) return;
|
||||||
this._howler.play();
|
this._howler?.play();
|
||||||
this._playing = true;
|
this._playing = true;
|
||||||
document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`;
|
document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`;
|
||||||
this._playDiscordPresence(this._currentTrack, this.seek());
|
this._playDiscordPresence(this._currentTrack, this.seek());
|
||||||
|
|
@ -456,7 +459,7 @@ export default class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playOrPause() {
|
playOrPause() {
|
||||||
if (this._howler.playing()) {
|
if (this._howler?.playing()) {
|
||||||
this.pause();
|
this.pause();
|
||||||
} else {
|
} else {
|
||||||
this.play();
|
this.play();
|
||||||
|
|
@ -464,7 +467,7 @@ export default class {
|
||||||
}
|
}
|
||||||
seek(time = null) {
|
seek(time = null) {
|
||||||
if (time !== null) {
|
if (time !== null) {
|
||||||
this._howler.seek(time);
|
this._howler?.seek(time);
|
||||||
if (this._playing)
|
if (this._playing)
|
||||||
this._playDiscordPresence(this._currentTrack, this.seek());
|
this._playDiscordPresence(this._currentTrack, this.seek());
|
||||||
}
|
}
|
||||||
|
|
@ -479,10 +482,10 @@ export default class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setOutputDevice() {
|
setOutputDevice() {
|
||||||
if (this._howler._sounds.length <= 0 || !this._howler._sounds[0]._node) {
|
if (this._howler?._sounds.length <= 0 || !this._howler?._sounds[0]._node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._howler._sounds[0]._node.setSinkId(store.state.settings.outputDevice);
|
this._howler?._sounds[0]._node.setSinkId(store.state.settings.outputDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
replacePlaylist(
|
replacePlaylist(
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,6 @@ service.interceptors.response.use(
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
const errMsg = `error: ${error}`;
|
|
||||||
console.log(errMsg);
|
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -169,9 +169,6 @@ export default {
|
||||||
title: "",
|
title: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.loadData(this.$route.params.id);
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["player", "data"]),
|
...mapState(["player", "data"]),
|
||||||
albumTime() {
|
albumTime() {
|
||||||
|
|
@ -197,6 +194,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.loadData(this.$route.params.id);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["appendTrackToPlayerList"]),
|
...mapMutations(["appendTrackToPlayerList"]),
|
||||||
...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
|
...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
|
||||||
|
|
@ -211,15 +211,20 @@ export default {
|
||||||
likeAAlbum({
|
likeAAlbum({
|
||||||
id: this.album.id,
|
id: this.album.id,
|
||||||
t: this.dynamicDetail.isSub ? 0 : 1,
|
t: this.dynamicDetail.isSub ? 0 : 1,
|
||||||
}).then((data) => {
|
})
|
||||||
if (data.code === 200) {
|
.then((data) => {
|
||||||
this.dynamicDetail.isSub = !this.dynamicDetail.isSub;
|
if (data.code === 200) {
|
||||||
if (toast === true)
|
this.dynamicDetail.isSub = !this.dynamicDetail.isSub;
|
||||||
this.showToast(
|
if (toast === true)
|
||||||
this.dynamicDetail.isSub ? "已保存到音乐库" : "已从音乐库删除"
|
this.showToast(
|
||||||
);
|
this.dynamicDetail.isSub ? "已保存到音乐库" : "已从音乐库删除"
|
||||||
}
|
);
|
||||||
});
|
}
|
||||||
|
console.log(data);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.showToast(`${error.response.data.message || error}`);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
formatTitle() {
|
formatTitle() {
|
||||||
let splitTitle = splitSoundtrackAlbumTitle(this.album.name);
|
let splitTitle = splitSoundtrackAlbumTitle(this.album.name);
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,16 @@ export default {
|
||||||
ButtonTwoTone,
|
ButtonTwoTone,
|
||||||
SvgIcon,
|
SvgIcon,
|
||||||
},
|
},
|
||||||
|
beforeRouteUpdate(to, from, next) {
|
||||||
|
NProgress.start();
|
||||||
|
this.showLoadMoreButton = false;
|
||||||
|
this.hasMore = true;
|
||||||
|
this.playlists = [];
|
||||||
|
this.offset = 1;
|
||||||
|
this.activeCategory = to.query.category;
|
||||||
|
this.getPlaylist();
|
||||||
|
next();
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
show: false,
|
show: false,
|
||||||
|
|
@ -119,7 +129,7 @@ export default {
|
||||||
this.getPlaylist();
|
this.getPlaylist();
|
||||||
},
|
},
|
||||||
goToCategory(Category) {
|
goToCategory(Category) {
|
||||||
if (this.showCatOptions) return;
|
this.showCatOptions = false;
|
||||||
this.$router.push({ path: "/explore?category=" + Category });
|
this.$router.push({ path: "/explore?category=" + Category });
|
||||||
},
|
},
|
||||||
updatePlaylist(playlists) {
|
updatePlaylist(playlists) {
|
||||||
|
|
@ -179,16 +189,6 @@ export default {
|
||||||
this.togglePlaylistCategory(name);
|
this.togglePlaylistCategory(name);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
|
||||||
NProgress.start();
|
|
||||||
this.showLoadMoreButton = false;
|
|
||||||
this.hasMore = true;
|
|
||||||
this.playlists = [];
|
|
||||||
this.offset = 1;
|
|
||||||
this.activeCategory = to.query.category;
|
|
||||||
this.getPlaylist();
|
|
||||||
next();
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,12 +273,26 @@ export default {
|
||||||
return this.lyric.length == 0;
|
return this.lyric.length == 0;
|
||||||
},
|
},
|
||||||
artist() {
|
artist() {
|
||||||
return this.currentTrack?.ar[0] || { id: 0, name: "unknown" };
|
return this.currentTrack?.ar
|
||||||
|
? this.currentTrack.ar[0]
|
||||||
|
: { id: 0, name: "unknown" };
|
||||||
},
|
},
|
||||||
album() {
|
album() {
|
||||||
return this.currentTrack?.al || { id: 0, name: "unknown" };
|
return this.currentTrack?.al || { id: 0, name: "unknown" };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
currentTrack() {
|
||||||
|
this.getLyric();
|
||||||
|
},
|
||||||
|
showLyrics(show) {
|
||||||
|
if (show) {
|
||||||
|
this.setLyricsInterval();
|
||||||
|
} else {
|
||||||
|
clearInterval(this.lyricsInterval);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getLyric();
|
this.getLyric();
|
||||||
},
|
},
|
||||||
|
|
@ -343,27 +357,16 @@ export default {
|
||||||
const showLyricsTranslation = this.$store.state.settings
|
const showLyricsTranslation = this.$store.state.settings
|
||||||
.showLyricsTranslation;
|
.showLyricsTranslation;
|
||||||
if (showLyricsTranslation && line.contents[1]) {
|
if (showLyricsTranslation && line.contents[1]) {
|
||||||
return `<span>${line?.contents[0]}<br/>${line.contents[1]}</span>`;
|
return `<span>${line.contents[0]}<br/>${line.contents[1]}</span>`;
|
||||||
} else {
|
} else if (line.contents[0] !== undefined) {
|
||||||
return `<span>${line?.contents[0]}</span>`;
|
return `<span>${line.contents[0]}</span>`;
|
||||||
}
|
}
|
||||||
|
return "unknown";
|
||||||
},
|
},
|
||||||
moveToFMTrash() {
|
moveToFMTrash() {
|
||||||
this.player.moveToFMTrash();
|
this.player.moveToFMTrash();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
currentTrack() {
|
|
||||||
this.getLyric();
|
|
||||||
},
|
|
||||||
showLyrics(show) {
|
|
||||||
if (show) {
|
|
||||||
this.setLyricsInterval();
|
|
||||||
} else {
|
|
||||||
clearInterval(this.lyricsInterval);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue