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

service worker,更新angularcli,clean

parent dc6d5b1f
......@@ -18,7 +18,7 @@
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"serviceWorker": false,
"serviceWorker": true,
"styles": [
"styles.css"
],
......@@ -37,13 +37,16 @@
},
"lint": [
{
"project": "src/tsconfig.app.json"
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json"
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json"
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
......
#!/bin/bash
sed -i '' 's/,this._isFinished=!0//' node_modules/web-animations-js/web-animations.min.js
sed -i '' "s/ class:/ 'class':/g" node_modules/@angular/material/@angular/material.js
sed -i '' "s/ extends:/ 'extends':/" node_modules/intl/lib/core.js
sed -i '' "s/\[value, name\]/\[name, value\]/" node_modules/url-polyfill/url-polyfill.js
{
"routing": {
"index": "/mobile2/index.html",
"routes": {
"/mobile2/": {
"match": "exact"
},
"/mobile2/?": {
"match": "prefix"
},
"/mobile2/ygopro/": {
"match": "prefix"
}
}
}
}
This diff is collapsed.
{
"name": "mycard-mobile",
"version": "1.0.7",
"version": "1.0.10",
"license": "UNLISENCED",
"scripts": {
"ng": "ng",
"start": "ng serve --base-href /mobile/index.html --deploy-url /mobile --locale zh-CN --output-path mobile --open",
"start": "ng serve --base-href /mobile/ --deploy-url /mobile --locale zh-CN --output-path mobile --open",
"start:wild": "npm run start -- --host 0.0.0.0 --public-host 192.168.1.131:4200",
"build": "ng build --base-href /mobile/index.html --locale zh-CN --aot --prod",
"build": "ng build --base-href /mobile/ --locale zh-CN --aot --build-optimizer --extract-css --sourcemaps --prod",
"postinstall": "./fuck.sh",
"build:dev": "ng build --base-href /mobile2/index.html --locale zh-CN --aot",
"build:dev": "ng build --base-href /mobile2/ --locale zh-CN --aot --build-optimizer --extract-css --sourcemaps",
"lint": "ng lint",
"publish": "npm run build && ./ossutil cp -rf dist oss://mycard/mobile",
"publish:dev": "npm run build:dev && ./ossutil cp -rf dist oss://mycard/mobile2"
......@@ -16,40 +16,32 @@
"dependencies": {
"@angular/animations": "^4.3.0",
"@angular/cdk": "^2.0.0-beta.8",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"classlist.js": "^1.1.20150312",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
"lodash": "^4.17.4",
"material-design-icons": "^3.0.1",
"ng2-dragula": "^1.5.0",
"raf": "^3.3.2",
"rxjs": "^5.1.0",
"rxjs-to-async-iterator": "^2.1.3",
"url-polyfill": "^1.0.6",
"web-animations-js": "^2.3.1",
"rxjs": "^5.4.2",
"webdav": "^1.0.0-rc1",
"zone.js": "^0.8.4",
"observable-to-async-iterator": "gist:4e65592f184dafc82125"
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.2.1",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@angular/cli": "1.3.0-rc.1",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@angular/service-worker": "^1.0.0-beta.16",
"@types/lodash": "^4.14.70",
"@types/node": "^8.0.13",
"codelyzer": "^3.1.2",
"codelyzer": "~3.1.1",
"tslint": "^5.5.0",
"typescript": "~2.3.3"
}
......
......@@ -24,7 +24,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: [AuthGuard, LoginService],
})
......
......@@ -35,13 +35,13 @@
<!--<a href="https://accounts.moecube.com/profiles" id="avatar" md-raised-button [style.background-image]="'url(' + login.user.avatar_url + ')'">{{login.user.username}}</a>-->
<!--</md-grid-tile>-->
<md-grid-tile>
<button md-raised-button color="primary" (click)="request_match('athletic')">
<button md-raised-button color="primary" (click)="ygopro.request_match('athletic')">
<md-icon fontSet="fa" fontIcon="fa-futbol-o"></md-icon>
<br>竞技匹配
</button>
</md-grid-tile>
<md-grid-tile>
<button md-raised-button color="primary" (click)="request_match('entertain')">
<button md-raised-button color="primary" (click)="ygopro.request_match('entertain')">
<md-icon>toys</md-icon>
<br>娱乐匹配
</button>
......
......@@ -51,10 +51,6 @@ export class LobbyComponent {
url.searchParams.set('key', key);
open(url.toString());
}
request_match(arena: string) {
this.dialog.open(MatchDialog, { data: arena, disableClose: true });
}
}
interface BuildConfig {
......
......@@ -6,6 +6,8 @@ import { Subscription } from 'rxjs/Subscription';
import { LoginService } from '../login.service';
import { YGOProService } from '../ygopro.service';
const second = 1000;
@Component({
selector: 'app-match',
templateUrl: './match.component.html',
......@@ -13,12 +15,12 @@ import { YGOProService } from '../ygopro.service';
})
export class MatchDialog implements OnInit, OnDestroy {
expect_wait = this.http.get('https://api.mycard.moe/ygopro/match/stats/' + this.arena).map(response => new Date(response.json() * 1000));
actual_wait = Observable.timer(0, 1000).map(timestamp => new Date(timestamp * 1000));
expect_wait = this.http.get('https://api.mycard.moe/ygopro/match/stats/' + this.arena).map(response => response.json() * second);
actual_wait = Observable.timer(0, second).map(timestamp => timestamp * second);
matching: Subscription;
constructor(@Inject(MD_DIALOG_DATA) public arena: string, private dialogRef: MdDialogRef<MatchDialog>, private http: Http, private login: LoginService, private ygopro: YGOProService) {
constructor(@Inject(MD_DIALOG_DATA) public arena: string, private dialogRef: MdDialogRef<MatchDialog>, private http: Http, private login: LoginService) {
}
ngOnInit() {
......@@ -26,8 +28,7 @@ export class MatchDialog implements OnInit, OnDestroy {
headers: new Headers({ Authorization: 'Basic ' + Buffer.from(this.login.user.username + ':' + this.login.user.external_id).toString('base64') }),
params: { arena: this.arena, locale: 'zh-CN' }
}).map(response => response.json()).subscribe((data) => {
this.ygopro.join(data['password'], { address: data['address'], port: data['port'] });
this.dialogRef.close();
this.dialogRef.close(data);
}, (error) => {
alert(`匹配失败`);
this.dialogRef.close();
......
......@@ -41,7 +41,6 @@ export class ResultDialog {
}
again() {
this.dialogRef.close();
this.dialog.open(MatchDialog, { data: this.last.type, disableClose: true });
this.dialogRef.close(true);
}
}
......@@ -5,6 +5,7 @@ import { MdDialog } from '@angular/material';
import { sortBy } from 'lodash';
import { Observable } from 'rxjs/Observable';
import { LoginService } from './login.service';
import { MatchDialog } from './match/match.component';
import { ResultDialog } from './result/result.dialog';
import { StorageService } from './storage.service';
......@@ -202,7 +203,17 @@ export class YGOProService {
if (load_points) {
this.load_points();
}
this.dialog.open(ResultDialog, { data: last });
const again = await this.dialog.open(ResultDialog, { data: last }).afterClosed();
if (again) {
this.request_match(last.type);
}
}
}
async request_match(arena: string) {
const data = await this.dialog.open(MatchDialog, { data: arena, disableClose: true });
if (data) {
this.join(data['password'], { address: data['address'], port: data['port'] });
}
}
......
......@@ -3,56 +3,16 @@
<head>
<meta charset="utf-8">
<title>MyCard Mobile</title>
<base href="/mobile/index.html">
<base href="/mobile/">
<meta name="theme-color" content="#673ab7">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
}
#loading {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#loading > img {
width: 300px;
}
#loading p {
position: relative;
left: 10px;
font-weight: 600;
font-size: 30px;
color: #4b99ea;
text-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
margin-top: 0;
margin-bottom: 1rem;
}
</style>
</head>
<body>
<app-root>
<div id="loading">
<img src="assets/CubbitLogo.png">
<p>LOADING <span>.</span> <span>.</span> <span>.</span></p>
<p>LOADING2 <span>.</span> <span>.</span> <span>.</span></p>
</div>
</app-root>
<script>
// window.onerror = function (msg, url, lineNo, columnNo, error) {
// alert(msg);
// return false;
// };
</script>
</body>
</html>
......@@ -4,6 +4,11 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
// migrate
if (location.host === 'r.my-card.in') {
location.replace('https://mycard.moe/mobile/');
}
if (environment.production) {
enableProdMode();
}
......
......@@ -38,17 +38,15 @@
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** Evergreen browsers require these. **/
// import 'core-js/es6/reflect';
// import 'core-js/es7/reflect';
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'core-js/shim';
/**
* Required to support Web Animations `@angular/animation`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
import 'raf/polyfill'
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
......@@ -64,13 +62,11 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
*/
/**
* Date, currency, decimal and percent pipes.
* Date, curm -rf node_modules/rrency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
import 'intl'; // Run `npm install --save intl`.
// import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
import 'intl/locale-data/jsonp/zh-Hans-CN';
import 'url-polyfill';
// import 'intl/locale-data/jsonp/en';
......@@ -3,6 +3,34 @@
@import '~material-design-icons/iconfont/material-icons.css';
@import '~font-awesome/css/font-awesome.min.css';
html, body {
height: 100%;
}
body {
margin: 0
margin: 0;
}
#loading {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#loading > img {
width: 300px;
height: 300px;
}
#loading p {
position: relative;
left: 10px;
font-weight: 600;
font-size: 30px;
color: #4b99ea;
text-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
margin-top: 0;
margin-bottom: 1rem;
}
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