* fix: goToList bug

* lyrics page title go to fix

* change
This commit is contained in:
memorydream 2021-10-28 22:02:58 +08:00 committed by qier222
parent 5566b2e344
commit 0442214555
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
3 changed files with 48 additions and 20 deletions

View File

@ -30,16 +30,19 @@
@click="goToAlbum"
/>
<div class="track-info" :title="audioSource">
<div class="name" @click="goToList">
<div
:class="['name', { hasList: hasList() }]"
@click="hasList() && goToList()"
>
{{ currentTrack.name }}
</div>
<div class="artist">
<span
v-for="(ar, index) in currentTrack.ar"
:key="ar.id"
@click="ar.id !== 0 && goToArtist(ar.id)"
@click="ar.id && goToArtist(ar.id)"
>
<span :class="ar.id !== 0 ? 'ar' : ''"> {{ ar.name }} </span
<span :class="{ ar: ar.id }"> {{ ar.name }} </span
><span v-if="index !== currentTrack.ar.length - 1">, </span>
</span>
</div>
@ -173,6 +176,7 @@ import '@/assets/css/slider.css';
import ButtonIcon from '@/components/ButtonIcon.vue';
import VueSlider from 'vue-slider-component';
import { goToListSource, hasListSource } from '@/utils/playList';
export default {
name: 'Player',
@ -217,22 +221,11 @@ export default {
let sec = (~~(value % 60)).toString().padStart(2, '0');
return `${min}:${sec}`;
},
hasList() {
return hasListSource();
},
goToList() {
if (this.player.playlistSource.id === this.data.likedSongPlaylistID) {
this.$router.push({ path: '/library/liked-songs' });
} else if (this.player.playlistSource.type === 'url') {
this.$router.push({ path: this.player.playlistSource.id });
} else if (this.player.playlistSource.type === 'cloudDisk') {
this.$router.push({ path: '/library' });
} else {
this.$router.push({
path:
'/' +
this.player.playlistSource.type +
'/' +
this.player.playlistSource.id,
});
}
goToListSource();
},
goToAlbum() {
if (this.player.currentTrack.al.id === 0) return;
@ -319,12 +312,14 @@ export default {
opacity: 0.88;
color: var(--color-text);
margin-bottom: 4px;
cursor: pointer;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
word-break: break-all;
}
.hasList {
cursor: pointer;
&:hover {
text-decoration: underline;
}

22
src/utils/playList.js Normal file
View File

@ -0,0 +1,22 @@
import router from '../router';
import state from '../store/state';
export function hasListSource() {
return !state.player.isPersonalFM && state.player.playlistSource.id !== 0;
}
export function goToListSource() {
router.push({ path: getListSourcePath() });
}
export function getListSourcePath() {
if (state.player.playlistSource.id === state.data.likedSongPlaylistID) {
return '/library/liked-songs';
} else if (state.player.playlistSource.type === 'url') {
return state.player.playlistSource.id;
} else if (state.player.playlistSource.type === 'cloudDisk') {
return '/library';
} else {
return `/${state.player.playlistSource.type}/${state.player.playlistSource.id}`;
}
}

View File

@ -46,10 +46,14 @@
<div class="track-info">
<div class="title" :title="currentTrack.name">
<router-link
:to="`/${player.playlistSource.type}/${player.playlistSource.id}`"
v-if="hasList()"
:to="`${getListPath()}`"
@click.native="toggleLyrics"
>{{ currentTrack.name }}
</router-link>
<span v-else>
{{ currentTrack.name }}
</span>
</div>
<div class="subtitle">
<router-link
@ -209,6 +213,7 @@ import { lyricParser } from '@/utils/lyrics';
import ButtonIcon from '@/components/ButtonIcon.vue';
import * as Vibrant from 'node-vibrant';
import Color from 'color';
import { hasListSource, getListSourcePath } from '@/utils/playList';
export default {
name: 'Lyrics',
@ -385,6 +390,12 @@ export default {
this.background = `linear-gradient(to top left, ${color}, ${color2})`;
});
},
hasList() {
return hasListSource();
},
getListPath() {
return getListSourcePath();
},
},
};
</script>