An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/8273
Vanessa110eab8a1a12
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.tsindex 7f678b6bc1..8e242b9cfd 100644--- a/app/src/plugin/index.ts+++ b/app/src/plugin/index.ts@@ -12,7 +12,7 @@ import {hasClosestByAttribute} from "../protyle/util/hasClosest";export class Plugin {public i18n: IObject;public eventBus: EventBus;- public data: any;+ public data: any = {};public name: string;public topBarIcons: Element[] = [];public models: {@@ -75,17 +75,12 @@ export class Plugin {}public loadData(storageName: string) {- if (!this.data) {- this.data = {};- }if (typeof this.data[storageName] === "undefined") {this.data[storageName] = "";}return new Promise((resolve) => {fetchPost("/api/file/getFile", {path: `/data/storage/petal/${this.name}/${storageName}`}, (response) => {- if (response.code === 404) {- this.data[storageName] = "";- } else {+ if (response.code !== 404) {this.data[storageName] = response;}resolve(this.data[storageName]);@@ -95,11 +90,15 @@ export class Plugin {public saveData(storageName: string, data: any) {return new Promise((resolve) => {- if (!this.data) {- this.data = {};- }const pathString = `/data/storage/petal/${this.name}/${storageName}`;- const file = new File([new Blob([data])], pathString.split("/").pop());+ let file: File;+ if (typeof data === "object") {+ file = new File([new Blob([JSON.stringify(data)], {+ type: "application/json"+ })], pathString.split("/").pop());+ } else {+ file = new File([new Blob([data])], pathString.split("/").pop());+ }const formData = new FormData();formData.append("path", pathString);formData.append("file", file);diff --git a/app/src/util/fetch.ts b/app/src/util/fetch.tsindex 83194ffc89..22f43e0fcc 100644--- a/app/src/util/fetch.ts+++ b/app/src/util/fetch.ts@@ -48,15 +48,16 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat}return;}- if (typeof response.msg === "undefined") {- 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;}}- if (processMessage(response) && cb) {+ if (typeof response === "object" && typeof response.msg === "string" && typeof response.code === "number") {+ if (processMessage(response) && cb) {+ cb(response);+ }+ } else if (cb) {cb(response);}}).catch((e) => {