diff --git a/.gitignore b/.gitignore index e02847c..a8f7588 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ .DS_Store node_modules /dist -dist_electron -Icon? # local env files .env @@ -25,7 +23,6 @@ pnpm-debug.log* *.sw? .vercel -/netease_api #Electron-builder output /dist_electron diff --git a/netease_api b/netease_api new file mode 160000 index 0000000..c32bf8b --- /dev/null +++ b/netease_api @@ -0,0 +1 @@ +Subproject commit c32bf8b69728bcc52659862c9349bff9a6c5fc28 diff --git a/package.json b/package.json index 4240245..736073c 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-service": "~4.5.0", "babel-eslint": "^10.1.0", + "electron-builder": "^22.10.5", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", "husky": "^4.3.0", diff --git a/public/img/touchbar/route_next.png b/public/img/touchbar/page_next.png similarity index 100% rename from public/img/touchbar/route_next.png rename to public/img/touchbar/page_next.png diff --git a/public/img/touchbar/route_prev.png b/public/img/touchbar/page_prev.png similarity index 100% rename from public/img/touchbar/route_prev.png rename to public/img/touchbar/page_prev.png diff --git a/src/api/user.js b/src/api/user.js index aeeb719..708a96f 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -16,6 +16,20 @@ export function userDetail(uid) { }); } +/** + * 获取账号详情 + * 说明 : 登录后调用此接口 ,可获取用户账号信息 + */ +export function userAccount() { + return request({ + url: "/user/account", + method: "get", + params: { + timestamp: new Date().getTime(), + }, + }); +} + /** * 获取用户歌单 * 说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户歌单 diff --git a/src/background.js b/src/background.js index ec11712..fa7c55c 100644 --- a/src/background.js +++ b/src/background.js @@ -94,8 +94,8 @@ class Background { this.window = new BrowserWindow({ width: this.store.get("window.width") | 1440, height: this.store.get("window.height") | 840, - minWidth: 360, - minHeight: 240, + minWidth: 1080, + minHeight: 720, titleBarStyle: "hiddenInset", frame: !withoutFrame, webPreferences: { @@ -140,11 +140,9 @@ class Background { }); }; - if (process.platform === "darwin") { - autoUpdater.on("update-available", (info) => { - showNewVersionMessage(info); - }); - } + autoUpdater.on("update-available", (info) => { + showNewVersionMessage(info); + }); } handleWindowEvents() { @@ -176,7 +174,6 @@ class Background { ["win32", "linux"].includes(process.platform) && this.store.get("settings.minimizeToTray") ) { - this.tray = createTray(this.window); this.window.hide(); } }); @@ -209,6 +206,11 @@ class Background { // create menu createMenu(this.window); + // create tray + if (["win32", "linux"].includes(process.platform)) { + this.tray = createTray(this.window); + } + // create dock menu for macOS app.dock.setMenu(createDockMenu(this.window)); diff --git a/src/electron/tray.js b/src/electron/tray.js index a787472..df15f87 100644 --- a/src/electron/tray.js +++ b/src/electron/tray.js @@ -15,7 +15,6 @@ export function createTray(win) { tray.on("click", () => { win.show(); - tray.destroy(); }); tray.on("right-click", () => { diff --git a/src/utils/Player.js b/src/utils/Player.js index bc32d21..6a7c78e 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -32,6 +32,7 @@ export default class { this._playing = false; this._isPersonalFM = false; this._personalFMTrack = { id: 0 }; + this._personalFMNextTrack = { id: 0 }; this._howler = null; Object.defineProperty(this, "_howler", { @@ -112,19 +113,27 @@ export default class { _init() { Howler.autoUnlock = false; Howler.usingWebAudio = true; - Howler.masterGain = true; this._loadSelfFromLocalStorage(); - this._replaceCurrentTrack(this._currentTrack.id, false).then(() => { - this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0); - setInterval( - () => - localStorage.setItem("playerCurrentTrackTime", this._howler.seek()), - 1000 - ); - }); // update audio source and init howler - this._initMediaSession(); + if (this._enabled) { + this._replaceCurrentTrack(this._currentTrack.id, false).then(() => { + this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0); + setInterval( + () => + localStorage.setItem("playerCurrentTrackTime", this._howler.seek()), + 1000 + ); + }); // update audio source and init howler + this._initMediaSession(); + } Howler.volume(this.volume); - this._loadPersonalFMTrack(); + if (this._personalFMTrack.id === 0 || this._personalFMNextTrack.id === 0) { + // init fm + personalFM().then((result) => { + this._personalFMTrack = result.data[0]; + this._personalFMNextTrack = result.data[1]; + return this._personalFMTrack; + }); + } } _getNextTrack() { // 返回 [trackID, index] @@ -298,10 +307,10 @@ export default class { this.playNextTrack(); } } - _loadPersonalFMTrack() { + _loadPersonalFMNextTrack() { return personalFM().then((result) => { - this._personalFMTrack = result.data[0]; - return this._personalFMTrack; + this._personalFMNextTrack = result.data[0]; + return this._personalFMNextTrack; }); } @@ -315,9 +324,9 @@ export default class { playNextTrack(isFM = false) { if (this._isPersonalFM || isFM) { this._isPersonalFM = true; - this._loadPersonalFMTrack().then(() => { - this._replaceCurrentTrack(this._personalFMTrack.id); - }); + this._personalFMTrack = this._personalFMNextTrack; + this._replaceCurrentTrack(this._personalFMTrack.id); + this._loadPersonalFMNextTrack(); return true; } // TODO: 切换歌曲时增加加载中的状态 diff --git a/src/utils/request.js b/src/utils/request.js index 9d5d377..b984ae9 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -20,6 +20,7 @@ const service = axios.create({ }); service.interceptors.request.use(function (config) { + if (!config.params) config.params = {}; config.params.cookie = `MUSIC_U=${Cookies.get("MUSIC_U")};`; return config; }); diff --git a/src/views/library.vue b/src/views/library.vue index ffc3fb9..ebfeecc 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -129,6 +129,7 @@ import { mapActions, mapMutations, mapState } from "vuex"; import { getTrackDetail, getLyric } from "@/api/track"; import { userDetail, + userAccount, userPlaylist, likedAlbums, likedArtists, @@ -169,9 +170,21 @@ export default { }, created() { NProgress.start(); - userDetail(this.data.user.userId).then((data) => { - this.$store.commit("updateData", { key: "user", value: data.profile }); - }); + if (isAccountLoggedIn()) { + userAccount().then((result) => { + this.$store.commit("updateData", { + key: "user", + value: result.profile, + }); + }); + } else { + userDetail(this.data.user.userId).then((result) => { + this.$store.commit("updateData", { + key: "user", + value: result.profile, + }); + }); + } }, activated() { if (!this.data.likedSongPlaylistID) { diff --git a/src/views/lyrics.vue b/src/views/lyrics.vue index c0bed52..aded77b 100644 --- a/src/views/lyrics.vue +++ b/src/views/lyrics.vue @@ -128,12 +128,7 @@