fix: bugs

This commit is contained in:
qier222 2021-09-25 16:20:53 +08:00
parent 17ef0e927c
commit bb87b7f20d
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
9 changed files with 54 additions and 41 deletions

View File

@ -52,7 +52,7 @@
"express-fileupload": "^1.2.0",
"express-http-proxy": "^1.6.2",
"extract-zip": "^2.0.1",
"howler": "^2.2.1",
"howler": "^2.2.3",
"js-cookie": "^2.2.1",
"lodash": "^4.17.20",
"node-vibrant": "^3.1.6",

View File

@ -22,9 +22,10 @@ const sign = params => {
};
export function auth() {
window.open(
`https://www.last.fm/api/auth/?api_key=${apiKey}&cb=${baseUrl}/#/lastfm/callback`
);
const url = process.env.IS_ELECTRON
? `https://www.last.fm/api/auth/?api_key=${apiKey}&cb=${baseUrl}/#/lastfm/callback`
: `https://www.last.fm/api/auth/?api_key=${apiKey}&cb=${baseUrl}/lastfm/callback`;
window.open(url);
}
export function authGetSession(token) {

View File

@ -26,6 +26,11 @@ const log = text => {
console.log(`${clc.blueBright('[background.js]')} ${text}`);
};
const isWindows = process.platform === 'win32';
const isMac = process.platform === 'darwin';
const isLinux = process.platform === 'linux';
const isDevelopment = process.env.NODE_ENV === 'development';
class Background {
constructor() {
this.window = null;
@ -38,7 +43,7 @@ class Background {
});
this.neteaseMusicAPI = null;
this.expressApp = null;
this.willQuitApp = process.platform === 'darwin' ? false : true;
this.willQuitApp = isMac ? false : true;
this.init();
}
@ -73,7 +78,7 @@ class Background {
}
// Exit cleanly on request from parent process in development mode.
if (process.platform === 'win32') {
if (isWindows) {
process.on('message', data => {
if (data === 'graceful-exit') {
app.quit();
@ -119,7 +124,7 @@ class Background {
minWidth: 1080,
minHeight: 720,
titleBarStyle: 'hiddenInset',
frame: process.platform !== 'win32',
frame: !isWindows,
title: 'YesPlayMusic',
show: false,
webPreferences: {
@ -165,7 +170,7 @@ class Background {
}
checkForUpdates() {
if (process.env.NODE_ENV === 'development') return;
if (isDevelopment) return;
log('checkForUpdates');
autoUpdater.checkForUpdatesAndNotify();
@ -195,17 +200,20 @@ class Background {
handleWindowEvents() {
this.window.once('ready-to-show', () => {
log('windows ready-to-show event');
log('window ready-to-show event');
this.window.show();
});
this.window.on('close', e => {
log('windows close event');
log('window close event');
let closeOpt = this.store.get('settings.closeAppOption');
if (this.willQuitApp && (closeOpt === 'exit' || closeOpt === 'ask')) {
/* the user tried to quit the app */
this.window = null;
app.quit();
} else if (!this.willQuitApp && isMac) {
e.preventDefault();
this.window.hide();
} else {
/* the user only tried to close the window */
e.preventDefault();
@ -223,7 +231,7 @@ class Background {
this.window.on('minimize', () => {
if (
['win32', 'linux'].includes(process.platform) &&
!isMac &&
this.store.get('settings.closeAppOption') === 'minimizeToTray'
) {
this.window.hide();
@ -263,7 +271,7 @@ class Background {
log('app ready event');
// for development
if (process.env.NODE_ENV === 'development') {
if (isDevelopment) {
this.initDevtools();
}
@ -292,10 +300,7 @@ class Background {
createMenu(this.window, this.store);
// create tray
if (
['win32', 'linux'].includes(process.platform) ||
process.env.NODE_ENV === 'development'
) {
if (isWindows || isLinux || isDevelopment) {
this.tray = createTray(this.window);
}
@ -323,7 +328,7 @@ class Background {
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
if (!isMac) {
app.quit();
}
});

View File

@ -101,6 +101,7 @@ img {
width: 100%;
user-select: none;
aspect-ratio: 1 / 1;
border: 1px solid rgba(0, 0, 0, 0.04);
}
.cover-hover {

View File

@ -86,6 +86,7 @@ export default {
this.getColor();
},
getColor() {
if (!this.player.personalFMTrack?.album?.picUrl) return;
const cover = `${this.player.personalFMTrack.album.picUrl.replace(
'http://',
'https://'

View File

@ -38,7 +38,8 @@ export default {
}
let like = true;
if (state.liked.songs.includes(id)) like = false;
likeATrack({ id, like }).then(() => {
likeATrack({ id, like })
.then(() => {
if (like === false) {
commit('updateLikedXXX', {
name: 'songs',
@ -53,6 +54,9 @@ export default {
});
}
dispatch('fetchLikedSongsWithDetails');
})
.catch(() => {
dispatch('showToast', '操作失败,专辑下架或版权锁定');
});
},
fetchLikedSongs: ({ state, commit }) => {
@ -140,7 +144,7 @@ export default {
},
fetchLikedMVs: ({ commit }) => {
if (!isAccountLoggedIn()) return;
return likedMVs({ limit: 2000 }).then(result => {
return likedMVs({ limit: 1000 }).then(result => {
if (result.data) {
commit('updateLikedXXX', {
name: 'mvs',

View File

@ -17,14 +17,14 @@ let localStorage = {
outputDevice: 'default',
showPlaylistsByAppleMusic: true,
enableUnblockNeteaseMusic: true,
automaticallyCacheSongs: false,
cacheLimit: false,
automaticallyCacheSongs: true,
cacheLimit: 8192,
nyancatStyle: false,
showLyricsTranslation: true,
lyricsBackground: true,
closeAppOption: 'ask',
enableDiscordRichPresence: false,
enableGlobalShortcut: true,
enableGlobalShortcut: false,
showLibraryDefault: false,
enabledPlaylistCategories,
proxyConfig: {

View File

@ -51,6 +51,7 @@ async function deleteExcessCache() {
}
export function cacheTrackSource(trackInfo, url, bitRate, from = 'netease') {
if (!process.env.IS_ELECTRON) return;
const name = trackInfo.name;
const artist =
(trackInfo.ar && trackInfo.ar[0]?.name) ||

View File

@ -6355,10 +6355,10 @@ hosted-git-info@^4.0.1:
dependencies:
lru-cache "^6.0.0"
howler@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.1.tgz#a521a9b495841e8bb9aa12e651bebba0affc179e"
integrity sha512-0iIXvuBO/81CcrQ/HSSweYmbT50fT2mIc9XMFb+kxIfk2pW/iKzDbX1n3fZmDXMEIpYvyyfrB+gXwPYSDqUxIQ==
howler@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.3.tgz#a2eff9b08b586798e7a2ee17a602a90df28715da"
integrity sha512-QM0FFkw0LRX1PR8pNzJVAY25JhIWvbKMBFM4gqk+QdV+kPXOhleWGCB6AiAF/goGjIHK2e/nIElplvjQwhr0jg==
hpack.js@^2.1.6:
version "2.1.6"