Commit a5951d38 authored by mercury233's avatar mercury233

add closeToTray

parent 156c1688
Pipeline #21490 passed with stages
in 4 minutes and 50 seconds
......@@ -42,7 +42,7 @@
<i i18n (click)="currentWindow.minimize()" class="fa fa-minus" i18n-title title="最小化"></i>
<i i18n *ngIf="!currentWindow.isMaximized()" (click)="currentWindow.maximize()" class="fa fa-expand" i18n-title title="最大化"></i>
<i i18n *ngIf="currentWindow.isMaximized()" (click)="currentWindow.unmaximize()" class="fa fa-clone" i18n-title title="还原"></i>
<i i18n (click)="currentWindow.hide()" class="fa fa-times" i18n-title title="关闭"></i>
<i i18n (click)="closeWindow()" class="fa fa-times" i18n-title title="关闭"></i>
</div>
</div>
</nav>
......@@ -66,6 +66,13 @@
<form (submit)="submit()">
<div class="modal-body">
<div class="container">
<div class="form-group row">
<label i18n class="col-sm-3 col-form-label">关闭时</label>
<div class="col-sm-9">
<input type="checkbox" id="chkCloseToTray" [(ngModel)]="closeToTray" name="chkCloseToTray">
<label i18n for="chkCloseToTray">点击关闭按钮最小化到系统托盘</label>
</div>
</div>
<div class="form-group row">
<label i18n for="locale" class="col-sm-3 col-form-label">语言</label>
<div class="col-sm-9">
......@@ -78,7 +85,7 @@
<div class="form-group row">
<label i18n class="col-sm-3 col-form-label">允许导入</label>
<div class="col-sm-9">
<input type="checkbox" [(ngModel)]="importEnabled" name="chkImportEnabled">
<input type="checkbox" id="chkImportEnabled" [(ngModel)]="importEnabled" name="chkImportEnabled">
<label i18n for="chkImportEnabled">我确认我在开发者指导下使用导入功能</label>
</div>
</div>
......
......@@ -38,6 +38,7 @@ export class MyCardComponent implements OnInit {
locale: string;
importEnabled: boolean;
closeToTray: boolean;
resizing: HTMLElement | null;
......@@ -67,6 +68,8 @@ export class MyCardComponent implements OnInit {
this.currentWindow.webContents.openDevTools({ mode: 'undocked' });
}
});
$('#settings-modal').on('show.bs.modal', () => { this.update_settings(); });
//$('[data-toggle="tooltip"]').tooltip();
// bootstrap有BUG不能用这玩意
......@@ -104,9 +107,13 @@ export class MyCardComponent implements OnInit {
this.set_update_status('update-downloaded');
});
this.update_settings();
}
update_settings() {
this.locale = this.settingsService.getLocale();
this.importEnabled = this.settingsService.getImportEnabled();
this.closeToTray = this.settingsService.getCloseToTray();
}
update_retry() {
......@@ -162,6 +169,7 @@ export class MyCardComponent implements OnInit {
submit() {
this.settingsService.setImportEnabled(this.importEnabled);
this.settingsService.setCloseToTray(this.closeToTray);
if (this.locale !== this.settingsService.getLocale()) {
this.settingsService.setLocale(this.locale);
remote.app.relaunch();
......@@ -170,6 +178,13 @@ export class MyCardComponent implements OnInit {
$('#settings-modal').modal('hide');
}
closeWindow() {
if (this.closeToTray)
this.currentWindow.hide();
else
remote.app.quit();
}
//
// moesound_loaded() {
// this.moesound.nativeElement.insertCSS(`
......
......@@ -22,11 +22,13 @@ export class SettingsService {
];
static SETTING_LOCALE = 'locale';
static IMPORT_ENABLED = 'importEnabled';
static CLOSE_TO_TRAY = 'closeToTray';
static defaultLocale = remote.app.getLocale();
locale: string;
libraries: Library[];
importEnabled: boolean;
closeToTray: boolean;
getLibraries () {
......@@ -112,4 +114,23 @@ export class SettingsService {
this.importEnabled = enabled;
localStorage.setItem(SettingsService.IMPORT_ENABLED, enabled ? 'true' : 'false');
}
getCloseToTray(): boolean {
if (this.closeToTray === undefined) {
let closeToTray = localStorage.getItem(SettingsService.CLOSE_TO_TRAY);
if (!closeToTray) {
this.closeToTray = true;
localStorage.setItem(SettingsService.CLOSE_TO_TRAY, 'true');
} else {
this.closeToTray = closeToTray === 'true';
}
}
return this.closeToTray;
}
setCloseToTray(enabled: boolean) {
this.closeToTray = enabled;
localStorage.setItem(SettingsService.CLOSE_TO_TRAY, enabled ? 'true' : 'false');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment