mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
parent
991fef8c5d
commit
d29c4e7796
8 changed files with 74 additions and 40 deletions
|
|
@ -206,18 +206,24 @@ class Background {
|
||||||
|
|
||||||
this.window.on('close', e => {
|
this.window.on('close', e => {
|
||||||
log('window close event');
|
log('window close event');
|
||||||
let closeOpt = this.store.get('settings.closeAppOption');
|
|
||||||
if (this.willQuitApp && (closeOpt === 'exit' || closeOpt === 'ask')) {
|
if (isMac) {
|
||||||
/* the user tried to quit the app */
|
if (this.willQuitApp) {
|
||||||
this.window = null;
|
this.window = null;
|
||||||
app.quit();
|
app.quit();
|
||||||
} else if (!this.willQuitApp && isMac) {
|
} else {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.window.hide();
|
this.window.hide();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* the user only tried to close the window */
|
let closeOpt = this.store.get('settings.closeAppOption');
|
||||||
e.preventDefault();
|
if (this.willQuitApp && (closeOpt === 'exit' || closeOpt === 'ask')) {
|
||||||
this.window.minimize();
|
this.window = null;
|
||||||
|
app.quit();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
this.window.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -229,15 +235,6 @@ class Background {
|
||||||
this.store.set('window', this.window.getBounds());
|
this.store.set('window', this.window.getBounds());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.window.on('minimize', () => {
|
|
||||||
if (
|
|
||||||
!isMac &&
|
|
||||||
this.store.get('settings.closeAppOption') === 'minimizeToTray'
|
|
||||||
) {
|
|
||||||
this.window.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.window.webContents.on('new-window', function (e, url) {
|
this.window.webContents.on('new-window', function (e, url) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
log('open url');
|
log('open url');
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,25 @@ export function initIpcMain(win, store) {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('close', e => {
|
ipcMain.on('close', e => {
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
win.hide();
|
win.hide();
|
||||||
exitAsk(e);
|
exitAsk(e);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let closeOpt = store.get('settings.closeAppOption');
|
|
||||||
if (closeOpt === 'exit') {
|
|
||||||
win = null;
|
|
||||||
//app.quit();
|
|
||||||
app.exit(); //exit()直接关闭客户端,不会执行quit();
|
|
||||||
} else if (closeOpt === 'minimize' || closeOpt === 'minimizeToTray') {
|
|
||||||
e.preventDefault(); //阻止默认行为
|
|
||||||
win.minimize(); //调用 最小化实例方法
|
|
||||||
} else {
|
} else {
|
||||||
exitAsk(e);
|
let closeOpt = store.get('settings.closeAppOption');
|
||||||
|
console.log(closeOpt);
|
||||||
|
if (closeOpt === 'exit') {
|
||||||
|
win = null;
|
||||||
|
//app.quit();
|
||||||
|
app.exit(); //exit()直接关闭客户端,不会执行quit();
|
||||||
|
} else if (closeOpt === 'minimize') {
|
||||||
|
e.preventDefault(); //阻止默认行为
|
||||||
|
win.minimize(); //调用 最小化实例方法
|
||||||
|
} else if (closeOpt === 'minimizeToTray') {
|
||||||
|
e.preventDefault();
|
||||||
|
win.hide();
|
||||||
|
} else {
|
||||||
|
exitAskWithoutMac(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -175,4 +178,38 @@ export function initIpcMain(win, store) {
|
||||||
log(err);
|
log(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exitAskWithoutMac = e => {
|
||||||
|
e.preventDefault(); //阻止默认行为
|
||||||
|
dialog
|
||||||
|
.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: 'Information',
|
||||||
|
cancelId: 2,
|
||||||
|
defaultId: 0,
|
||||||
|
message: '确定要关闭吗?',
|
||||||
|
buttons: ['最小化到托盘', '直接退出'],
|
||||||
|
checkboxLabel: '记住我的选择',
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
if (result.checkboxChecked && result.response !== 2) {
|
||||||
|
win.webContents.send(
|
||||||
|
'rememberCloseAppOption',
|
||||||
|
result.response === 0 ? 'minimizeToTray' : 'exit'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.response === 0) {
|
||||||
|
e.preventDefault(); //阻止默认行为
|
||||||
|
win.hide(); //调用 最小化实例方法
|
||||||
|
} else if (result.response === 1) {
|
||||||
|
win = null;
|
||||||
|
//app.quit();
|
||||||
|
app.exit(); //exit()直接关闭客户端,不会执行quit();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
log(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,4 +76,11 @@ export function ipcRenderer(vueInstance) {
|
||||||
ipcRenderer.on('nextUp', () => {
|
ipcRenderer.on('nextUp', () => {
|
||||||
self.$refs.player.goToNextTracksPage();
|
self.$refs.player.goToNextTracksPage();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('rememberCloseAppOption', (event, value) => {
|
||||||
|
store.commit('updateSettings', {
|
||||||
|
key: 'closeAppOption',
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,6 @@ export default {
|
||||||
text: 'Close App...',
|
text: 'Close App...',
|
||||||
ask: 'Ask',
|
ask: 'Ask',
|
||||||
exit: 'Exit',
|
exit: 'Exit',
|
||||||
minimize: 'Minimize',
|
|
||||||
minimizeToTray: 'Minimize to tray',
|
minimizeToTray: 'Minimize to tray',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ export default {
|
||||||
text: 'Close App...',
|
text: 'Close App...',
|
||||||
ask: 'Ask',
|
ask: 'Ask',
|
||||||
exit: 'Exit',
|
exit: 'Exit',
|
||||||
minimize: 'Minimize',
|
|
||||||
minimizeToTray: 'Küçült',
|
minimizeToTray: 'Küçült',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,6 @@ export default {
|
||||||
text: '关闭主面板时...',
|
text: '关闭主面板时...',
|
||||||
ask: '询问',
|
ask: '询问',
|
||||||
exit: '退出',
|
exit: '退出',
|
||||||
minimize: '最小化',
|
|
||||||
minimizeToTray: '最小化到托盘',
|
minimizeToTray: '最小化到托盘',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,6 @@ export default {
|
||||||
text: '關閉主面板時...',
|
text: '關閉主面板時...',
|
||||||
ask: '詢問',
|
ask: '詢問',
|
||||||
exit: '退出',
|
exit: '退出',
|
||||||
minimize: '最小化',
|
|
||||||
minimizeToTray: '最小化到系統列',
|
minimizeToTray: '最小化到系統列',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -295,9 +295,6 @@
|
||||||
<option value="exit">
|
<option value="exit">
|
||||||
{{ $t('settings.closeAppOption.exit') }}
|
{{ $t('settings.closeAppOption.exit') }}
|
||||||
</option>
|
</option>
|
||||||
<option value="minimize">
|
|
||||||
{{ $t('settings.closeAppOption.minimize') }}
|
|
||||||
</option>
|
|
||||||
<option value="minimizeToTray">
|
<option value="minimizeToTray">
|
||||||
{{ $t('settings.closeAppOption.minimizeToTray') }}
|
{{ $t('settings.closeAppOption.minimizeToTray') }}
|
||||||
</option>
|
</option>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue