Commit f7135db6 authored by mercury233's avatar mercury233

add timeout for loading apps.json

parent 0c6ffd91
...@@ -84,7 +84,9 @@ export class AppsService { ...@@ -84,7 +84,9 @@ export class AppsService {
let appsURL = 'https://api.mycard.moe/apps.json'; let appsURL = 'https://api.mycard.moe/apps.json';
let keysURL = 'https://api.mycard.moe/keys'; let keysURL = 'https://api.mycard.moe/keys';
try { try {
let data = await this.http.get(appsURL).map((response) => response.json()).toPromise(); let data = await this.http.get(appsURL)
.timeout(5000)
.map((response) => response.json()).toPromise();
let keys_data = await this.http.get(keysURL, { let keys_data = await this.http.get(keysURL, {
search: { search: {
user_id: this.loginService.user.email user_id: this.loginService.user.email
...@@ -102,6 +104,7 @@ export class AppsService { ...@@ -102,6 +104,7 @@ export class AppsService {
console.error(e); console.error(e);
let data = localStorage.getItem('apps_json'); let data = localStorage.getItem('apps_json');
if (data) { if (data) {
new Notification('MyCard', {body: '读取最新游戏列表失败...'});
this.apps = this.loadAppsList(JSON.parse(data!)); this.apps = this.loadAppsList(JSON.parse(data!));
} else { } else {
alert('读取游戏列表失败,可能是网络不通'); alert('读取游戏列表失败,可能是网络不通');
......
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