Commit cf943090 authored by wudizhanche1000's avatar wudizhanche1000

Merge branch 'v3' of https://github.com/mycard/mycard into v3

parents b5c9d300 f7fa7a08
......@@ -59,6 +59,7 @@ export class App {
version: string;
local: AppLocal | null;
status: AppStatus;
conference: string | undefined;
isInstalled(): boolean {
return !!this.local;
......@@ -81,6 +82,7 @@ export class App {
this.network = app.network;
this.tags = app.tags;
this.version = app.version;
this.conference = app.conference;
}
findDependencies(): App[] {
......
......@@ -29,4 +29,4 @@
<app-detail *ngIf="currentApp" [currentApp]="currentApp"></app-detail>
<roster></roster>
</div>
<webview id="candy" [src]="candy_url" nodeintegration></webview>
\ No newline at end of file
<webview *ngIf="currentApp" #candy id="candy" [src]="candy_url" nodeintegration></webview>
/**
* Created by zh99998 on 16/9/2.
*/
import {Component, OnInit} from "@angular/core";
import {Component, OnInit, ElementRef, ViewChild} from "@angular/core";
import {AppsService} from "./apps.service";
import {LoginService, User} from "./login.service";
import {App, Category} from "./app";
import {DownloadService} from "./download.service";
import {InstallService} from "./install.service";
import {Http} from "@angular/http";
import {Http, URLSearchParams} from "@angular/http";
import * as path from 'path';
import {InstallConfig} from "./install-config";
import {AppLocal} from "./app-local";
import {UrlResolver} from "@angular/compiler";
import WebViewElement = Electron.WebViewElement;
@Component({
selector: 'lobby',
......@@ -19,23 +21,38 @@ import {AppLocal} from "./app-local";
})
export class LobbyComponent implements OnInit {
candy_url: string;
@ViewChild('candy')
candy?: ElementRef;
candy_url: URL;
currentApp: App;
private apps: Map<string,App>;
constructor(private appsService: AppsService, private loginService: LoginService, private downloadService: DownloadService,
private installService: InstallService, private http: Http) {
this.candy_url = './candy/index.html?jid=' + this.loginService.user.username + '@mycard.moe&password=' + this.loginService.user.external_id + '&nickname=' + this.loginService.user.username + '&autojoin=ygopro_china_north@conference.mycard.moe'
}
ngOnInit() {
this.appsService.loadApps()
.then((apps) => {
this.apps = apps;
this.currentApp = <App>this.apps.get("th06");
this.updateApp();
})
async ngOnInit() {
this.apps = await this.appsService.loadApps();
this.chooseApp(Array.from(this.apps.values()).find(app => app.isInstalled()) || <App>this.apps.get("ygopro"));
// 初始化聊天室
let url = new URL('candy/index.html', location.href);
let params: URLSearchParams = url['searchParams']; // TypeScrpt 缺了 url.searchParams 的定义
params.set('jid', this.loginService.user.username + '@mycard.moe');
params.set('password', this.loginService.user.external_id.toString());
params.set('nickname', this.loginService.user.username);
params.set('autojoin', this.currentApp.conference + '@conference.mycard.moe');
this.candy_url = url;
// 尝试更新应用
this.updateApp();
}
chooseApp(app: App) {
this.currentApp = app;
if (this.candy && this.currentApp.conference) {
(<WebViewElement>this.candy.nativeElement).send('join', this.currentApp.conference + '@conference.mycard.moe');
}
}
async updateApp() {
......@@ -99,9 +116,6 @@ export class LobbyComponent implements OnInit {
}
}
chooseApp(app: App) {
this.currentApp = app;
}
get grouped_apps() {
let contains = ["game", "music", "book"].map((value) => Category[value]);
......@@ -123,5 +137,3 @@ export class LobbyComponent implements OnInit {
return result
}
}
......@@ -78,7 +78,8 @@
"url": "#",
"title": "红魔乡新闻2"
}
]
],
"conference": "touhou"
},
{
"id": "th06-lang-zh-TW",
......@@ -218,7 +219,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th07-lang-zh-TW",
......@@ -358,7 +360,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th075-lang-zh-TW",
......@@ -499,7 +502,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th08-lang-zh-CN",
......@@ -639,7 +643,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th09-lang-zh-TW",
......@@ -779,7 +784,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th095-lang-zh-TW",
......@@ -919,7 +925,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th10-lang-zh-CN-zh-TW",
......@@ -1055,7 +1062,8 @@
"url": "wss://wudizhanche.mycard.moe:10800/"
}
]
}
},
"conference": "th105"
},
{
"id": "th105-lang-zh-CN",
......@@ -1181,7 +1189,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th11-lang-zh-TW",
......@@ -1321,7 +1330,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou"
},
{
"id": "th12-lang-zh-TW",
......@@ -1463,7 +1473,8 @@
"url": "wss://wudizhanche.mycard.moe:10800/"
}
]
}
},
"conference": "th123"
},
{
"id": "th123-lang-zh-CN",
......@@ -1575,7 +1586,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou-pc98"
},
{
"id": "th2",
......@@ -1631,7 +1643,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou-pc98"
},
{
"id": "th2-lang-zh-TW",
......@@ -1742,7 +1755,8 @@
"win32": "1.06",
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou-pc98"
},
{
"id": "th3-lang-zh-TW",
......@@ -1853,7 +1867,8 @@
"win32": "1.06",
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou-pc98"
},
{
"id": "th4-lang-zh-TW",
......@@ -1965,7 +1980,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "touhou-pc98"
},
{
"id": "th5-lang-zh-TW",
......@@ -2081,7 +2097,8 @@
"title": "News Title2",
"text": "聚集的祈愿将成为新生的闪耀之星,化作光芒闪耀的道路吧!"
}
]
],
"conference": "ygopro_china_north"
},
{
"id": "desmume",
......@@ -2137,7 +2154,7 @@
"description": {
"zh-CN": "A script engine for \"yu-gi-oh!\" and sample gui."
},
"category": "emulator",
"category": "game",
"tags": [
"yugioh"
],
......@@ -2175,7 +2192,8 @@
"version": {
"darwin": "1.06"
},
"news": []
"news": [],
"conference": "ds"
},
{
"id": "ghost_trick-lang-zh-CN",
......
......@@ -12,58 +12,42 @@
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="libs.min.js"></script>
<script type="text/javascript" src="candy.min.js"></script>
<script type="text/javascript">
//require('electron').remote.getCurrentWebContents().openDevTools();
$(document).ready(function () {
var querystring = require('querystring');
var params = querystring.parse(location.search.slice(1));
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>'
</head>
<body>
<div id="candy"></div>
<script type="text/javascript">
const {remote, ipcRenderer} = require('electron');
require('electron-cookies'); // https://github.com/hstove/electron-cookies
Candy.Util.setCookie('candy-nostatusmessages', '1', 365);
Candy.init('wss://chat.mycard.moe:5280/websocket', {
core: {
// only set this to true if developing / debugging errors
debug: false,
// autojoin is a *required* parameter if you don't have a plugin (e.g. roomPanel) for it
// true
// -> fetch info from server (NOTE: does only work with openfire server)
// ['test@conference.example.com']
// -> array of rooms to join after connecting
autojoin: [params.autojoin],
resource: 'mycard-' + Math.random().toString().split('.')[1]
},
view: {assets: 'res/', language: 'cn'}
});
// remote.getCurrentWebContents().openDevTools();
ipcRenderer.on('join', (event, message) => {
Candy.Core.Action.Jabber.Room.Join(message);
Candy.View.Pane.Chat.setActiveTab(message);
});
Candy.Core.connect(params.jid, params.password, params.nickname);
// fix
Base64.encode = btoa.bind(window);
Base64.decode = atob.bind(window);
Candy.Core.connect();
/**
* Thanks for trying Candy!
*
* If you need more information, please see here:
* - Setup instructions & config params: http://candy-chat.github.io/candy/#setup
* - FAQ & more: https://github.com/candy-chat/candy/wiki
*
* Mailinglist for questions:
* - http://groups.google.com/group/candy-chat
*
* Github issues for bugs:
* - https://github.com/candy-chat/candy/issues
*/
// candy init
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.Util.setCookie('candy-nostatusmessages', '1', 365);
Candy.init('wss://chat.mycard.moe:5280/websocket', {
core: {
debug: false,
autojoin: [params.get('autojoin')],
resource: 'mycard-' + Math.random().toString().split('.')[1]
},
view: {assets: 'res/', language: 'cn'}
});
Candy.Core.connect(params.get('jid'), params.get('password'), params.get('nickname'));
</script>
// fix
Base64.encode = function (input) {
return new Buffer(input).toString('base64');
};
Base64.decode = function (input) {
return new Buffer(input, 'base64').toString();
};
});
</script>
</head>
<body>
<div id="candy"></div>
</body>
</html>
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