Commit 17242131 authored by hjistc's avatar hjistc

UI, 3.0.17

parent 668c1f58
......@@ -4,15 +4,12 @@
position: relative;
}
:host:before {
content: '';
background-image: url('http://vignette2.wikia.nocookie.net/touhou/images/2/2c/Th10_cover.jpg/revision/latest?cb=20071101234746');
#background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
filter: grayscale(50%) opacity(10%);
background-repeat: no-repeat;
background-size: 100% auto;
......@@ -20,7 +17,7 @@
}
.scroll {
padding: 1rem;
padding: 1rem 1rem 0 1rem;
height: 100%;
}
......@@ -59,7 +56,7 @@ progress {
#network {
display: inline-block;
vertical-align: middle;
width: 300px;
width: 230px;
}
#network .input-group-btn > .btn:not(:last-child):not(.dropdown-toggle) {
......@@ -87,7 +84,6 @@ progress {
h1 {
font-size: 28px;
margin-left: 1rem;
}
#status {
......@@ -112,9 +108,10 @@ h2 {
.panel {
border: 1px solid #eceeef;
border-radius: 6px;
background: rgba(255, 255, 255, .7);
background: rgba(255,255,255,.7);
padding: .8rem;
margin-bottom: 1rem;
box-shadow: 0 0 15px rgba(0,0,0,.05);
position: relative;
}
......@@ -150,4 +147,76 @@ h2 {
#local h2 {
margin-bottom: .8rem;
}
\ No newline at end of file
}
#icon {
width: 128px;
height: 128px;
box-shadow: 0 0 4px #ccc;
}
#main {
display: flex;
flex-direction: row;
}
#right {
margin-left: 1rem;
}
h1 {
font-size: 28px;
margin-bottom: 0;
}
#time {
font-size: 14px;
margin-bottom: .6rem;
}
th {
width: 25%;
}
.moreinfo {
color: #00a4d9;
display: block;
position: absolute;
top: 12px;
right: 18px;
font-size: 14px;
}
#arena {
position: relative;
}
.btn-primary {
background-color: #00a4d9;
border-color: #008dbb;
}
/* 竞技场 */
h2 {
font-size: 20px;
}
dt, dd {
font-size: 14px;
}
table {
margin-bottom: 0;
}
table th, table td {
border-top: none;
font-size: 14px;
font-weight: normal;
}
/* */
\ No newline at end of file
This diff is collapsed.
import {Component, OnInit, Input, ChangeDetectorRef} from '@angular/core';
import {Component, OnInit, Input, ChangeDetectorRef, OnChanges, SimpleChanges} from '@angular/core';
import {AppsService} from './apps.service';
import {InstallOption} from './install-option';
import {SettingsService} from './settings.sevices';
......@@ -8,6 +8,7 @@ import {clipboard, remote} from 'electron';
import * as path from 'path';
import * as fs from 'fs';
import * as $ from 'jquery';
import {Points} from './ygopro.component';
declare const Notification: any;
......@@ -17,7 +18,7 @@ declare const Notification: any;
templateUrl: 'app-detail.component.html',
styleUrls: ['app-detail.component.css'],
})
export class AppDetailComponent implements OnInit {
export class AppDetailComponent implements OnInit, OnChanges {
@Input()
currentApp: App;
platform = process.platform;
......@@ -28,11 +29,26 @@ export class AppDetailComponent implements OnInit {
referencesInstall: {[id: string]: boolean};
import_path: string;
background: string;
points: Points;
constructor(private appsService: AppsService, private settingsService: SettingsService,
private downloadService: DownloadService, private ref: ChangeDetectorRef) {
}
ngOnChanges(changes: SimpleChanges): void {
if (changes['currentApp']) {
if (this.currentApp.background && this.currentApp.background.length > 0) {
let url = this.currentApp.background[Math.floor(Math.random() * this.currentApp.background.length)];
this.background = `url(${url})`;
} else {
this.background = '';
}
}
}
async ngOnInit(): Promise<void> {
let volume = 'A';
for (let i = 0; i < 26; i++) {
......@@ -216,4 +232,8 @@ export class AppDetailComponent implements OnInit {
}
}
onPoints(points: Points) {
this.points = points;
}
}
......@@ -72,6 +72,10 @@ export class App {
files: Map<string, FileOptions>;
data: any;
icon: string;
cover: string;
background: string;
static downloadUrl (app: App, platform: string, locale: string): string {
if (app.id === 'ygopro') {
return `https://thief.mycard.moe/metalinks/${app.id}-${process.platform}-${locale}/${app.version}`;
......@@ -165,6 +169,10 @@ export class App {
this.conference = app.conference;
this.files = app.files;
this.data = app.data;
this.icon = app.icon;
this.cover = app.cover;
this.background = app.background;
}
findDependencies(): App[] {
......
......@@ -35,7 +35,6 @@ import 'node_modules/candy-shop/modify-role/candy.js';
import 'node_modules/candy-shop/me-does/candy.js';
import 'node_modules/candy-shop/notifications/candy.js';
import 'node_modules/candy-shop/refocus/candy.js';
import 'electron-cookies';
delete window['jQuery'];
......@@ -59,7 +58,8 @@ Candy.Util.getPosTopAccordingToWindowBounds = new Proxy(Candy.Util.getPosTopAcco
}
});
Candy.Util.setCookie('candy-nostatusmessages', '1', 365);
document['__defineGetter__']('cookie', () => 'candy-nostatusmessages');
document['__defineSetter__']('cookie', () => true);
@Component({
moduleId: module.id,
......@@ -75,10 +75,10 @@ export class CandyComponent implements OnInit, OnChanges {
password: string;
nickname: string;
constructor (private loginService: LoginService, private settingsService: SettingsService, private element: ElementRef) {
constructor(private loginService: LoginService, private settingsService: SettingsService, private element: ElementRef) {
}
ngOnInit () {
ngOnInit() {
this.jid = this.loginService.user.username + '@mycard.moe';
this.password = this.loginService.user.external_id.toString();
......@@ -136,7 +136,7 @@ export class CandyComponent implements OnInit, OnChanges {
Candy.Core.connect(this.jid, this.password, this.nickname);
}
ngOnChanges (changes: SimpleChanges): void {
ngOnChanges(changes: SimpleChanges): void {
if (!Candy.Core.getConnection()) {
return;
}
......
......@@ -2,6 +2,7 @@
display: flex;
height: 100%;
}
#right {
display: flex;
flex-direction: column;
......@@ -166,19 +167,23 @@ nav {
a {
cursor: default;
}
.search {
background-color: #ebf3f8;
border: none;
}
i.search {
color: #a7a7a7;
}
input.search {
padding-left: 0;
font-size: 14px;
font-family: -apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
}
input.search::-webkit-input-placeholder{
input.search::-webkit-input-placeholder {
color: #a7a7a7;
}
......@@ -229,4 +234,28 @@ nav::-webkit-resizer {
left: 0;
right: 0;
cursor: row-resize;
}
\ No newline at end of file
}
#nav-wrapper {
z-index: 90;
box-shadow: 0 0 5px rgba(0, 0, 0, .2);
}
#candy-wrapper {
z-index: 80;
box-shadow: 0 0 5px rgba(0, 0, 0, .2);
}
roster {
z-index: 90;
}
/*#right-shadow {*/
/*width: 190px;*/
/*z-index: 95;*/
/*box-shadow: 0 0 5px rgba(0, 0, 0, .2);*/
/*position: absolute;*/
/*top: 0;*/
/*right: 0;*/
/*bottom: 0;*/
/*}*/
\ No newline at end of file
......@@ -11,7 +11,7 @@
<ul *ngIf="grouped_apps.installed" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.installed" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" class="nav-link" [class.active]="app===currentApp" [href]="'https://mycard.moe/' + app.id">
<img class="icon" src="https://lh3.googleusercontent.com/-crYEtoQ-4Ho/AAAAAAAAAAI/AAAAAAAAAAA/AKB_U8u0CDmxkVqQgOKesrJIb-6eiXacgA/s32-c-mo/photo.jpg">
<img *ngIf="app.icon" class="icon" [src]="app.icon">
{{app.name}}<i *ngIf="!app.isReady() && !app.status.total" class="spin fa fa-circle-o-notch fa-spin fa-fw"></i>
<div *ngIf="!app.isReady() && app.status.total" class="progress">
<div class="pie" [class.second-half]="app.status.progress/app.status.total>0.5">
......@@ -26,31 +26,31 @@
<span i18n *ngIf="grouped_apps.recommend">推荐</span>
<ul *ngIf="grouped_apps.recommend" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.recommend" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">{{app.name}}</a>
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp"><img *ngIf="app.icon" class="icon" [src]="app.icon">{{app.name}}</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.mysterious">迷之物体</span>
<ul *ngIf="grouped_apps.mysterious" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.mysterious" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">{{app.name}}</a>
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp"><img *ngIf="app.icon" class="icon" [src]="app.icon">{{app.name}}</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.touhou">东方 Project</span>
<ul *ngIf="grouped_apps.touhou" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.touhou" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">{{app.name}}</a>
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp"><img *ngIf="app.icon" class="icon" [src]="app.icon">{{app.name}}</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.touhou_pc98">东方旧作</span>
<ul *ngIf="grouped_apps.touhou_pc98" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.touhou_pc98" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">{{app.name}}</a>
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp"><img *ngIf="app.icon" class="icon" [src]="app.icon">{{app.name}}</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.runtime_installed">已安装的运行库</span>
<ul *ngIf="grouped_apps.runtime_installed" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.runtime_installed" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">{{app.name}}</a>
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp"><img *ngIf="app.icon" class="icon" [src]="app.icon">{{app.name}}</a>
</li>
</ul>
</nav>
......@@ -59,7 +59,6 @@
<div id="right">
<div id="main">
<app-detail *ngIf="currentApp" [currentApp]="currentApp"></app-detail>
<roster class="scroll"></roster>
......@@ -70,3 +69,5 @@
<candy *ngIf="currentApp" [currentApp]="currentApp"></candy>
</div>
</div>
<div id="right-shadow"></div>
\ No newline at end of file
:host {
background-color: white;
}
.page {
flex-grow: 1;
/*margin-bottom: 60px;*/
......@@ -49,6 +52,12 @@ lobby[hidden], webview[hidden] {
overflow: hidden;
}
/* 不加这个切到有 Webview 的页面,上面的圆角会消失 */
/* 即使加了这个,下面的圆角也会消失 */
webview {
overflow: hidden;
}
#navbar {
background-color: #f7f7f9!important;
padding: 0;
......@@ -78,4 +87,8 @@ lobby[hidden], webview[hidden] {
margin: .2rem 0.4rem;
color: #a7a7a7;
font-size: 1.2rem;
}
#navbar {
z-index: 100;
}
\ No newline at end of file
/*:host {*/
/*display: none;*/
/*}*/
\ No newline at end of file
:host {
display: none;
}
\ No newline at end of file
......@@ -93,98 +93,6 @@ label {
font-size: 15px;
}
h2 {
font-size: 20px;
}
dt, dd {
font-size: 14px;
}
.panel {
border: 1px solid #eceeef;
border-radius: 6px;
background: rgba(255,255,255,.7);
padding: .8rem;
margin-bottom: 1rem;
}
table {
margin-bottom: 0;
}
table th, table td {
border-top: none;
font-size: 14px;
font-weight: normal;
}
/*.table-curved {*/
/*border-collapse: separate;*/
/*border: solid #ccc 1px;*/
/*border-radius: 6px;*/
/*border-left: 0px;*/
/*border-top: 0px;*/
/*}*/
/*.table-curved > thead:first-child > tr:first-child > th {*/
/*border-bottom: 0px;*/
/*border-top: solid #ccc 1px;*/
/*}*/
/*.table-curved td, .table-curved th {*/
/*border-left: 1px solid #ccc;*/
/*border-top: 1px solid #ccc;*/
/*}*/
/*.table-curved > :first-child > :first-child > :first-child {*/
/*border-radius: 6px 0 0 0;*/
/*}*/
/*.table-curved > :first-child > :first-child > :last-child {*/
/*border-radius: 0 6px 0 0;*/
/*}*/
/*.table-curved > :last-child > :last-child > :first-child {*/
/*border-radius: 0 0 0 6px;*/
/*}*/
/*.table-curved > :last-child > :last-child > :last-child {*/
/*border-radius: 0 0 6px 0;*/
/*}*/
#icon {
width: 128px;
height: 128px;
box-shadow: 0 0 4px #ccc;
}
#main {
display: flex;
flex-direction: row;
}
.panel {
border: 1px solid #eceeef;
border-radius: 6px;
background: rgba(255,255,255,.7);
padding: .8rem;
margin-bottom: 1rem;
position: relative;
}
#right {
margin-left: 1rem;
}
h1 {
font-size: 28px;
margin-bottom: 0;
}
#time {
font-size: 14px;
margin-bottom: .6rem;
}
#action {
margin-bottom: .5rem;
}
form {
margin-bottom: 0;
......@@ -195,22 +103,6 @@ form {
border-color: #008dbb;
}
th {
width: 25%;
}
.moreinfo {
color: #00a4d9;
display: block;
position: absolute;
top: 12px;
right: 18px;
font-size: 14px;
}
#arena {
position: relative;
}
select {
margin-right: 0 !important;
#action {
margin-bottom: .5rem;
}
\ No newline at end of file
This diff is collapsed.
/**
* Created by zh99998 on 16/9/2.
*/
import {Component, OnInit, ChangeDetectorRef, Input} from '@angular/core';
import {Component, OnInit, ChangeDetectorRef, Input, EventEmitter, Output} from '@angular/core';
import * as fs from 'fs';
import * as path from 'path';
import * as child_process from 'child_process';
......@@ -71,7 +71,7 @@ interface Options {
lflist?: number;
time_limit?: number;
}
interface Points {
export interface Points {
exp: number;
exp_rank: number;
pt: number;
......@@ -102,12 +102,15 @@ export class YGOProComponent implements OnInit {
app: App;
@Input()
currentApp: App;
@Output()
points: EventEmitter<Points> = new EventEmitter();
decks: string[] = [];
current_deck: string;
system_conf: string;
numfont: string[];
textfont: string[];
points: Points;
// points: Points;
windbot: string[]; // ["琪露诺", "谜之剑士LV4", "复制植物", "尼亚"];
......@@ -136,8 +139,8 @@ export class YGOProComponent implements OnInit {
matching: ISubscription | undefined;
matching_arena: string | undefined;
constructor (private http: Http, private appsService: AppsService, private loginService: LoginService,
private settingsService: SettingsService, private ref: ChangeDetectorRef) {
constructor(private http: Http, private appsService: AppsService, private loginService: LoginService,
private settingsService: SettingsService, private ref: ChangeDetectorRef) {
switch (process.platform) {
case 'darwin':
this.numfont = ['/System/Library/Fonts/SFNSTextCondensed-Bold.otf'];
......@@ -174,7 +177,7 @@ export class YGOProComponent implements OnInit {
}
async ngOnInit () {
async ngOnInit() {
let locale: string;
if (this.settingsService.getLocale().startsWith('zh')) {
......@@ -232,7 +235,7 @@ export class YGOProComponent implements OnInit {
});
}
async refresh () {
async refresh() {
let decks = await this.get_decks();
this.decks = decks;
let system_conf = await this.load_system_conf();
......@@ -246,15 +249,16 @@ export class YGOProComponent implements OnInit {
let params = new URLSearchParams();
params.set('username', this.loginService.user.username);
try {
this.points = await this.http.get('https://mycard.moe/ygopro/api/user', {search: params})
let points = await this.http.get('https://mycard.moe/ygopro/api/user', {search: params})
.map((response) => response.json())
.toPromise();
this.points.emit(points);
} catch (error) {
console.log(error);
}
};
get_decks (): Promise<string[]> {
get_decks(): Promise<string[]> {
return new Promise((resolve, reject) => {
fs.readdir(path.join(this.app.local!.path, 'deck'), (error, files) => {
if (error) {
......@@ -266,7 +270,7 @@ export class YGOProComponent implements OnInit {
});
}
async get_font (files: string[]): Promise<string | undefined> {
async get_font(files: string[]): Promise<string | undefined> {
for (let file of files) {
let found = await new Promise((resolve) => fs.access(file, fs.constants.R_OK, error => resolve(!error)));
if (found) {
......@@ -275,14 +279,14 @@ export class YGOProComponent implements OnInit {
}
}
async delete_deck (deck: string) {
async delete_deck(deck: string) {
if (confirm('确认删除?')) {
await new Promise(resolve => fs.unlink(path.join(this.app.local!.path, 'deck', deck + '.ydk'), resolve));
return this.refresh();
}
}
async fix_fonts (data: SystemConf) {
async fix_fonts(data: SystemConf) {
if (!await this.get_font([data.numfont])) {
let font = await this.get_font(this.numfont);
if (font) {
......@@ -298,7 +302,7 @@ export class YGOProComponent implements OnInit {
}
};
load_system_conf (): Promise<SystemConf> {
load_system_conf(): Promise<SystemConf> {
return new Promise((resolve, reject) => {
fs.readFile(this.system_conf, {encoding: 'utf-8'}, (error, data) => {
if (error) {
......@@ -309,7 +313,7 @@ export class YGOProComponent implements OnInit {
});
};
save_system_conf (data: SystemConf) {
save_system_conf(data: SystemConf) {
return new Promise((resolve, reject) => {
fs.writeFile(this.system_conf, ini.unsafe(ini.stringify(data, <EncodeOptions>{whitespace: true})), (error) => {
if (error) {
......@@ -320,7 +324,7 @@ export class YGOProComponent implements OnInit {
});
};
async join (name: string, server: Server) {
async join(name: string, server: Server) {
let system_conf = await this.load_system_conf();
await this.fix_fonts(system_conf);
system_conf.lastdeck = this.current_deck;
......@@ -333,7 +337,7 @@ export class YGOProComponent implements OnInit {
return this.start_game(['-j']);
};
async edit_deck (deck: string) {
async edit_deck(deck: string) {
let system_conf = await this.load_system_conf();
await this.fix_fonts(system_conf);
system_conf.lastdeck = deck;
......@@ -341,11 +345,11 @@ export class YGOProComponent implements OnInit {
return this.start_game(['-d']);
}
join_windbot (name: string) {
join_windbot(name: string) {
return this.join('AI#' + name, this.servers[0]);
}
async start_game (args: string[]) {
async start_game(args: string[]) {
let win = remote.getCurrentWindow();
win.minimize();
return new Promise((resolve, reject) => {
......@@ -357,7 +361,7 @@ export class YGOProComponent implements OnInit {
reject(error);
win.restore();
});
child.on('exit', async (code, signal) => {
child.on('exit', async(code, signal) => {
// error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。
await this.refresh();
resolve();
......@@ -366,7 +370,7 @@ export class YGOProComponent implements OnInit {
});
};
create_room (room: Room) {
create_room(room: Room) {
let options_buffer = new Buffer(6);
// 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit
options_buffer.writeUInt8((room.private ? 2 : 1) << 4, 1);
......@@ -397,7 +401,7 @@ export class YGOProComponent implements OnInit {
this.join(password, this.servers[0]);
}
join_room (room: Room) {
join_room(room: Room) {
let options_buffer = new Buffer(6);
options_buffer.writeUInt8(3 << 4, 1);
let checksum = 0;
......@@ -417,7 +421,7 @@ export class YGOProComponent implements OnInit {
this.join(password, room.server!);
}
request_match (arena = 'entertain') {
request_match(arena = 'entertain') {
let headers = new Headers();
headers.append('Authorization',
'Basic ' + Buffer.from(this.loginService.user.username + ':' + this.loginService.user.external_id).toString('base64'));
......@@ -443,7 +447,7 @@ export class YGOProComponent implements OnInit {
});
}
cancel_match () {
cancel_match() {
this.matching!.unsubscribe();
this.matching = matching = undefined;
this.matching_arena = matching_arena = undefined;
......
......@@ -278,7 +278,7 @@
</trans-unit>
<trans-unit datatype="html" id="19923836b1ae79614782426a7a001d8ccfa27b5c">
<source>创建房间</source>
<target>Custom Game</target>
<target>Create Game</target>
</trans-unit>
<trans-unit datatype="html" id="c54a3c40a2766446dd03b0af75f64055aa404855">
......
{
"name": "mycard",
"version": "3.0.16",
"version": "3.0.17",
"description": "mycard",
"keywords": [],
"author": "zh99998 <zh99998@gmail.com>",
......@@ -36,7 +36,6 @@
"candy-shop": "zh99998/candy-plugins#patch-5",
"core-js": "latest",
"electron-auto-updater": "latest",
"electron-cookies": "latest",
"electron-is-dev": "latest",
"electron-sudo": "mycard/electron-sudo#mycard",
"font-awesome": "latest",
......
html, body {
height: 100%;
overflow: hidden;
}
body {
font-family: -apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
-webkit-user-select: none;
background: transparent;
border-radius: 5px;
border: 1px solid #eee;
padding-right: 0 !important;
}
mycard {
......@@ -85,6 +92,6 @@ body.resizing /deep/ * {
-webkit-user-select: none;
}
body {
-webkit-user-select: none;
}
mycard {
background-color: white;
}
\ No newline at end of file
......@@ -73,7 +73,6 @@ System.config({
"mkdirp": "@node/mkdirp",
"aria2": "@node/aria2",
"electron-sudo": "@node/electron-sudo",
"electron-cookies": "@node/electron-cookies",
'jquery': 'npm:jquery/dist/jquery.min.js',
'tether': 'npm:tether/dist/js/tether.min.js',
......
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