diff --git a/src/store/actions.js b/src/store/actions.js index dc1174b..609cf00 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -98,6 +98,11 @@ export default { name: 'playlists', data: result.playlist, }); + // 更新用户”喜欢的歌曲“歌单ID + commit('updateData', { + key: 'likedSongPlaylistID', + value: result.playlist[0].id, + }); } }); } else { diff --git a/src/utils/common.js b/src/utils/common.js index 2bbfdec..4b6aa84 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -98,14 +98,20 @@ export function dailyTask() { isAccountLoggedIn() && (lastDate === undefined || lastDate !== dayjs().date()) ) { - console.log('execute dailyTask'); - store.commit('updateData', { - key: 'lastRefreshCookieDate', - value: dayjs().date(), + console.debug('[debug][common.js] execute dailyTask'); + refreshCookie().then(() => { + console.debug('[debug][common.js] 刷新cookie'); + store.commit('updateData', { + key: 'lastRefreshCookieDate', + value: dayjs().date(), + }); + }); + dailySignin(0).catch(() => { + console.debug('[debug][common.js] 手机端重复签到'); + }); + dailySignin(1).catch(() => { + console.debug('[debug][common.js] PC端重复签到'); }); - refreshCookie(); - dailySignin(0); - dailySignin(1); } } diff --git a/src/views/library.vue b/src/views/library.vue index 309ab03..3c03316 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -191,29 +191,34 @@ export default { }, created() { NProgress.start(); + this.loadData(); }, activated() { - if (this.liked.songsWithDetails.length > 0) { - NProgress.done(); - this.show = true; - this.getRandomLyric(); - } else { - this.$store.dispatch('fetchLikedSongsWithDetails').then(() => { - NProgress.done(); - this.show = true; - this.getRandomLyric(); - }); - } - this.$store.dispatch('fetchLikedSongs'); - this.$store.dispatch('fetchLikedPlaylist'); - this.$store.dispatch('fetchLikedAlbums'); - this.$store.dispatch('fetchLikedArtists'); - this.$store.dispatch('fetchLikedMVs'); + this.loadData(); dailyTask(); }, methods: { ...mapActions(['showToast']), ...mapMutations(['updateModal', 'updateData']), + loadData() { + if (this.liked.songsWithDetails.length > 0) { + NProgress.done(); + this.show = true; + this.$store.dispatch('fetchLikedSongsWithDetails'); + this.getRandomLyric(); + } else { + this.$store.dispatch('fetchLikedSongsWithDetails').then(() => { + NProgress.done(); + this.show = true; + this.getRandomLyric(); + }); + } + this.$store.dispatch('fetchLikedSongs'); + this.$store.dispatch('fetchLikedPlaylist'); + this.$store.dispatch('fetchLikedAlbums'); + this.$store.dispatch('fetchLikedArtists'); + this.$store.dispatch('fetchLikedMVs'); + }, playLikedSongs() { this.$store.state.player.playPlaylistByID( this.liked.playlists[0].id, diff --git a/src/views/loginAccount.vue b/src/views/loginAccount.vue index 692d19e..c37b1a7 100644 --- a/src/views/loginAccount.vue +++ b/src/views/loginAccount.vue @@ -188,7 +188,9 @@ export default { setCookies(data.cookie); this.updateData({ key: 'user', value: data.profile }); this.updateData({ key: 'loginMode', value: 'account' }); - this.$router.push({ path: '/library' }); + this.$store.dispatch('fetchLikedPlaylist').then(() => { + this.$router.push({ path: '/library' }); + }); } else { this.processing = false; nativeAlert(data.msg ?? data.message ?? '账号或密码错误,请检查');