Commit 0d7ce086 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent 197ab652
This diff is collapsed.
......@@ -20,8 +20,8 @@ import { AppsJson } from './shared/apps-json-type';
import os from 'os';
import Timer = NodeJS.Timer;
import { HttpClient } from '@angular/common/http';
import { map, timeout } from 'rxjs/operators';
import { Observable, Observer } from 'rxjs';
import {lastValueFrom, map, Observable, Observer, timeout} from 'rxjs';
const Logger = {
info: (...message: any[]) => {
......@@ -103,12 +103,12 @@ export class AppsService {
let appsURL = 'https://sapi.moecube.com:444/release/update/apps.json';
let keysURL = 'https://sapi.moecube.com:444/keys';
try {
let data = await this.http.get<AppsJson.App[]>(appsURL).pipe(timeout(5000)).toPromise();
let keys_data = await this.http.get<any[]>(keysURL, {
let data = await lastValueFrom(this.http.get<AppsJson.App[]>(appsURL).pipe(timeout(5000)));
let keys_data = await lastValueFrom(this.http.get<any[]>(keysURL, {
params: {
user_id: this.loginService.user.email
}
}).toPromise();
}));
for (let item of keys_data) {
let app = data.find((app: any) => app.id === item.app_id);
if (app) {
......@@ -658,7 +658,7 @@ export class AppsService {
locale = 'en-US';
}
let updateUrl = App.updateUrl(app, process.platform, locale, os.arch());
let metalink = await this.http.post(updateUrl, changedFiles, {responseType: 'text'}).toPromise();
let metalink = await lastValueFrom(this.http.post(updateUrl, changedFiles, {responseType: 'text'}));
let downloadDir = path.join(path.dirname(app.local!.path), 'downloading');
let downloadId = await this.downloadService.addMetalink(metalink, downloadDir);
await this.downloadService.progress(downloadId, (status: DownloadStatus) => {
......@@ -717,7 +717,7 @@ export class AppsService {
}
let metalinkUrl = App.downloadUrl(_app, process.platform, locale, os.arch());
_app.status.status = 'downloading';
let metalink = await this.http.get(metalinkUrl,{responseType: 'text'}).toPromise();
let metalink = await lastValueFrom(this.http.get(metalinkUrl,{responseType: 'text'}));
let downloadId = await this.downloadService.addMetalink(metalink, dir);
try {
await this.downloadService.progress(downloadId, (status: DownloadStatus) => {
......@@ -1124,7 +1124,7 @@ export class AppsService {
}
let checksumUrl = App.checksumUrl(app, process.platform, locale, os.arch());
return this.http.get(checksumUrl,{responseType: 'text'}).pipe(map((response) => {
return lastValueFrom(this.http.get(checksumUrl,{responseType: 'text'}).pipe(map((response) => {
let map = new Map<string, string>();
for (let line of response.split('\n')) {
if (line !== '') {
......@@ -1135,7 +1135,7 @@ export class AppsService {
}
}
return map;
})).toPromise();
})));
}
......
......@@ -16,7 +16,7 @@ import fg from 'fast-glob';
import { HttpClient } from '@angular/common/http';
import WillNavigateEvent = Electron.WillNavigateEvent;
import Timer = NodeJS.Timer;
import { Subscription } from 'rxjs';
import {lastValueFrom, Subscription} from 'rxjs';
interface SystemConf {
use_d3d: string;
......@@ -462,12 +462,11 @@ export class YGOProComponent implements OnInit, OnDestroy {
// https://mycard.moe/ygopro/api/user?username=ozxdno
try {
let points = await this.http.get<any>('https://mycard.moe/ygopro/api/user', {
let points = await lastValueFrom(this.http.get<any>('https://mycard.moe/ygopro/api/user', {
params: {
username: this.loginService.user.username
}
})
.toPromise();
}));
this.points.emit(points);
} catch (error) {
console.log(error);
......@@ -611,15 +610,14 @@ export class YGOProComponent implements OnInit, OnDestroy {
win.restore();
});
try {
this.http.get<any>('https://mycard.moe/ygopro/api/history', {
lastValueFrom(this.http.get<any>('https://mycard.moe/ygopro/api/history', {
params: {
page: 1,
username: this.loginService.user.username,
type: 0,
page_num: 1
}
})
.toPromise()
}))
.then((d) => {
start_time = d.data[0].start_time;
});
......@@ -627,8 +625,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
console.log(error);
}
try {
this.http.get<any>('https://sapi.moecube.com:444/ygopro/arena/user', { params: { username: this.loginService.user.username } })
.toPromise()
lastValueFrom(this.http.get<any>('https://sapi.moecube.com:444/ygopro/arena/user', { params: { username: this.loginService.user.username } }))
.then((d2) => {
exp_rank_ex = d2.exp_rank;
arena_rank_ex = d2.arena_rank;
......@@ -638,7 +635,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
}
});
try {
await this.http.get<any>('https://mycard.moe/ygopro/api/history', {
await lastValueFrom(this.http.get<any>('https://mycard.moe/ygopro/api/history', {
params: {
page: 1,
username: this.loginService.user.username,
......@@ -646,19 +643,17 @@ export class YGOProComponent implements OnInit, OnDestroy {
type: 0,
page_num: 1
}
})
.toPromise()
}))
.then((d) => {
data = d.data[0];
data.myname = this.loginService.user.username;
});
await this.http.get<any>('https://sapi.moecube.com:444/ygopro/arena/user', {
await lastValueFrom(this.http.get<any>('https://sapi.moecube.com:444/ygopro/arena/user', {
params: {
username: this.loginService.user.username
}
})
.toPromise()
}))
.then((data2) => {
data.athletic_win = data2.athletic_win;
data.athletic_lose = data2.athletic_lose;
......
......@@ -2,7 +2,10 @@ const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
target: 'electron-renderer',
externals: Object.fromEntries(['bufferutil', 'utf-8-validate'].map((pkg) => [pkg, `commonjs2 ${pkg}`])),
externals: {
bufferutil: 'commonjs2 bufferutil',
'utf-8-validate': 'commonjs2 utf-8-validate',
},
plugins: [
new CopyPlugin({
patterns: [{ from: 'node_modules/candy/res', to: 'candy/res' }],
......
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