Vanessa 2025-10-19 23:01:23 +08:00
parent 0a24337d7d
commit 6c5af077a3
2 changed files with 16 additions and 16 deletions

View file

@ -177,7 +177,7 @@ const renderPDF = async (id: string) => {
.b3-label:last-child {
border-bottom: none;
}
${await setInlineStyle(false)}
${await setInlineStyle(false, servePath)}
${await getPluginStyle()}
</style>
${getSnippetCSS()}
@ -644,28 +644,29 @@ export const onExport = async (data: IWebSocketData, filePath: string, exportOpt
mode = 1;
}
const isDefault = (window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark === "midnight") || (window.siyuan.config.appearance.mode === 0 && window.siyuan.config.appearance.themeLight === "daylight");
const servePath = window.location.protocol + "//" + window.location.host;
let themeStyle = "";
if (!isDefault) {
themeStyle = `<link rel="stylesheet" type="text/css" id="themeStyle" href="appearance/themes/${themeName}/theme.css?${Constants.SIYUAN_VERSION}"/>`;
themeStyle = `<link rel="stylesheet" type="text/css" id="themeStyle" href="${servePath}appearance/themes/${themeName}/theme.css?${Constants.SIYUAN_VERSION}"/>`;
}
const html = `<!DOCTYPE html>
<html lang="${window.siyuan.config.appearance.lang}" data-theme-mode="${getThemeMode()}" data-light-theme="${window.siyuan.config.appearance.themeLight}" data-dark-theme="${window.siyuan.config.appearance.themeDark}">
<head>
<base href="${window.location.protocol}//${window.location.host}">
<base href="${servePath}">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" type="text/css" id="baseStyle" href="stage/build/export/base.css?v=${Constants.SIYUAN_VERSION}"/>
<link rel="stylesheet" type="text/css" id="themeDefaultStyle" href="appearance/themes/${themeName}/theme.css?v=${Constants.SIYUAN_VERSION}"/>
<script src="stage/protyle/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}"></script>
<link rel="stylesheet" type="text/css" id="baseStyle" href="${servePath}/stage/build/export/base.css?v=${Constants.SIYUAN_VERSION}"/>
<link rel="stylesheet" type="text/css" id="themeDefaultStyle" href="${servePath}/appearance/themes/${themeName}/theme.css?v=${Constants.SIYUAN_VERSION}"/>
<script src="${servePath}/stage/protyle/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}"></script>
${themeStyle}
<title>${data.data.name}</title>
<!-- Exported by SiYuan v${Constants.SIYUAN_VERSION} -->
<style>
body {font-family: var(--b3-font-family);background-color: var(--b3-theme-background);color: var(--b3-theme-on-background)}
${await setInlineStyle(false)}
${await setInlineStyle(false, servePath)}
${await getPluginStyle()}
</style>
${getSnippetCSS()}
@ -673,9 +674,9 @@ export const onExport = async (data: IWebSocketData, filePath: string, exportOpt
<body>
<div class="${["htmlmd", "word"].includes(exportOption.type) ? "b3-typography" : "protyle-wysiwyg" + (window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : "")}"
style="max-width: 800px;margin: 0 auto;" id="preview">${data.data.content}</div>
<script src="appearance/icons/${window.siyuan.config.appearance.icon}/icon.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="stage/build/export/protyle-method.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="stage/protyle/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="${servePath}appearance/icons/${window.siyuan.config.appearance.icon}/icon.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="${servePath}stage/build/export/protyle-method.js?v=${Constants.SIYUAN_VERSION}"></script>
<script src="${servePath}stage/protyle/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}"></script>
<script>
window.siyuan = {
config: {

View file

@ -198,16 +198,15 @@ export const initAssets = () => {
});
};
export const setInlineStyle = async (set = true) => {
export const setInlineStyle = async (set = true, servePath = "../../..") => {
const height = Math.floor(window.siyuan.config.editor.fontSize * 1.625);
let style;
// Emojis Reset: 字体中包含了 emoji需重置
// Emojis Additional 苹果/win11 字体中没有的 emoji
if (isMac() || isIPad() || isIPhone()) {
style = `@font-face {
font-family: "Emojis Additional";
src: url(../../../appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
src: url(${servePath}/appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
unicode-range: U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1fa8f;
}
@font-face {
@ -233,7 +232,7 @@ export const setInlineStyle = async (set = true) => {
if (isWin11Browser) {
style = `@font-face {
font-family: "Emojis Additional";
src: url(../../../appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
src: url(${servePath}/appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
unicode-range: U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1f3f4, U+e0067, U+e0062,
U+e0065, U+e006e, U+e007f, U+e0073, U+e0063, U+e0074, U+e0077, U+e006c;
size-adjust: 85%;
@ -255,7 +254,7 @@ export const setInlineStyle = async (set = true) => {
} else {
style = `@font-face {
font-family: "Emojis Reset";
src: url(../../../appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
src: url(${servePath}/appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
unicode-range: U+1f170-1f171, U+1f17e, U+1f17f, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250, U+1f251, U+1f32b, U+1f3bc,
U+1f411, U+1f42d, U+1f42e, U+1f431, U+1f435, U+1f441, U+1f4a8, U+1f4ab, U+1f525, U+1f600-1f60d, U+1f60f-1f623,
U+1f625-1f62b, U+1f62d-1f63f, U+1F643, U+1F640, U+1f79, U+1f8f, U+1fa79, U+1fae4, U+1fae9, U+1fac6, U+1fabe, U+1fadf,
@ -268,7 +267,7 @@ export const setInlineStyle = async (set = true) => {
}
@font-face {
font-family: "Emojis";
src: url(../../../appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2"),
src: url(${servePath}/appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2"),
local("Segoe UI Emoji"),
local("Segoe UI Symbol"),
local("Apple Color Emoji"),