Skip to content

Commit

Permalink
fix: initialization of the title size
Browse files Browse the repository at this point in the history
close #315
  • Loading branch information
YangFong committed Jul 23, 2024
1 parent ff44d3d commit 8d12093
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/assets/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -284,9 +284,7 @@ export function exportHTML() {

// 判断是否是包裹代码块的 code 元素
function isCode(element) {
return (
element.tagName === `CODE`
)
return element.tagName === `CODE`
}

// 判断是否是包裹代码字符的 span 元素
Expand Down
11 changes: 9 additions & 2 deletions src/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit 8d12093

Please sign in to comment.