diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts index b0ac6ab2f..0e6b122ac 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 48169c9db..8feeec74d 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()} @@ -673,7 +684,7 @@ const onExport = async (data: IWebSocketData, filePath: string, exportOption: IE