diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts index da248e561..564b5597b 100644 --- a/app/src/plugin/index.ts +++ b/app/src/plugin/index.ts @@ -258,7 +258,7 @@ export class Plugin { this.setting.open(this.displayName || this.name); } - public loadData(storageName: string) { + public loadData(storageName: string): Promise { if (typeof this.data[storageName] === "undefined") { this.data[storageName] = ""; } @@ -274,7 +274,7 @@ export class Plugin { }); } - public saveData(storageName: string, data: any) { + public saveData(storageName: string, data: any): Promise { if (window.siyuan.config.readonly || window.siyuan.isPublish) { return Promise.reject({ code: 403, @@ -312,7 +312,7 @@ export class Plugin { }); } - public removeData(storageName: string) { + public removeData(storageName: string): Promise { if (window.siyuan.config.readonly || window.siyuan.isPublish) { return Promise.reject({ code: 403, diff --git a/app/src/util/fetch.ts b/app/src/util/fetch.ts index ece58ee61..caf6f1a21 100644 --- a/app/src/util/fetch.ts +++ b/app/src/util/fetch.ts @@ -93,6 +93,14 @@ export const fetchPost = ( cb(response); } }).catch((e) => { + if (failCallback && url === "/api/file/getFile") { + failCallback({ + data: null, + msg: e.message, + code: 400, + }); + return; + } console.warn("fetch post failed [" + e + "], url [" + url + "]"); if (url === "/api/transactions" && (e.message === "Failed to fetch" || e.message === "Unexpected end of JSON input")) { kernelError();