From ee59479ff8f39aaac667b319ea6839eb4f5fa0e7 Mon Sep 17 00:00:00 2001 From: Hawtim Date: Thu, 28 Oct 2021 01:09:00 +0800 Subject: [PATCH] feat: enhance (#1016) --- package.json | 6 +++--- src/components/Navbar.vue | 1 + src/components/TrackListItem.vue | 10 +++++++--- src/store/actions.js | 2 +- src/utils/Player.js | 8 ++++++-- yarn.lock | 6 +++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5258849..02c72b9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.4.2", "private": true, "description": "A third party music player for Netease Music", - "author": "hawtim", + "author": "qier222", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", @@ -47,14 +47,14 @@ "electron-store": "^6.0.1", "electron-updater": "^4.3.5", "express": "^4.17.1", - "md5": "^2.3.0", - "music-metadata": "^7.5.3", "express-fileupload": "^1.2.0", "express-http-proxy": "^1.6.2", "extract-zip": "^2.0.1", "howler": "^2.2.3", "js-cookie": "^2.2.1", "lodash": "^4.17.20", + "md5": "^2.3.0", + "music-metadata": "^7.5.3", "node-vibrant": "^3.1.6", "nprogress": "^0.2.0", "pac-proxy-agent": "^4.1.0", diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 372fca0..6b01a48 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -53,6 +53,7 @@
- {{ album.name }} + {{ + album.name + }}
@@ -85,6 +87,7 @@ import ArtistsInLine from '@/components/ArtistsInLine.vue'; import ExplicitSymbol from '@/components/ExplicitSymbol.vue'; import { mapState } from 'vuex'; +import { isNil } from 'lodash'; export default { name: 'TrackListItem', @@ -117,8 +120,9 @@ export default { return image + '?param=224y224'; }, artists() { - if (this.track.ar !== undefined) return this.track.ar; - if (this.track.artists !== undefined) return this.track.artists; + const { ar, artists } = this.track; + if (!isNil(ar)) return ar; + if (!isNil(artists)) return artists; return []; }, album() { diff --git a/src/store/actions.js b/src/store/actions.js index d29eb88..39bb019 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -100,7 +100,7 @@ export default { if (!isLooseLoggedIn()) return; if (isAccountLoggedIn()) { return userPlaylist({ - uid: state.data.user.userId, + uid: state.data.user?.userId, limit: 2000, // 最多只加载2000个歌单(等有用户反馈问题再修) timestamp: new Date().getTime(), }).then(result => { diff --git a/src/utils/Player.js b/src/utils/Player.js index 20ff303..4f81941 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -235,7 +235,9 @@ export default class { }); if (autoplay) { this.play(); - document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`; + if (this._currentTrack.name) { + document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`; + } } this.setOutputDevice(); this._howler.once('end', () => { @@ -485,7 +487,9 @@ export default class { if (this._howler?.playing()) return; this._howler?.play(); this._playing = true; - document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`; + if (this._currentTrack.name) { + document.title = `${this._currentTrack.name} · ${this._currentTrack.ar[0].name} - YesPlayMusic`; + } this._playDiscordPresence(this._currentTrack, this.seek()); if (store.state.lastfm.key !== undefined) { trackUpdateNowPlaying({ diff --git a/yarn.lock b/yarn.lock index 257e6c4..d6bd1ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3238,9 +3238,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001208: - version "1.0.30001208" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz#a999014a35cebd4f98c405930a057a0d75352eb9" - integrity sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA== + version "1.0.30001271" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001271.tgz" + integrity sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA== capital-case@^1.0.4: version "1.0.4"