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

fix

parent 783a2327
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button i18n type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button i18n id="submit" type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button> <button i18n id="submit" type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button>
</div> </div>
</form> </form>
......
...@@ -541,6 +541,9 @@ export class AppsService { ...@@ -541,6 +541,9 @@ export class AppsService {
app.local = local; app.local = local;
this.saveAppLocal(app); this.saveAppLocal(app);
app.status.status = "ready"; app.status.status = "ready";
if (app.id == 'ygopro') {
localStorage.removeItem('ygopro-locale')
}
} catch (e) { } catch (e) {
console.log("exception in doInstall", e); console.log("exception in doInstall", e);
throw e; throw e;
......
/**
* Created by zh99998 on 16/9/2.
*/
import {Component} from "@angular/core";
@Component({
moduleId: module.id,
selector: 'community',
templateUrl: 'community.component.html',
styleUrls: ['community.component.css'],
})
export class CommunityComponent {
}
...@@ -9,6 +9,7 @@ import {DownloadService} from "./download.service"; ...@@ -9,6 +9,7 @@ import {DownloadService} from "./download.service";
import {Http, URLSearchParams} from "@angular/http"; import {Http, URLSearchParams} from "@angular/http";
import {shell} from "electron"; import {shell} from "electron";
import WebViewElement = Electron.WebViewElement; import WebViewElement = Electron.WebViewElement;
import {SettingsService} from "./settings.sevices";
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
...@@ -24,7 +25,7 @@ export class LobbyComponent implements OnInit { ...@@ -24,7 +25,7 @@ export class LobbyComponent implements OnInit {
currentApp: App; currentApp: App;
private apps: Map<string,App>; private apps: Map<string,App>;
constructor(private appsService: AppsService, private loginService: LoginService) { constructor(private appsService: AppsService, private loginService: LoginService, private settingsService: SettingsService) {
} }
async ngOnInit() { async ngOnInit() {
...@@ -38,6 +39,13 @@ export class LobbyComponent implements OnInit { ...@@ -38,6 +39,13 @@ export class LobbyComponent implements OnInit {
params.set('jid', this.loginService.user.username + '@mycard.moe'); params.set('jid', this.loginService.user.username + '@mycard.moe');
params.set('password', this.loginService.user.external_id.toString()); params.set('password', this.loginService.user.external_id.toString());
params.set('nickname', this.loginService.user.username); params.set('nickname', this.loginService.user.username);
switch(this.settingsService.getLocale()){
case 'zh-CN':
params.set('language', 'cn');
break;
default:
params.set('language', 'en');
}
if (this.currentApp.conference) { if (this.currentApp.conference) {
params.set('autojoin', this.currentApp.conference + '@conference.mycard.moe'); params.set('autojoin', this.currentApp.conference + '@conference.mycard.moe');
} }
......
<webview [src]="url" (will-navigate)="return_sso($event.url)" (did-get-redirect-request)="return_sso($event.newURL)"></webview> <webview [src]="url" (will-navigate)="return_sso($event.url)" (did-get-redirect-request)="return_sso($event.newURL)" (new-window)="openExternal($event.url)"></webview>
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,7 @@ import {LoginService} from "./login.service"; ...@@ -6,6 +6,7 @@ import {LoginService} from "./login.service";
import * as crypto from "crypto"; import * as crypto from "crypto";
import * as querystring from "querystring"; import * as querystring from "querystring";
import * as url from "url"; import * as url from "url";
import {shell} from "electron";
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
...@@ -46,4 +47,7 @@ export class LoginComponent { ...@@ -46,4 +47,7 @@ export class LoginComponent {
this.loginService.login(user); this.loginService.login(user);
} }
openExternal(url: string) {
shell.openExternal(url);
}
} }
...@@ -39,4 +39,4 @@ ...@@ -39,4 +39,4 @@
<login class="page" *ngIf="!loginService.logged_in"></login> <login class="page" *ngIf="!loginService.logged_in"></login>
<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"></webview> <webview class="page" *ngIf="loginService.logged_in" [hidden]="currentPage != 'community'" src="https://ygobbs.com" (new-window)="openExternal($event.url)"></webview>
import {Component, Renderer, ChangeDetectorRef, OnInit, ElementRef, ViewChild} from "@angular/core"; import {Component, Renderer, ChangeDetectorRef, OnInit, ElementRef, ViewChild} from "@angular/core";
import {remote} from "electron"; import {remote, shell} from "electron";
import {LoginService} from "./login.service"; import {LoginService} from "./login.service";
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater'); const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
declare const $: any; declare const $: any;
...@@ -89,4 +89,8 @@ export class MyCardComponent implements OnInit { ...@@ -89,4 +89,8 @@ export class MyCardComponent implements OnInit {
$(element.nativeElement).tooltip({placement: 'bottom', container: 'body'}) $(element.nativeElement).tooltip({placement: 'bottom', container: 'body'})
} }
} }
openExternal(url: string) {
shell.openExternal(url);
}
} }
...@@ -8,7 +8,6 @@ import {StoreComponent} from "./store.component"; ...@@ -8,7 +8,6 @@ import {StoreComponent} from "./store.component";
import {LobbyComponent} from "./lobby.component"; import {LobbyComponent} from "./lobby.component";
import {AppDetailComponent} from "./app-detail.component"; import {AppDetailComponent} from "./app-detail.component";
import {RosterComponent} from "./roster.component"; import {RosterComponent} from "./roster.component";
import {CommunityComponent} from "./community.component";
import {YGOProComponent} from "./ygopro.component"; import {YGOProComponent} from "./ygopro.component";
import {AppsService} from "./apps.service"; import {AppsService} from "./apps.service";
import {SettingsService} from "./settings.sevices"; import {SettingsService} from "./settings.sevices";
...@@ -19,7 +18,7 @@ import {DownloadService} from "./download.service"; ...@@ -19,7 +18,7 @@ import {DownloadService} from "./download.service";
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule], imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
declarations: [ declarations: [
MyCardComponent, LoginComponent, StoreComponent, LobbyComponent, MyCardComponent, LoginComponent, StoreComponent, LobbyComponent,
CommunityComponent, AppDetailComponent, RosterComponent, YGOProComponent, AppDetailComponent, RosterComponent, YGOProComponent,
], ],
bootstrap: [MyCardComponent], bootstrap: [MyCardComponent],
providers: [ providers: [
......
...@@ -16,7 +16,7 @@ export class SettingsService { ...@@ -16,7 +16,7 @@ export class SettingsService {
static defaultLibraries = [ static defaultLibraries = [
{ {
"default": true, "default": true,
path: path.join(remote.app.getPath("appData"), "library") path: path.join(remote.app.getPath("appData"), "MyCardLibrary")
}, },
]; ];
libraries: Library[]; libraries: Library[];
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
<h4 class="modal-title" id="myModalLabel1">单人模式</h4> <h4 i18n class="modal-title" id="myModalLabel1">单人模式</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<label i18n>选择对手</label> <label i18n>选择对手</label>
......
...@@ -121,9 +121,9 @@ export class YGOProComponent implements OnInit { ...@@ -121,9 +121,9 @@ export class YGOProComponent implements OnInit {
} }
} }
ngOnInit() { async ngOnInit() {
this.system_conf = path.join(this.app.local!.path, 'system.conf'); this.system_conf = path.join(this.app.local!.path, 'system.conf');
this.refresh(); await this.refresh();
let modal = $('#game-list-modal'); let modal = $('#game-list-modal');
...@@ -262,7 +262,7 @@ export class YGOProComponent implements OnInit { ...@@ -262,7 +262,7 @@ export class YGOProComponent implements OnInit {
win.minimize(); win.minimize();
let locale = this.settingsService.getLocale(); let locale = this.settingsService.getLocale();
if (localStorage.getItem('ygopro-locale') != locale) { if (localStorage.getItem('ygopro-locale') != locale) {
console.log(`try convert ygopro locale to ${locale}`) console.log(`try convert ygopro locale to ${locale}`);
try { try {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let source = fs.createReadStream(path.join(this.app.local!.path, 'locales', locale, 'strings.conf')); let source = fs.createReadStream(path.join(this.app.local!.path, 'locales', locale, 'strings.conf'));
...@@ -296,7 +296,7 @@ export class YGOProComponent implements OnInit { ...@@ -296,7 +296,7 @@ export class YGOProComponent implements OnInit {
reject(error) reject(error)
}); });
}); });
localStorage.setItem('ygopro-locale', locale) localStorage.setItem('ygopro-locale', locale);
console.log(`convert ygopro locale to ${locale} success`) console.log(`convert ygopro locale to ${locale} success`)
} catch (error) { } catch (error) {
console.error(`convert ygopro locale to ${locale} failed`, error) console.error(`convert ygopro locale to ${locale} failed`, error)
...@@ -311,8 +311,9 @@ export class YGOProComponent implements OnInit { ...@@ -311,8 +311,9 @@ export class YGOProComponent implements OnInit {
reject(error); reject(error);
win.restore() win.restore()
}); });
child.on('exit', (code, signal) => { child.on('exit', async(code, signal) => {
// error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。 // error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。
await this.refresh();
resolve(); resolve();
win.restore() win.restore()
}) })
......
...@@ -2052,8 +2052,8 @@ ...@@ -2052,8 +2052,8 @@
} }
}, },
"version": { "version": {
"win32": "1.033.C-7", "win32": "1.033.C-8",
"darwin": "1.033.C-7" "darwin": "1.033.C-8"
}, },
"news": { "news": {
"zh-CN": [ "zh-CN": [
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
// candy init // candy init
const params = new URLSearchParams(location.search); const params = new URLSearchParams(location.search);
Candy.View.Template.Login.form = '<form method="post" id="login-form" class="login-form">' + '<input type="hidden" id="nickname" name="nickname" value="' + params.nickname + '"/>' + '{{#displayUsername}}<input type="hidden" id="username" name="username" value="' + params.jid + '"/>' + '{{#displayDomain}} <span class="at-symbol">@</span> ' + '<select id="domain" name="domain">{{#domains}}<option value="{{domain}}">{{domain}}</option>{{/domains}}</select>' + "{{/displayDomain}}" + "{{/displayUsername}}" + '{{#presetJid}}<input type="hidden" id="username" name="username" value="{{presetJid}}"/>{{/presetJid}}' + '{{#displayPassword}}<input type="hidden" id="password" name="password" value="' + params.password + '"/>{{/displayPassword}}' + '<input type="submit" class="button" value="{{_loginSubmit}}" /></form>';; Candy.View.Template.Login.form = '<form method="post" id="login-form" class="login-form">' + '<input type="hidden" id="nickname" name="nickname" value="' + params.nickname + '"/>' + '{{#displayUsername}}<input type="hidden" id="username" name="username" value="' + params.jid + '"/>' + '{{#displayDomain}} <span class="at-symbol">@</span> ' + '<select id="domain" name="domain">{{#domains}}<option value="{{domain}}">{{domain}}</option>{{/domains}}</select>' + "{{/displayDomain}}" + "{{/displayUsername}}" + '{{#presetJid}}<input type="hidden" id="username" name="username" value="{{presetJid}}"/>{{/presetJid}}' + '{{#displayPassword}}<input type="hidden" id="password" name="password" value="' + params.password + '"/>{{/displayPassword}}' + '<input type="submit" class="button" value="{{_loginSubmit}}" /></form>';
Candy.Util.setCookie('candy-nostatusmessages', '1', 365); Candy.Util.setCookie('candy-nostatusmessages', '1', 365);
Candy.init('wss://chat.mycard.moe:5280/websocket', { Candy.init('wss://chat.mycard.moe:5280/websocket', {
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
autojoin: params.get('autojoin') && [params.get('autojoin')], autojoin: params.get('autojoin') && [params.get('autojoin')],
resource: 'mycard-' + Math.random().toString().split('.')[1] resource: 'mycard-' + Math.random().toString().split('.')[1]
}, },
view: {assets: 'res/', language: 'cn'} view: {assets: 'res/', language: params.get('language')}
}); });
Candy.Core.connect(params.get('jid'), params.get('password'), params.get('nickname')); Candy.Core.connect(params.get('jid'), params.get('password'), params.get('nickname'));
......
This diff is collapsed.
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