Skip to content

Commit

Permalink
fix: font-size of theme (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
YangFong authored Sep 28, 2024
1 parent c7b0e02 commit e7f01b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CodeMirror.EditorFromTextArea | null>(null)
Expand Down Expand Up @@ -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,
})

// 更新编辑器
Expand Down Expand Up @@ -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 }))
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export function addPrefix(str: string) {
}

export function customizeTheme(theme: Theme, options: {
fontSize?: string
fontSize?: number
color?: string
}) {
const newTheme = JSON.parse(JSON.stringify(theme))
const { fontSize, color } = 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) {
Expand Down

0 comments on commit e7f01b6

Please sign in to comment.