An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Add encrypted export risk confirmation dialog #18034
Daniele2bbb6011dcd
diff --git a/app/src/protyle/export/exportMd.ts b/app/src/protyle/export/exportMd.tsindex 42a7d54284..d5813413ca 100644--- a/app/src/protyle/export/exportMd.ts+++ b/app/src/protyle/export/exportMd.ts@@ -1,8 +1,10 @@import {Constants} from "../../constants";import {Dialog} from "../../dialog";+import {confirmDialog} from "../../dialog/confirmDialog";import {showMessage} from "../../dialog/message";import {fetchPost, fetchSyncPost} from "../../util/fetch";import {isMobile} from "../../util/functions";+import {isEncryptedBox} from "../../util/pathName";import {saveExportFile} from "../util/compatibility";// 导出参数对话框 https://github.com/siyuan-note/siyuan/issues/17031@@ -142,14 +144,18 @@ interface IExportMdOptionsPayload {export const exportMarkdownZip = async(options: IExportMdOptions) => {let showSubDocs = true;let showRelatedDocs = true;+ let encrypted = false;if (options.id) {// 查询文档是否有子文档、引用及绑定的数据库,无则隐藏对应配置项 #17031const docInfo = await fetchSyncPost("/api/block/getDocInfo", {id: options.id});const data = docInfo.data;showSubDocs = 0 < data.subFileCount;showRelatedDocs = 0 < (data.refCount || 0) || 0 < (data.attrViews?.length || 0);+ const blockInfo = await fetchSyncPost("/api/block/getBlockInfo", {id: options.id});+ encrypted = blockInfo.code === 0 && isEncryptedBox(blockInfo.data.box);}openExportOptionsDialog(params => {+ const exportMarkdown = () => {const msgId = showMessage(window.siyuan.languages.exporting, -1);const cb = (response: IWebSocketData) => saveExportFile(response.data.zip, msgId);if (options.id) {@@ -159,5 +165,11 @@ export const exportMarkdownZip = async(options: IExportMdOptions) => {} else {fetchPost("/api/export/exportNotebookMd", {notebook: options.notebook, ...params}, cb);}+ };+ if (encrypted) {+ confirmDialog(window.siyuan.languages.export, window.siyuan.languages.encryptedExportRiskTip, exportMarkdown);+ return;+ }+ exportMarkdown();}, showSubDocs, showRelatedDocs);};diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.tsindex 3b2dd70634..a687941bc2 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -34,6 +34,7 @@ const getIconScript = (servePath: string) => {export const saveExport = (option: IExportOptions) => {/// #if BROWSERif (["html", "htmlmd"].includes(option.type)) {+ const startExport = () => {const msgId = showMessage(window.siyuan.languages.exporting, -1);// 浏览器环境:先调用 API 生成资源文件,再在前端生成完整的 HTMLconst url = option.type === "htmlmd" ? "/api/export/exportMdHTML" : "/api/export/exportHTML";@@ -59,6 +60,14 @@ export const saveExport = (option: IExportOptions) => {saveExportFile(zipResponse.data.zip, msgId);});});+ };+ fetchPost("/api/block/getBlockInfo", {id: option.id}, (response) => {+ if (response.code === 0 && isEncryptedBox(response.data.box)) {+ confirmDialog(window.siyuan.languages.export, window.siyuan.languages.encryptedExportRiskTip, startExport);+ return;+ }+ startExport();+ });return;}/// #else