@@ -11,11 +11,11 @@ import { useAppStore } from '@/store/app'
1111import { useSnippetStore } from ' @/store/snippets'
1212import sanitizeHtml from ' sanitize-html'
1313import hljs from ' highlight.js'
14- import ' highlight.js/styles/github.css'
15- import { computed , onBeforeUnmount , onMounted , ref } from ' vue'
14+ import { computed , onBeforeUnmount , onMounted , ref , watch } from ' vue'
1615import { ipc } from ' @/electron'
1716import { marked } from ' marked'
1817import mermaid from ' mermaid'
18+ import { useHljsTheme } from ' @/composable'
1919
2020interface Props {
2121 value: string
@@ -27,6 +27,9 @@ const appStore = useAppStore()
2727const snippetStore = useSnippetStore ()
2828
2929const forceRefresh = ref ()
30+ const preTagBg = computed (() =>
31+ appStore .isLightTheme ? ' #fff' : ' var(--color-contrast-high)'
32+ )
3033
3134const init = () => {
3235 const renderer: marked .RendererObject = {
@@ -181,6 +184,18 @@ const height = computed(() => {
181184 return window .innerHeight - result + ' px'
182185})
183186
187+ watch (
188+ () => appStore .isLightTheme ,
189+ v => {
190+ if (v ) {
191+ useHljsTheme (' light' )
192+ } else {
193+ useHljsTheme (' dark' )
194+ }
195+ },
196+ { immediate: true }
197+ )
198+
184199init ()
185200
186201onMounted (() => {
@@ -207,5 +222,8 @@ window.addEventListener('resize', () => {
207222 :deep(.ps ) {
208223 height : v-bind (height );
209224 }
225+ :deep(pre ) {
226+ background-color : v-bind (preTagBg );
227+ }
210228}
211229 </style >
0 commit comments