Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/14579

Vanessa7ded2d407733
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index b0ac6ab2f6..0e6b122ac9 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -41,7 +41,7 @@ export const loadPlugins = async (app: App, names?: string[]) => {
});
const pluginsStyle = document.getElementById("pluginsStyle");
if (pluginsStyle) {
- pluginsStyle.innerHTML = css;
+ pluginsStyle.insertAdjacentHTML("afterend", css);
} else {
document.head.insertAdjacentHTML("beforeend", css);
}
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 48169c9db6..8feeec74d8 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -8,12 +8,23 @@ import {afterExport} from "./util";
/// #endif
import {confirmDialog} from "../../dialog/confirmDialog";
import {getThemeMode, setInlineStyle} from "../../util/assets";
-import {fetchPost} from "../../util/fetch";
+import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {Dialog} from "../../dialog";
import {replaceLocalPath} from "../../editor/rename";
import {setStorageVal} from "../util/compatibility";
import {isPaidUser} from "../../util/needSubscribe";
import {getCloudURL} from "../../config/util/about";
+import {getFrontend} from "../../util/functions";
+
+const getPluginStyle = async () => {
+ const response = await fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()});
+ let css = '';
+ // 为加快启动速度,不进行 await
+ response.data.forEach((item: IPluginData) => {
+ css += item.css || "";
+ });
+ return css;
+};
export const saveExport = (option: IExportOptions) => {
/// #if !BROWSER
@@ -170,7 +181,7 @@ const renderPDF = async (id: string) => {
border-bottom: none;
}
${await setInlineStyle(false)}
- ${document.getElementById("pluginsStyle").innerHTML}
+ ${await getPluginStyle()}
${getSnippetCSS()}
</style>
</head>
@@ -673,7 +684,7 @@ const onExport = async (data: IWebSocketData, filePath: string, exportOption: IE
<style>
body {font-family: var(--b3-font-family);background-color: var(--b3-theme-background);color: var(--b3-theme-on-background)}
${await setInlineStyle(false)}
- ${document.getElementById("pluginsStyle").innerHTML}
+ ${await getPluginStyle()}
${getSnippetCSS()}
</style>
</head>