Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: font-size of theme #429

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading