Vanessa 2025-10-19 18:05:35 +08:00
parent a115273ccf
commit c8b9eb9b6b
2 changed files with 8 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import {confirmDialog} from "../dialog/confirmDialog";
import {getSearch, isMobile, isValidAttrName} from "../util/functions"; import {getSearch, isMobile, isValidAttrName} from "../util/functions";
import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName"; import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName";
import {MenuItem} from "./Menu"; import {MenuItem} from "./Menu";
import {saveExport} from "../protyle/export"; import {onExport, saveExport} from "../protyle/export";
import {isInAndroid, isInHarmony, openByMobile, writeText} from "../protyle/util/compatibility"; import {isInAndroid, isInHarmony, openByMobile, writeText} from "../protyle/util/compatibility";
import {fetchPost, fetchSyncPost} from "../util/fetch"; import {fetchPost, fetchSyncPost} from "../util/fetch";
import {hideMessage, showMessage} from "../dialog/message"; import {hideMessage, showMessage} from "../dialog/message";
@ -765,8 +765,9 @@ export const exportMd = (id: string) => {
id, id,
keepFold: localData.keepFold, keepFold: localData.keepFold,
merge: localData.mergeSubdocs, merge: localData.mergeSubdocs,
}, response => { }, async response => {
window.JSAndroid.exportPDF(response.data.content); const html = await onExport(response, undefined, {type: "pdf", id});
window.JSAndroid.exportPDF(html);
}); });
} }
}, },

View file

@ -635,7 +635,7 @@ const getExportPath = (option: IExportOptions, removeAssets?: boolean, mergeSubd
}); });
}; };
const onExport = async (data: IWebSocketData, filePath: string, exportOption: IExportOptions, removeAssets?: boolean, msgId?: string) => { export const onExport = async (data: IWebSocketData, filePath: string, exportOption: IExportOptions, removeAssets?: boolean, msgId?: string) => {
let themeName = window.siyuan.config.appearance.themeLight; let themeName = window.siyuan.config.appearance.themeLight;
let mode = 0; let mode = 0;
if (["html", "htmlmd"].includes(exportOption.type) && window.siyuan.config.appearance.mode === 1) { if (["html", "htmlmd"].includes(exportOption.type) && window.siyuan.config.appearance.mode === 1) {
@ -711,6 +711,9 @@ id="preview">${data.data.content}</div>
}) })
}); });
</script></body></html>`; </script></body></html>`;
if (typeof filePath === "undefined") {
return html;
}
const htmlPath = path.join(filePath, "index.html"); const htmlPath = path.join(filePath, "index.html");
fs.writeFileSync(htmlPath, html); fs.writeFileSync(htmlPath, html);
afterExport(htmlPath, msgId); afterExport(htmlPath, msgId);