From e7f01b640a7325c26b80ba8890431a90c6a42dee Mon Sep 17 00:00:00 2001 From: YangFong Date: Sat, 28 Sep 2024 16:07:30 +0800 Subject: [PATCH] fix: font-size of theme (#429) --- src/stores/index.ts | 6 +++--- src/utils/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stores/index.ts b/src/stores/index.ts index 89e3fcc..9982dba 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -43,7 +43,7 @@ export const useStore = defineStore(`store`, () => { // 图注格式 const legend = useStorage(`legend`, legendOptions[3].value) - const fontSizeNumber = computed(() => fontSize.value.replace(`px`, ``)) + const fontSizeNumber = computed(() => Number(fontSize.value.replace(`px`, ``))) // 内容编辑器编辑器 const editor = ref(null) @@ -132,7 +132,7 @@ export const useStore = defineStore(`store`, () => { const renderer = initRenderer({ theme: customCssWithTemplate(css2json(getCurrentTab().content), primaryColor.value, customizeTheme(themeMap[theme.value], { fontSize: fontSizeNumber.value, color: primaryColor.value })), fonts: fontFamily.value, - size: fontSizeNumber.value, + size: fontSize.value, }) // 更新编辑器 @@ -264,7 +264,7 @@ export const useStore = defineStore(`store`, () => { const getTheme = (size: string, color: string) => { const newTheme = themeMap[theme.value] - const fontSize = size.replace(`px`, ``) + const fontSize = Number(size.replace(`px`, ``)) return customCssWithTemplate(css2json(getCurrentTab().content), color, customizeTheme(newTheme, { fontSize, color })) } diff --git a/src/utils/index.ts b/src/utils/index.ts index 17efcd1..605d5cd 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -14,7 +14,7 @@ export function addPrefix(str: string) { } export function customizeTheme(theme: Theme, options: { - fontSize?: string + fontSize?: number color?: string }) { const newTheme = JSON.parse(JSON.stringify(theme)) @@ -22,7 +22,7 @@ export function customizeTheme(theme: Theme, options: { if (fontSize) { for (let i = 1; i <= 4; i++) { const v = newTheme.block[`h${i}`][`font-size`] - newTheme.block[`h${i}`][`font-size`] = `${Number(fontSize) * Number.parseFloat(v)}px` + newTheme.block[`h${i}`][`font-size`] = `${fontSize * Number.parseFloat(v)}px` } } if (color) {