From ddf69f7d96a0df4c19a5961a8502f7bdd0aa53e8 Mon Sep 17 00:00:00 2001 From: YangFong Date: Sun, 8 Sep 2024 19:52:30 +0800 Subject: [PATCH] fix: font-size of init (#392) --- src/stores/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/stores/index.js b/src/stores/index.js index 8e796df..e59cd75 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -1,4 +1,4 @@ -import { markRaw, onMounted, ref } from 'vue' +import { computed, markRaw, onMounted, ref } from 'vue' import { createPinia, defineStore } from 'pinia' import { marked } from 'marked' import CodeMirror from 'codemirror' @@ -43,12 +43,12 @@ export const useStore = defineStore(`store`, () => { // 图注格式 const legend = useStorage(`legend`, legendOptions[3].value) - const fontSizeNumber = fontSize.value.replace(`px`, ``) + const fontSizeNumber = computed(() => fontSize.value.replace(`px`, ``)) const renderer = initRenderer({ - theme: customizeTheme(themeMap[theme.value], { fontSize: fontSizeNumber, color: fontColor.value }), + theme: customizeTheme(themeMap[theme.value], { fontSize: fontSizeNumber.value, color: fontColor.value }), fonts: fontFamily.value, - size: fontSize.value, + size: fontSize, }) // 内容编辑器编辑器 @@ -174,7 +174,7 @@ export const useStore = defineStore(`store`, () => { // 更新 CSS const updateCss = () => { const json = css2json(cssEditor.value.getValue()) - const newTheme = customCssWithTemplate(json, fontColor.value, customizeTheme(themeMap[theme.value], { fontSize: fontSizeNumber, color: fontColor.value })) + const newTheme = customCssWithTemplate(json, fontColor.value, customizeTheme(themeMap[theme.value], { fontSize: fontSizeNumber.value, color: fontColor.value })) renderer.setOptions({ theme: newTheme, }) @@ -263,7 +263,7 @@ export const useStore = defineStore(`store`, () => { const themeChanged = withAfterRefresh((newTheme) => { renderer.setOptions({ - theme: customizeTheme(themeMap[newTheme], { fontSize: fontSizeNumber, color: fontColor.value }), + theme: customizeTheme(themeMap[newTheme], { fontSize: fontSizeNumber.value, color: fontColor.value }), }) theme.value = newTheme })