Commit ce76a122 authored by 神楽坂玲奈's avatar 神楽坂玲奈

手工语言切换,按Meta键呼出控制台

parent 864d393a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<a class="navbar-brand" href="#">MyCard</a> <a class="navbar-brand" href="#">MyCard</a>
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li *ngIf="!loginService.logged_in" class="nav-item active"> <li *ngIf="!loginService.logged_in" class="nav-item active">
<a class="nav-link" href="#">登录<span class="sr-only">(current)</span></a> <a i18n class="nav-link" href="#">登录</a>
</li> </li>
<!-- <!--
<li [ngClass]="{active: routingService.component == 'store'}" class="nav-item"> <li [ngClass]="{active: routingService.component == 'store'}" class="nav-item">
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<a href="#" class="profile"><img id="avatar" [src]="loginService.user.avatar_url" alt="image"></a> <a href="#" class="profile"><img id="avatar" [src]="loginService.user.avatar_url" alt="image"></a>
<a href="#" class="profile item" id="username">{{loginService.user.username}}</a> <a href="#" class="profile item" id="username">{{loginService.user.username}}</a>
<a i18n href="#" (click)="loginService.logout()" class="item">切换账号</a> <a i18n href="#" (click)="loginService.logout()" class="item">切换账号</a>
<a i18n href="#" data-toggle="modal" data-target="#settings-modal" class="item">设置</a>
</div> </div>
<div id="window-buttons"> <div id="window-buttons">
<i (click)="currentWindow.minimize()" class="fa fa-minus"></i> <i (click)="currentWindow.minimize()" class="fa fa-minus"></i>
...@@ -40,3 +41,36 @@ ...@@ -40,3 +41,36 @@
<store class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'store'"></store> <store class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'store'"></store>
<lobby class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'lobby'"></lobby> <lobby class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'lobby'"></lobby>
<webview class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'community'" src="https://ygobbs.com" (new-window)="openExternal($event.url)"></webview> <webview class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'community'" src="https://ygobbs.com" (new-window)="openExternal($event.url)"></webview>
<!-- Modal -->
<div class="modal fade" id="settings-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 i18n class="modal-title" id="myModalLabel">MyCard 设置</h4>
</div>
<form (submit)="submit()">
<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">
<select class="form-control" id="locale" [(ngModel)]="locale" name="locale">
<option i18n value="en-US">英文</option>
<option i18n value="zh-CN">简体中文</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button i18n type="submit" class="btn btn-primary">确定</button>
</div>
</form>
</div>
</div>
</div>
\ No newline at end of file
import {Component, Renderer, ChangeDetectorRef, OnInit, ElementRef, ViewChild} from "@angular/core"; import {Component, Renderer, ChangeDetectorRef, OnInit, ElementRef, ViewChild} from "@angular/core";
import {remote, shell} from "electron"; import {remote, shell} from "electron";
import {LoginService} from "./login.service"; import {LoginService} from "./login.service";
import {SettingsService} from "./settings.sevices";
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater'); const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
declare const $: any; declare const $: any;
...@@ -29,6 +30,8 @@ export class MyCardComponent implements OnInit { ...@@ -29,6 +30,8 @@ export class MyCardComponent implements OnInit {
update_downloaded: ElementRef; update_downloaded: ElementRef;
update_elements: Map<string, ElementRef>; update_elements: Map<string, ElementRef>;
locale: string;
ngOnInit() { ngOnInit() {
this.update_elements = new Map(Object.entries({ this.update_elements = new Map(Object.entries({
'error': this.error, 'error': this.error,
...@@ -38,7 +41,7 @@ export class MyCardComponent implements OnInit { ...@@ -38,7 +41,7 @@ export class MyCardComponent implements OnInit {
})); }));
} }
constructor(private renderer: Renderer, private loginService: LoginService, private ref: ChangeDetectorRef) { constructor(private renderer: Renderer, private loginService: LoginService, private ref: ChangeDetectorRef, private settingsService: SettingsService) {
// renderer.listenGlobal('window', 'message', (event) => { // renderer.listenGlobal('window', 'message', (event) => {
// console.log(event); // console.log(event);
// // Do something with 'event' // // Do something with 'event'
...@@ -63,6 +66,8 @@ export class MyCardComponent implements OnInit { ...@@ -63,6 +66,8 @@ export class MyCardComponent implements OnInit {
this.set_update_status('update-downloaded'); this.set_update_status('update-downloaded');
}); });
this.locale = this.settingsService.getLocale();
} }
update_retry() { update_retry() {
...@@ -93,4 +98,12 @@ export class MyCardComponent implements OnInit { ...@@ -93,4 +98,12 @@ export class MyCardComponent implements OnInit {
openExternal(url: string) { openExternal(url: string) {
shell.openExternal(url); shell.openExternal(url);
} }
submit() {
if (this.locale != this.settingsService.getLocale()) {
localStorage.setItem(SettingsService.SETTING_LOCALE, this.locale);
remote.app.relaunch();
remote.app.quit()
}
}
} }
...@@ -170,7 +170,12 @@ let tray; ...@@ -170,7 +170,12 @@ let tray;
function createTray() { function createTray() {
tray = new Tray(path.join(process.env['NODE_ENV'] == 'production' ? process.resourcesPath : app.getAppPath(), 'images', 'icon.ico')); tray = new Tray(path.join(process.env['NODE_ENV'] == 'production' ? process.resourcesPath : app.getAppPath(), 'images', 'icon.ico'));
tray.on('click', (event) => { tray.on('click', (event) => {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); console.log(event);
if (event.metaKey) {
mainWindow.webContents.openDevTools();
} else {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
}
}); });
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
// {label: '游戏', type: 'normal', click: (menuItem, browserWindow, event)=>{}}, // {label: '游戏', type: 'normal', click: (menuItem, browserWindow, event)=>{}},
......
<?xml version="1.0" ?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <?xml version="1.0" ?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="ng2.template" source-language="zh-CN" target-language="en-US"> <file datatype="plaintext" original="ng2.template" source-language="zh-CN" target-language="en-US">
<body> <body>
<trans-unit datatype="html" id="ae5dccdf399fb229fb9f0153a7ec5c28a4579ca1">
<source>登录</source>
<target>Sign In</target>
</trans-unit>
<trans-unit datatype="html" id="fbfb7c4354663a67786aa5aee748d1f38b8fe71c"> <trans-unit datatype="html" id="fbfb7c4354663a67786aa5aee748d1f38b8fe71c">
<source>游戏</source> <source>游戏</source>
<target>Library</target> <target>Library</target>
...@@ -14,7 +19,42 @@ ...@@ -14,7 +19,42 @@
<trans-unit datatype="html" id="8422ff34db177236e8f54d415b07c972284c36bf"> <trans-unit datatype="html" id="8422ff34db177236e8f54d415b07c972284c36bf">
<source>切换账号</source> <source>切换账号</source>
<target>Change Account</target> <target>Change Account</target>
</trans-unit>
<trans-unit datatype="html" id="67adbad4f646bb8e1c440522bafea8fe5f7e6bfd">
<source>设置</source>
<target>Custom</target>
</trans-unit>
<trans-unit datatype="html" id="9d9335d175b40b85f2b98610af517a8b7509c089">
<source>MyCard 设置</source>
<target>MyCard Settings</target>
</trans-unit>
<trans-unit datatype="html" id="b22ce2179c700e2499e1d402fb1d3f4392c7f6af">
<source>语言</source>
<target>Language</target>
</trans-unit>
<trans-unit datatype="html" id="80a97c5d9418c828bebf91b112188f12a4f5317c">
<source>英文</source>
<target>English</target>
</trans-unit>
<trans-unit datatype="html" id="8f9b332ffed52a814f1926470890d7e75865f2ce">
<source>简体中文</source>
<target>Simplified Chinese</target>
</trans-unit>
<trans-unit datatype="html" id="f6f3be110e7043e3cfe71a7bd75b8b3be79bff5d">
<source>取消</source>
<target>Cancel</target>
</trans-unit>
<trans-unit datatype="html" id="af09a0e18f4200fdb729133ddcd5bb43d52439aa">
<source>确定</source>
<target>OK</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="1761e51e36b01ae1e0012914bd58aa2a741d0401"> <trans-unit datatype="html" id="1761e51e36b01ae1e0012914bd58aa2a741d0401">
<source>已安装</source> <source>已安装</source>
...@@ -50,11 +90,6 @@ ...@@ -50,11 +90,6 @@
<source>安装</source> <source>安装</source>
<target>Install</target> <target>Install</target>
</trans-unit>
<trans-unit datatype="html" id="e6194d8a9c8da57b667847cd80f1da563f2c2b1e">
<source>导入</source>
<target>Import</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="8bb533b37ee18bf8d09df19b4d7234b38f134909"> <trans-unit datatype="html" id="8bb533b37ee18bf8d09df19b4d7234b38f134909">
<source>正在下载</source> <source>正在下载</source>
...@@ -80,11 +115,6 @@ ...@@ -80,11 +115,6 @@
<source>运行</source> <source>运行</source>
<target>Start</target> <target>Start</target>
</trans-unit>
<trans-unit datatype="html" id="67adbad4f646bb8e1c440522bafea8fe5f7e6bfd">
<source>设置</source>
<target>Custom</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="3d6cad40e26f99e39bc6f5925a890ba83b67ce5b"> <trans-unit datatype="html" id="3d6cad40e26f99e39bc6f5925a890ba83b67ce5b">
<source>联机</source> <source>联机</source>
...@@ -135,11 +165,6 @@ ...@@ -135,11 +165,6 @@
<source>浏览本地文件</source> <source>浏览本地文件</source>
<target>Browse</target> <target>Browse</target>
</trans-unit>
<trans-unit datatype="html" id="6d582ed48c57c91fc7cf10f36f3869cd33808d1d">
<source>校验完整性</source>
<target>Verify integrity</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="4809edca33b1a07d7d6e8905287d3825e676f2c8"> <trans-unit datatype="html" id="4809edca33b1a07d7d6e8905287d3825e676f2c8">
<source>安装 <x id="INTERPOLATION"/></source> <source>安装 <x id="INTERPOLATION"/></source>
...@@ -185,11 +210,6 @@ ...@@ -185,11 +210,6 @@
<source>依赖:</source> <source>依赖:</source>
<target>Dependencies</target> <target>Dependencies</target>
</trans-unit>
<trans-unit datatype="html" id="f6f3be110e7043e3cfe71a7bd75b8b3be79bff5d">
<source>取消</source>
<target>Cancel</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="def237147323023c1f5ce0579345da19d4707fdb"> <trans-unit datatype="html" id="def237147323023c1f5ce0579345da19d4707fdb">
<source>卡组</source> <source>卡组</source>
...@@ -298,7 +318,7 @@ ...@@ -298,7 +318,7 @@
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="d4038dd5d0e9d5139d425fc7bea40e40d965cc5b"> <trans-unit datatype="html" id="d4038dd5d0e9d5139d425fc7bea40e40d965cc5b">
<source>额外选项</source> <source>额外选项</source>
<target>Additional Options</target> <target>Additional Options</target>
</trans-unit> </trans-unit>
<trans-unit datatype="html" id="01cfbee3f1d69f5adae299b7b8c8d75034aef53b"> <trans-unit datatype="html" id="01cfbee3f1d69f5adae299b7b8c8d75034aef53b">
......
{ {
"name": "mycard", "name": "mycard",
"version": "3.0.1", "version": "3.0.2",
"description": "mycard", "description": "mycard",
"keywords": [], "keywords": [],
"author": "zh99998 <zh99998@gmail.com>", "author": "zh99998 <zh99998@gmail.com>",
......
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