From 8d12093adade1952a4af2a1c00abd7e00e1d3352 Mon Sep 17 00:00:00 2001 From: YangFong Date: Tue, 23 Jul 2024 22:41:02 +0800 Subject: [PATCH] fix: initialization of the title size close #315 --- src/assets/scripts/util.js | 10 ++++------ src/stores/index.js | 11 +++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/assets/scripts/util.js b/src/assets/scripts/util.js index 03f7c5d..4ce9b3b 100644 --- a/src/assets/scripts/util.js +++ b/src/assets/scripts/util.js @@ -28,9 +28,9 @@ export function setColorWithCustomTemplate(theme, color) { export function setFontSizeWithTemplate(template) { return function (fontSize) { const customTheme = JSON.parse(JSON.stringify(template)) - customTheme.block.h1[`font-size`] = `${fontSize * 1.14}px` - customTheme.block.h2[`font-size`] = `${fontSize * 1.1}px` - customTheme.block.h3[`font-size`] = `${fontSize}px` + customTheme.block.h1[`font-size`] = `${fontSize * 1.2}px` + customTheme.block.h2[`font-size`] = `${fontSize * 1.2}px` + customTheme.block.h3[`font-size`] = `${fontSize * 1.1}px` customTheme.block.h4[`font-size`] = `${fontSize}px` return customTheme } @@ -284,9 +284,7 @@ export function exportHTML() { // 判断是否是包裹代码块的 code 元素 function isCode(element) { - return ( - element.tagName === `CODE` - ) + return element.tagName === `CODE` } // 判断是否是包裹代码字符的 span 元素 diff --git a/src/stores/index.js b/src/stores/index.js index 37e8ff3..ccf388d 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -6,7 +6,12 @@ import config from '../assets/scripts/config' import WxRenderer from '../assets/scripts/renderers/wx-renderer' import DEFAULT_CONTENT from '@/assets/example/markdown.md' import DEFAULT_CSS_CONTENT from '@/assets/example/theme-css.txt' -import { setColor, formatDoc, formatCss } from '@/assets/scripts/util' +import { + formatDoc, + formatCss, + setFontSize, + setColorWithCustomTemplate, +} from '@/assets/scripts/util' const defaultKeyMap = CodeMirror.keyMap[`default`] const modPrefix = @@ -92,8 +97,10 @@ export const useStore = defineStore(`store`, { localStorage.getItem(`isMacCodeBlock`) === `false` ) this.isEditOnLeft = !(localStorage.getItem(`isEditOnLeft`) === `false`) + + const theme = setFontSize(this.currentSize.replace(`px`, ``)) this.wxRenderer = new WxRenderer({ - theme: setColor(this.currentColor), + theme: setColorWithCustomTemplate(theme, this.currentColor), fonts: this.currentFont, size: this.currentSize, })