master
qier222 4 years ago
parent 22c9691a73
commit c506dea02b
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D

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

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

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

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

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

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

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

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

@ -53,6 +53,13 @@ async function deleteExcessCache() {
export function cacheTrackSource(trackInfo, url, bitRate, from = 'netease') { export function cacheTrackSource(trackInfo, url, bitRate, from = 'netease') {
const name = trackInfo.name; const name = trackInfo.name;
const artist = trackInfo.ar[0]?.name || trackInfo.artists[0]?.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 return axios
.get(url, { .get(url, {
responseType: 'arraybuffer', responseType: 'arraybuffer',

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save