mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-25 08:24:06 +01:00
This commit is contained in:
parent
875f00398e
commit
99725ea21d
14 changed files with 122 additions and 40 deletions
|
|
@ -28,8 +28,23 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
|
|||
init.headers = headers;
|
||||
}
|
||||
fetch(url, init).then((response) => {
|
||||
return response.json();
|
||||
if (response.status === 404) {
|
||||
cb({
|
||||
data: null,
|
||||
msg: response.statusText,
|
||||
code: response.status,
|
||||
});
|
||||
} else {
|
||||
if (response.headers.get("content-type").indexOf("application/json") > -1) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.text();
|
||||
}
|
||||
}
|
||||
}).then((response: IWebSocketData) => {
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
if (["/api/search/searchRefBlock", "/api/graph/getGraph", "/api/graph/getLocalGraph"].includes(url)) {
|
||||
if (response.data.reqId && window.siyuan.reqIds[url] && window.siyuan.reqIds[url] > response.data.reqId) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue