fix: bugs

This commit is contained in:
qier222 2021-06-08 00:09:30 +08:00
parent 22c9691a73
commit c506dea02b
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
18 changed files with 79 additions and 32 deletions

View File

@ -231,6 +231,7 @@ class Background {
}
checkForUpdates() {
if (process.env.NODE_ENV === 'development') return;
log('checkForUpdates');
autoUpdater.checkForUpdatesAndNotify();

View File

@ -111,7 +111,7 @@ export default {
}
}
let img = item.img1v1Url || item.picUrl || item.coverImgUrl;
return `${img}?param=512y512`;
return `${img?.replace('http://', 'https://')}?param=512y512`;
},
},
};

View File

@ -1,5 +1,6 @@
<template>
<div class="fm" :style="{ background }" data-theme="dark">
<img :src="nextTrackCover" style="display: none" />
<img
class="cover"
:src="track.album && track.album.picUrl | resizeImage(512)"
@ -57,6 +58,12 @@ export default {
artists() {
return this.track.artists || this.track.ar || [];
},
nextTrackCover() {
return `${this.player._personalFMNextTrack?.album?.picUrl.replace(
'http://',
'https://'
)}?param=512y512`;
},
},
created() {
this.getColor();
@ -76,9 +83,13 @@ export default {
},
moveToFMTrash() {
this.player.moveToFMTrash();
this.getColor();
},
getColor() {
const cover = `${this.player.personalFMTrack.album.picUrl}?param=512y512`;
const cover = `${this.player.personalFMTrack.album.picUrl.replace(
'http://',
'https://'
)}?param=512y512`;
Vibrant.from(cover, { colorCount: 1 })
.getPalette()
.then(palette => {
@ -104,9 +115,11 @@ export default {
background: var(--color-secondary-bg);
border-radius: 1rem;
display: flex;
height: 198px;
box-sizing: border-box;
}
.cover {
height: 164px;
height: 100%;
clip-path: border-box;
border-radius: 0.75rem;
margin-right: 1.2rem;

View File

@ -104,7 +104,7 @@
<button-icon
:title="$t('player.nextUp')"
:class="{
active: this.$route.name === 'next',
active: $route.name === 'next',
disabled: player.isPersonalFM,
}"
@click.native="goToNextTracksPage"
@ -154,7 +154,7 @@
:interval="0.01"
:drag-on-click="true"
:duration="0"
:tooltip="`none`"
tooltip="none"
:dot-size="12"
></vue-slider>
</div>
@ -164,7 +164,7 @@
class="lyrics-button"
title="歌词"
style="margin-left: 12px"
@click.native.stop="toggleLyrics"
@click.native="toggleLyrics"
><svg-icon icon-class="arrow-up"
/></button-icon>
</div>

View File

@ -35,6 +35,9 @@ export default {
hideTimer: null,
isOnDrag: false,
onDragClientY: 0,
positions: {
home: { scrollTop: 0, params: {} },
},
};
},
computed: {
@ -73,6 +76,11 @@ export default {
if (!this.show && clintHeight !== thumbHeight) this.show = true;
this.setScrollbarHideTimeout();
const route = this.$route;
if (route.meta.savePosition) {
this.positions[route.name] = { scrollTop, params: route.params };
}
},
handleMouseenter() {
this.active = true;
@ -121,6 +129,17 @@ export default {
this.hideTimer = null;
}, 4000);
},
restorePosition() {
const route = this.$route;
if (
!route.meta.savePosition ||
this.positions[route.name] === undefined ||
this.main === undefined
) {
return;
}
this.main.scrollTo({ top: this.positions[route.name].scrollTop });
},
},
};
</script>

View File

@ -127,7 +127,6 @@ export default {
translate() {
let t;
if (this.track?.tns?.length > 0) t = this.track.tns[0];
else if (this.track.al?.tns?.length > 0) t = this.track.al.tns[0];
else t = this.track.alia[0];
return t;
},
@ -138,11 +137,7 @@ export default {
return this.type === 'album';
},
isTranslate() {
return (
this.track?.tns?.length > 0 ||
this.track.al?.tns?.length > 0 ||
this.track.alia?.length > 0
);
return this.track?.tns?.length > 0 || this.track.alia?.length > 0;
},
isPlaylist() {
return this.type === 'playlist';
@ -301,6 +296,7 @@ button {
}
.translate {
color: #aeaeae;
margin-left: 4px;
}
}
.artist {
@ -401,7 +397,8 @@ button {
color: var(--color-primary);
.title,
.album,
.time {
.time,
.title-and-artist .translate {
color: var(--color-primary);
}
.title .featured,

View File

@ -14,6 +14,7 @@ const routes = [
component: () => import('@/views/home.vue'),
meta: {
keepAlive: true,
savePosition: true,
},
},
{
@ -47,6 +48,7 @@ const routes = [
component: () => import('@/views/artist.vue'),
meta: {
keepAlive: true,
savePosition: true,
},
},
{
@ -68,6 +70,7 @@ const routes = [
component: () => import('@/views/next.vue'),
meta: {
keepAlive: true,
savePosition: true,
},
},
{
@ -94,6 +97,7 @@ const routes = [
component: () => import('@/views/explore.vue'),
meta: {
keepAlive: true,
savePosition: true,
},
},
{
@ -103,6 +107,7 @@ const routes = [
meta: {
requireLogin: true,
keepAlive: true,
savePosition: true,
},
},
{
@ -132,16 +137,8 @@ const routes = [
component: () => import('@/views/lastfmCallback.vue'),
},
];
const router = new VueRouter({
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition;
} else {
return { x: 0, y: 0 };
}
},
});
const router = new VueRouter({ routes });
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {

View File

@ -322,6 +322,7 @@ export default class {
? this._personalFMNextTrack.id
: this._getNextTrack()[0];
if (!nextTrackID) return;
if (this._personalFMTrack.id == nextTrackID) return;
getTrackDetail(nextTrackID).then(data => {
let track = data.songs[0];
this._getAudioSource(track);
@ -406,6 +407,7 @@ export default class {
_loadPersonalFMNextTrack() {
return personalFM().then(result => {
this._personalFMNextTrack = result.data[0];
this._cacheNextTrack(); // cache next track
return this._personalFMNextTrack;
});
}

View File

@ -53,6 +53,13 @@ async function deleteExcessCache() {
export function cacheTrackSource(trackInfo, url, bitRate, from = 'netease') {
const name = trackInfo.name;
const artist = trackInfo.ar[0]?.name || trackInfo.artists[0]?.name;
let cover = trackInfo.al.picUrl;
if (cover.slice(0, 5) !== 'https') {
cover = 'https' + cover.slice(4);
}
axios.get(`${cover}?param=512y512`);
axios.get(`${cover}?param=224y224`);
axios.get(`${cover}?param=1024y1024`);
return axios
.get(url, {
responseType: 'arraybuffer',

View File

@ -206,6 +206,11 @@ export default {
}
},
},
watch: {
album: function () {
this.$parent.$refs.main.scrollTo({ top: 0 });
},
},
created() {
this.loadData(this.$route.params.id);
},

View File

@ -261,18 +261,19 @@ export default {
this.loadData(this.$route.params.id);
},
activated() {
if (this.show) {
if (this.artist.id.toString() !== this.$route.params.id) {
this.show = false;
NProgress.start();
this.loadData(this.$route.params.id);
}
if (this.artist?.id?.toString() !== this.$route.params.id) {
this.loadData(this.$route.params.id);
} else {
this.$parent.$refs.scrollbar.restorePosition();
}
},
methods: {
...mapMutations(['appendTrackToPlayerList']),
...mapActions(['playFirstTrackOnList', 'playTrackOnListByID', 'showToast']),
loadData(id, next = undefined) {
NProgress.start();
this.show = false;
this.$parent.$refs.main.scrollTo({ top: 0 });
getArtist(id).then(data => {
this.artist = data.artist;
this.popularTracks = data.hotSongs;

View File

@ -21,7 +21,7 @@ import { dailyRecommendTracks } from '@/api/playlist';
import TrackList from '@/components/TrackList.vue';
export default {
name: 'dailyTracks',
name: 'DailyTracks',
components: {
TrackList,
},
@ -40,6 +40,7 @@ export default {
} else {
this.show = true;
}
this.$parent.$refs.main.scrollTo(0, 0);
},
methods: {
...mapMutations(['updateDailyTracks']),

View File

@ -117,6 +117,7 @@ export default {
},
activated() {
this.loadData();
this.$parent.$refs.scrollbar.restorePosition();
},
methods: {
...mapMutations(['togglePlaylistCategory']),

View File

@ -106,6 +106,7 @@ export default {
},
activated() {
this.loadData();
this.$parent.$refs.scrollbar.restorePosition();
},
methods: {
loadData() {

View File

@ -234,6 +234,7 @@ export default {
this.loadData();
},
activated() {
this.$parent.$refs.scrollbar.restorePosition();
this.loadData();
dailyTask();
},

View File

@ -267,7 +267,6 @@ export default {
clearInterval(this.qrCodeCheckInterval);
this.qrCodeInformation = '登录成功,请稍等...';
result.code = 200;
console.log(result);
this.handleLoginResponse(result);
}
});
@ -463,6 +462,7 @@ button.loading {
margin-bottom: 12px;
}
.qr-code-info {
color: var(--color-text);
text-align: center;
margin-bottom: 28px;
}

View File

@ -218,7 +218,7 @@ export default {
return this.player.currentTrack?.al?.picUrl + '?param=1024y1024';
},
bgImageUrl() {
return this.player.currentTrack?.al?.picUrl + '?param=500y500';
return this.player.currentTrack?.al?.picUrl + '?param=512y512';
},
lyricWithTranslation() {
let ret = [];

View File

@ -81,6 +81,7 @@ export default {
},
activated() {
this.loadTracks();
this.$parent.$refs.scrollbar.restorePosition();
},
methods: {
...mapActions(['playTrackOnListByID']),