fix close button inconsistency

This commit is contained in:
vapormusic 2022-01-28 17:14:38 +07:00
parent 6fc3de9e9f
commit 8c7ae2b7e9
3 changed files with 28 additions and 8 deletions

View file

@ -10,6 +10,7 @@ export default class MinimizeToTray {
private _app: any;
private _store: any;
private _tray: any;
private _forceQuit = false;
/**
* Base Plugin Details (Eventually implemented into a GUI in settings)
@ -46,7 +47,7 @@ export default class MinimizeToTray {
{
label: 'Quit',
click: function () {
self._app.quit();
self._forceQuit = true; self._app.quit();
}
}
]));
@ -70,7 +71,7 @@ export default class MinimizeToTray {
{
label: 'Quit',
click: function () {
self._app.quit();
self._forceQuit = true; self._app.quit();
}
}
]));
@ -122,7 +123,22 @@ export default class MinimizeToTray {
// listen for close event
this._win.hide();
this.SetContextMenu(false);
});
});
electron.ipcMain.handle("update-store-mtt", (event, value) => {
this._store.general["close_behavior"] = value;
})
this._win.on("close", (e :any) => {
if (this._forceQuit || this._store.general["close_behavior"] == '0' ) {
this._app.exit();
} else if (this._store.general["close_behavior"] == '1') {
e.preventDefault();
this._win.minimize();
} else {
e.preventDefault();
this._win.hide();
this.SetContextMenu(false);
}
});
}
/**

View file

@ -3434,7 +3434,8 @@ const app = new Vue({
switch (app.cfg.general.close_behavior) {
case 0:
case '0':
ipcRenderer.send('close');
// the minimizeToTray plugin will handle this
window.close();
break;
case 1:
case '1':

View file

@ -546,10 +546,10 @@
{{$root.getLz("settings.option.experimental.closeButtonBehaviour")}}
</div>
<div class="md-option-segment md-option-segment_auto">
<select class="md-select" v-model="app.cfg.general.close_behavior">
<option value='0'>{{$root.getLz("settings.option.experimental.closeButtonBehaviour.quit")}}</option>
<option value='1'>{{$root.getLz("settings.option.experimental.closeButtonBehaviour.minimizeTaskbar")}}</option>
<option value='2'>{{$root.getLz("settings.option.experimental.closeButtonBehaviour.minimizeTray")}}</option>
<select class="md-select" v-model="app.cfg.general.close_behavior" @change="sendDataToMTT()">
<option value="0">{{$root.getLz("settings.option.experimental.closeButtonBehaviour.quit")}}</option>
<option value="1">{{$root.getLz("settings.option.experimental.closeButtonBehaviour.minimizeTaskbar")}}</option>
<option value="2">{{$root.getLz("settings.option.experimental.closeButtonBehaviour.minimizeTray")}}</option>
</select>
</div>
</div>
@ -695,6 +695,9 @@
},
toggleUserInfo: function () {
app.chrome.hideUserInfo = !app.cfg.visual.showuserinfo
},
sendDataToMTT: function() {
window.ipcRenderer.invoke('update-store-mtt', app.cfg.general.close_behavior);
}
}
})