diff --git a/src/App.vue b/src/App.vue index dbf971e..7bf49be 100644 --- a/src/App.vue +++ b/src/App.vue @@ -80,7 +80,7 @@ export default { if (e.target.tagName === 'INPUT') return false; if (this.$route.name === 'mv') return false; e.preventDefault(); - this.player.play(); + this.player.playOrPause(); } }, fetchData() { diff --git a/src/api/playlist.js b/src/api/playlist.js index b4f4cd7..078b064 100644 --- a/src/api/playlist.js +++ b/src/api/playlist.js @@ -47,10 +47,12 @@ export function getPlaylistDetail(id, noCache = false) { method: 'get', params, }).then(data => { - data.playlist.tracks = mapTrackPlayableStatus( - data.playlist.tracks, - data.privileges || [] - ); + if (data.playlist) { + data.playlist.tracks = mapTrackPlayableStatus( + data.playlist.tracks, + data.privileges || [] + ); + } return data; }); } diff --git a/src/background.js b/src/background.js index 6d37c71..383fc51 100644 --- a/src/background.js +++ b/src/background.js @@ -89,7 +89,16 @@ class Background { expressApp.use('/', express.static(__dirname + '/')); expressApp.use('/api', expressProxy('http://127.0.0.1:10754')); expressApp.use('/player', (req, res) => { - res.send(this.store.get('playerInfo')); + this.window.webContents + .executeJavaScript('window.yesplaymusic.player') + .then(result => { + res.send({ + currentTrack: result._isPersonalFM + ? result._personalFMTrack + : result._currentTrack, + progress: result._progress, + }); + }); }); this.expressApp = expressApp.listen(27232); } diff --git a/src/electron/ipcMain.js b/src/electron/ipcMain.js index 339b61b..c8fa912 100644 --- a/src/electron/ipcMain.js +++ b/src/electron/ipcMain.js @@ -121,8 +121,4 @@ export function initIpcMain(win, store) { console.log('removeProxy'); win.webContents.session.setProxy({}); }); - - ipcMain.on('playerInfo', (event, info) => { - store.set('playerInfo', info); - }); } diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index d1f0a77..dc27e7c 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -2,31 +2,33 @@ import { register } from 'register-service-worker'; -register(`${process.env.BASE_URL}service-worker.js`, { - ready() { - // console.log( - // "App is being served from cache by a service worker.\n" + - // "For more details, visit https://goo.gl/AFskqB" - // ); - }, - registered() { - // console.log("Service worker has been registered."); - }, - cached() { - // console.log("Content has been cached for offline use."); - }, - updatefound() { - // console.log("New content is downloading."); - }, - updated() { - // console.log("New content is available; please refresh."); - }, - offline() { - // console.log( - // "No internet connection found. App is running in offline mode." - // ); - }, - error(error) { - console.error('Error during service worker registration:', error); - }, -}); +if (!process.env.IS_ELECTRON) { + register(`${process.env.BASE_URL}service-worker.js`, { + ready() { + // console.log( + // "App is being served from cache by a service worker.\n" + + // "For more details, visit https://goo.gl/AFskqB" + // ); + }, + registered() { + // console.log("Service worker has been registered."); + }, + cached() { + // console.log("Content has been cached for offline use."); + }, + updatefound() { + // console.log("New content is downloading."); + }, + updated() { + // console.log("New content is available; please refresh."); + }, + offline() { + // console.log( + // "No internet connection found. App is running in offline mode." + // ); + }, + error(error) { + console.error('Error during service worker registration:', error); + }, + }); +} diff --git a/src/store/initLocalStorage.js b/src/store/initLocalStorage.js index 01aa96f..7522f3e 100644 --- a/src/store/initLocalStorage.js +++ b/src/store/initLocalStorage.js @@ -1,6 +1,6 @@ import { playlistCategories } from '@/utils/staticData'; -console.log('[debug][initLocalStorage.js]'); +console.debug('[debug][initLocalStorage.js]'); const enabledPlaylistCategories = playlistCategories .filter(c => c.enable) .map(c => c.name); diff --git a/src/utils/Player.js b/src/utils/Player.js index 4cf7e9c..f70f37f 100644 --- a/src/utils/Player.js +++ b/src/utils/Player.js @@ -47,10 +47,8 @@ export default class { // init this._init(); - // for debug - if (process.env.NODE_ENV === 'development') { - window.player = this; - } + window.yesplaymusic = {}; + window.yesplaymusic.player = this; } get repeatMode() { @@ -177,14 +175,6 @@ export default class { setInterval(() => { this._progress = this._howler === null ? 0 : this._howler.seek(); }, 1000); - - // 发送正在播放的信息给主进程 - setInterval(() => { - ipcRenderer.send('playerInfo', { - currentTrack: this.currentTrack, - progress: this._progress, - }); - }, 1000); } _getNextTrack() { if (this._playNextList.length > 0) { diff --git a/src/utils/auth.js b/src/utils/auth.js index 6df0299..82315c2 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -57,6 +57,5 @@ export function setCookies(string) { const cookies = string.split(';;'); cookies.map(cookie => { document.cookie = cookie; - console.log(cookie); }); } diff --git a/src/views/album.vue b/src/views/album.vue index 251e861..e2078f9 100644 --- a/src/views/album.vue +++ b/src/views/album.vue @@ -226,7 +226,6 @@ export default { this.dynamicDetail.isSub ? '已保存到音乐库' : '已从音乐库删除' ); } - console.log(data); }) .catch(error => { this.showToast(`${error.response.data.message || error}`); diff --git a/src/views/lastfmCallback.vue b/src/views/lastfmCallback.vue index f88b94a..b09f7b2 100644 --- a/src/views/lastfmCallback.vue +++ b/src/views/lastfmCallback.vue @@ -25,9 +25,7 @@ export default { this.done = true; return; } - console.log(token); authGetSession(token).then(result => { - console.log(result); if (!result.data.session) { this.message = '连接失败,请重试或联系开发者(无Session)'; this.done = true; diff --git a/src/views/loginAccount.vue b/src/views/loginAccount.vue index b53d076..692d19e 100644 --- a/src/views/loginAccount.vue +++ b/src/views/loginAccount.vue @@ -191,7 +191,6 @@ export default { this.$router.push({ path: '/library' }); } else { this.processing = false; - console.log(data.msg); nativeAlert(data.msg ?? data.message ?? '账号或密码错误,请检查'); } },