这个提交包含在:
徐勤民 2024-10-18 20:30:27 +08:00
父节点 87ef142944
当前提交 2081e3d6fa

查看文件

@ -73,7 +73,8 @@ export class HttpHelper {
return new Promise<T>((resolve, reject) => { return new Promise<T>((resolve, reject) => {
if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 && this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 &&
this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.get(apiNo ?? params.url).destroy() this.httpHandlerList.get(apiNo ?? params.url).destroy()
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -104,7 +105,7 @@ export class HttpHelper {
extraData: params.data extraData: params.data
}) })
.then((data: http.HttpResponse) => { .then((data: http.HttpResponse) => {
console.info('=====>' + 'Result:' + data.result as string); console.info(`=====>Result:${data.result as string}(${apiNo})`);
// console.info('=====>' + 'code:' + data.responseCode); // console.info('=====>' + 'code:' + data.responseCode);
// console.info('=====>' + 'type:' + JSON.stringify(data.resultType)); // console.info('=====>' + 'type:' + JSON.stringify(data.resultType));
// console.info('=====>' + 'header:' + JSON.stringify(data.header)); // console.info('=====>' + 'header:' + JSON.stringify(data.header));
@ -126,6 +127,7 @@ export class HttpHelper {
reject(err) reject(err)
} }
}).catch((err: Error) => { }).catch((err: Error) => {
console.info('=====>' + 'Error:' + JSON.stringify({ err: err, url: params.url, }));
if (this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -133,8 +135,9 @@ export class HttpHelper {
} }
if (err.message === 'Failed writing received data to disk/application') { if (err.message === 'Failed writing received data to disk/application') {
reject('cancel') reject('cancel')
} else } else {
reject(err) reject(err)
}
}); });
}); });
@ -151,7 +154,8 @@ export class HttpHelper {
return new Promise<T>((resolve, reject) => { return new Promise<T>((resolve, reject) => {
if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 && this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 &&
this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.get(apiNo ?? params.url).destroy() this.httpHandlerList.get(apiNo ?? params.url).destroy()
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -184,7 +188,7 @@ export class HttpHelper {
extraData: encodeURI(data) extraData: encodeURI(data)
}) })
.then((data: http.HttpResponse) => { .then((data: http.HttpResponse) => {
console.info('=====>' + 'Result:' + data.result as string); console.info(`=====>Result:${data.result as string}(${apiNo})`);
// console.info('=====>' + 'code:' + data.responseCode); // console.info('=====>' + 'code:' + data.responseCode);
// console.info('=====>' + 'type:' + JSON.stringify(data.resultType)); // console.info('=====>' + 'type:' + JSON.stringify(data.resultType));
// console.info('=====>' + 'header:' + JSON.stringify(data.header)); // console.info('=====>' + 'header:' + JSON.stringify(data.header));
@ -206,6 +210,7 @@ export class HttpHelper {
reject(err) reject(err)
} }
}).catch((err: Error) => { }).catch((err: Error) => {
console.info('=====>' + 'Error:' + JSON.stringify({ err: err, url: params.url, }));
if (this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -213,8 +218,9 @@ export class HttpHelper {
} }
if (err.message === 'Failed writing received data to disk/application') { if (err.message === 'Failed writing received data to disk/application') {
reject('cancel') reject('cancel')
} else } else {
reject(err) reject(err)
}
}); });
}); });
@ -233,7 +239,8 @@ export class HttpHelper {
return new Promise<T>((resolve, reject) => { return new Promise<T>((resolve, reject) => {
if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 && this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.concurrentList.getIndexOf(apiNo ?? params.url) === -1 &&
this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.get(apiNo ?? params.url).destroy() this.httpHandlerList.get(apiNo ?? params.url).destroy()
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -261,7 +268,7 @@ export class HttpHelper {
// extraData: params.data // extraData: params.data
}) })
.then((data: http.HttpResponse) => { .then((data: http.HttpResponse) => {
// console.info('=====>' + 'Result:' + data.result as string); console.info(`=====>Result:${data.result as string}(${apiNo})`);
// console.info('=====>' + 'code:' + data.responseCode); // console.info('=====>' + 'code:' + data.responseCode);
// console.info('=====>' + 'type:' + JSON.stringify(data.resultType)); // console.info('=====>' + 'type:' + JSON.stringify(data.resultType));
// console.info('=====>' + 'header:' + JSON.stringify(data.header)); // console.info('=====>' + 'header:' + JSON.stringify(data.header));
@ -283,6 +290,7 @@ export class HttpHelper {
reject(err) reject(err)
} }
}).catch((err: Error) => { }).catch((err: Error) => {
console.info('=====>' + 'Error:' + JSON.stringify({ err: err, url: params.url, }));
if (this.httpHandlerList.hasKey(apiNo ?? params.url)) { if (this.httpHandlerList.hasKey(apiNo ?? params.url)) {
this.httpHandlerList.remove(apiNo ?? params.url) this.httpHandlerList.remove(apiNo ?? params.url)
LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList) LocalStorageHelper.storage.setOrCreate(LocalStorageKeys.HttpHandlerList, this.httpHandlerList)
@ -290,8 +298,9 @@ export class HttpHelper {
} }
if (err.message === 'Failed writing received data to disk/application') { if (err.message === 'Failed writing received data to disk/application') {
reject('cancel') reject('cancel')
} else } else {
reject(err) reject(err)
}
}); });
}); });