Commit 156c1688 authored by mercury233's avatar mercury233

add importEnabled

parent d9b054c4
......@@ -17,7 +17,7 @@
<!--应用已购买,未安装-->
<div *ngIf="currentApp.isBought() && !currentApp.isInstalled()" class="i-b">
<button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#install-modal">安装</button>
<button i18n *ngIf="currentApp.runnable()" (click)="updateInstallOption(currentApp)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#import-modal">导入</button>
<button i18n *ngIf="currentApp.runnable() && settingsService.getImportEnabled()" (click)="updateInstallOption(currentApp)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#import-modal">导入</button>
</div>
<!--应用变更中-->
......
......@@ -67,14 +67,21 @@
<div class="modal-body">
<div class="container">
<div class="form-group row">
<label i18n for="locale" class="col-sm-2 col-form-label">语言</label>
<div class="col-sm-10">
<label i18n for="locale" class="col-sm-3 col-form-label">语言</label>
<div class="col-sm-9">
<select class="form-control" id="locale" [(ngModel)]="locale" name="locale">
<option value="en-US">English</option>
<option value="zh-CN">简体中文</option>
</select>
</div>
</div>
<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">
<label i18n for="chkImportEnabled">我确认我在开发者指导下使用导入功能</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
......
......@@ -37,6 +37,7 @@ export class MyCardComponent implements OnInit {
update_elements: Map<string, ElementRef>;
locale: string;
importEnabled: boolean;
resizing: HTMLElement | null;
......@@ -104,6 +105,7 @@ export class MyCardComponent implements OnInit {
});
this.locale = this.settingsService.getLocale();
this.importEnabled = this.settingsService.getImportEnabled();
}
......@@ -159,8 +161,9 @@ export class MyCardComponent implements OnInit {
}
submit() {
this.settingsService.setImportEnabled(this.importEnabled);
if (this.locale !== this.settingsService.getLocale()) {
localStorage.setItem(SettingsService.SETTING_LOCALE, this.locale);
this.settingsService.setLocale(this.locale);
remote.app.relaunch();
remote.app.quit();
}
......
......@@ -21,10 +21,12 @@ export class SettingsService {
},
];
static SETTING_LOCALE = 'locale';
static IMPORT_ENABLED = 'importEnabled';
static defaultLocale = remote.app.getLocale();
locale: string;
libraries: Library[];
importEnabled: boolean;
getLibraries () {
......@@ -92,4 +94,22 @@ export class SettingsService {
this.locale = locale;
localStorage.setItem(SettingsService.SETTING_LOCALE, locale);
}
getImportEnabled(): boolean {
if (this.importEnabled === undefined) {
let importEnabled = localStorage.getItem(SettingsService.IMPORT_ENABLED);
if (!importEnabled) {
this.importEnabled = false;
localStorage.setItem(SettingsService.IMPORT_ENABLED, 'false');
} else {
this.importEnabled = importEnabled === 'true';
}
}
return this.importEnabled;
}
setImportEnabled(enabled: boolean) {
this.importEnabled = enabled;
localStorage.setItem(SettingsService.IMPORT_ENABLED, 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