Skip to content

Commit

Permalink
feat: auto swith highlight theme #48
Browse files Browse the repository at this point in the history
Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll committed Apr 27, 2024
1 parent a188fc6 commit 275b1fa
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/MarkdownRender.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@ import { defineProps, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import MarkdownIt from 'markdown-it';
import hljs from 'highlight.js'; // https://highlightjs.org
import 'highlight.js/styles/default.css';
import { useChatStore } from '../store';
import { useAppStore, useChatStore } from '../store';
const props = defineProps({
markdown: {
type: String,
required: true,
},
});
const appStore = useAppStore();
const { uiThemeType } = storeToRefs(appStore);
watch(
() => uiThemeType.value,
async () => {
if (uiThemeType.value === 'dark') {
await import('highlight.js/styles/atom-one-dark.css');
} else {
await import('highlight.js/styles/atom-one-light.css');
}
},
{ immediate: true },
);
const chatStore = useChatStore();
const { insertBoard } = storeToRefs(chatStore);
Expand Down

0 comments on commit 275b1fa

Please sign in to comment.