An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: msg upload
Vanessafbaf8edea974
diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.tsindex 6dffba356a..8f26990349 100644--- a/app/src/protyle/upload/index.ts+++ b/app/src/protyle/upload/index.ts@@ -1,5 +1,5 @@import {insertHTML} from "../util/insertHTML";-import {showMessage} from "../../dialog/message";+import {hideMessage, showMessage} from "../../dialog/message";import {Constants} from "../../constants";import {destroy} from "../util/destroy";import {fetchPost} from "../../util/fetch";@@ -65,12 +65,12 @@ const validateFile = (protyle: IProtyle, files: File[]) => {uploadingStr += `<li>${filename} ${window.siyuan.languages.uploading}</li>`;}}-+ let msgIdif (errorTip !== "" || uploadingStr !== "") {- showMessage(`<ul>${errorTip}${uploadingStr}</ul>`);+ msgId = showMessage(`<ul>${errorTip}${uploadingStr}</ul>`);}- return uploadFileList;+ return {files: uploadFileList, msgId};};const genUploadedLabel = (responseText: string, protyle: IProtyle) => {@@ -96,7 +96,7 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {}let succFileText = "";- const keys = Object.keys(response.data.succMap);+ const keys = Object.keys(response.data.succMap);keys.forEach((key, index) => {const path = response.data.succMap[key];const lastIndex = key.lastIndexOf(".");@@ -130,11 +130,12 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {};export const uploadLocalFiles = (files: string[], protyle: IProtyle) => {- showMessage(window.siyuan.languages.uploading, 0);+ const id = showMessage(window.siyuan.languages.uploading, 0);fetchPost("/api/asset/insertLocalAssets", {assetPaths: files,id: protyle.block.rootID}, (response) => {+ hideMessage(id)genUploadedLabel(JSON.stringify(response), protyle);});};@@ -186,7 +187,7 @@ export const uploadFiles = (protyle: IProtyle, files: FileList | DataTransferIteconst editorElement = protyle.wysiwyg.element;const validateResult = validateFile(protyle, fileList);- if (validateResult.length === 0) {+ if (validateResult.files.length === 0) {if (element) {element.value = "";}@@ -200,8 +201,8 @@ export const uploadFiles = (protyle: IProtyle, files: FileList | DataTransferIteformData.append(key, extraData[key]);}- for (let i = 0, iMax = validateResult.length; i < iMax; i++) {- formData.append(protyle.options.upload.fieldName, validateResult[i]);+ for (let i = 0, iMax = validateResult.files.length; i < iMax; i++) {+ formData.append(protyle.options.upload.fieldName, validateResult.files[i]);}formData.append("id", protyle.block.rootID);const xhr = new XMLHttpRequest();@@ -223,6 +224,7 @@ export const uploadFiles = (protyle: IProtyle, files: FileList | DataTransferItereturn;}if (xhr.status === 200) {+ hideMessage(validateResult.msgId);if (protyle.options.upload.success) {protyle.options.upload.success(editorElement, xhr.responseText);} else if (successCB) {