♻️ 当 code 大于 0 时同样需要进行相关的业务处理 https://github.com/siyuan-note/siyuan/pull/11367

This commit is contained in:
Vanessa 2024-06-12 23:11:31 +08:00
parent c07a1a69db
commit 19dd387064
4 changed files with 9 additions and 14 deletions

View file

@ -310,12 +310,10 @@ export const editor = {
if (fontFamilyElement.tagName === "SELECT") { if (fontFamilyElement.tagName === "SELECT") {
let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`; let fontFamilyHTML = `<option value="">${window.siyuan.languages.default}</option>`;
fetchPost("/api/system/getSysFonts", {}, (response) => { fetchPost("/api/system/getSysFonts", {}, (response) => {
if (response.code === 0) {
response.data.forEach((item: string) => { response.data.forEach((item: string) => {
fontFamilyHTML += `<option value="${item}"${window.siyuan.config.editor.fontFamily === item ? " selected" : ""}>${item}</option>`; fontFamilyHTML += `<option value="${item}"${window.siyuan.config.editor.fontFamily === item ? " selected" : ""}>${item}</option>`;
}); });
fontFamilyElement.innerHTML = fontFamilyHTML; fontFamilyElement.innerHTML = fontFamilyHTML;
}
}); });
} }
editor.element.querySelector("#clearHistory").addEventListener("click", () => { editor.element.querySelector("#clearHistory").addEventListener("click", () => {

View file

@ -507,9 +507,8 @@ export const exportMd = (id: string) => {
}); });
}); });
return; return;
} else if (response.code === 0) {
showMessage(window.siyuan.languages.exportTplSucc);
} }
showMessage(window.siyuan.languages.exportTplSucc);
}); });
dialog.destroy(); dialog.destroy();
}); });

View file

@ -150,10 +150,8 @@ export const initAssets = () => {
return; return;
} }
} }
if (response.code === 0) {
window.siyuan.config.appearance = response.data.appearance; window.siyuan.config.appearance = response.data.appearance;
loadAssets(response.data.appearance); loadAssets(response.data.appearance);
}
}); });
}); });
}; };

View file

@ -38,7 +38,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
return { return {
data: null, data: null,
msg: response.statusText, msg: response.statusText,
code: response.status, code: -response.status,
}; };
default: default:
if (response.headers.get("content-type")?.indexOf("application/json") > -1) { if (response.headers.get("content-type")?.indexOf("application/json") > -1) {