mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 05:08:04 +00:00
parent
8b59a72506
commit
de818282c8
8 changed files with 74 additions and 40 deletions
|
|
@ -206,18 +206,24 @@ class Background {
|
|||
|
||||
this.window.on('close', e => {
|
||||
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();
|
||||
|
||||
if (isMac) {
|
||||
if (this.willQuitApp) {
|
||||
this.window = null;
|
||||
app.quit();
|
||||
} else {
|
||||
e.preventDefault();
|
||||
this.window.hide();
|
||||
}
|
||||
} else {
|
||||
/* the user only tried to close the window */
|
||||
e.preventDefault();
|
||||
this.window.minimize();
|
||||
let closeOpt = this.store.get('settings.closeAppOption');
|
||||
if (this.willQuitApp && (closeOpt === 'exit' || closeOpt === 'ask')) {
|
||||
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.window.on('minimize', () => {
|
||||
if (
|
||||
!isMac &&
|
||||
this.store.get('settings.closeAppOption') === 'minimizeToTray'
|
||||
) {
|
||||
this.window.hide();
|
||||
}
|
||||
});
|
||||
|
||||
this.window.webContents.on('new-window', function (e, url) {
|
||||
e.preventDefault();
|
||||
log('open url');
|
||||
|
|
|
|||
|
|
@ -37,22 +37,25 @@ export function initIpcMain(win, store) {
|
|||
});
|
||||
|
||||
ipcMain.on('close', e => {
|
||||
if (process.platform == 'darwin') {
|
||||
if (process.platform === 'darwin') {
|
||||
win.hide();
|
||||
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 {
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
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', () => {
|
||||
self.$refs.player.goToNextTracksPage();
|
||||
});
|
||||
|
||||
ipcRenderer.on('rememberCloseAppOption', (event, value) => {
|
||||
store.commit('updateSettings', {
|
||||
key: 'closeAppOption',
|
||||
value,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@ export default {
|
|||
text: 'Close App...',
|
||||
ask: 'Ask',
|
||||
exit: 'Exit',
|
||||
minimize: 'Minimize',
|
||||
minimizeToTray: 'Minimize to tray',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ export default {
|
|||
text: 'Close App...',
|
||||
ask: 'Ask',
|
||||
exit: 'Exit',
|
||||
minimize: 'Minimize',
|
||||
minimizeToTray: 'Küçült',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ export default {
|
|||
text: '关闭主面板时...',
|
||||
ask: '询问',
|
||||
exit: '退出',
|
||||
minimize: '最小化',
|
||||
minimizeToTray: '最小化到托盘',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ export default {
|
|||
text: '關閉主面板時...',
|
||||
ask: '詢問',
|
||||
exit: '退出',
|
||||
minimize: '最小化',
|
||||
minimizeToTray: '最小化到系統列',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -295,9 +295,6 @@
|
|||
<option value="exit">
|
||||
{{ $t('settings.closeAppOption.exit') }}
|
||||
</option>
|
||||
<option value="minimize">
|
||||
{{ $t('settings.closeAppOption.minimize') }}
|
||||
</option>
|
||||
<option value="minimizeToTray">
|
||||
{{ $t('settings.closeAppOption.minimizeToTray') }}
|
||||
</option>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue