Skip to content

Commit 3e872ed

Browse files
fix: markdown preview i18n
1 parent 2414405 commit 3e872ed

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
<template>
2-
<MdPreview noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" />
2+
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" />
33
</template>
44

55
<script setup lang="ts">
6-
import { MdPreview } from 'md-editor-v3'
6+
import { computed } from 'vue'
7+
import { MdPreview, config } from 'md-editor-v3'
8+
import { getBrowserLang } from '@/locales/index'
9+
import useStore from '@/stores'
10+
// 引入公共库中的语言配置
11+
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
12+
713
defineOptions({ name: 'MdPreview' })
14+
const { user } = useStore()
15+
const language = computed(() => user.getLanguage() || getBrowserLang() || '')
16+
config({
17+
editorConfig: {
18+
languageUserDefined: {
19+
'zh-Hant': ZH_TW
20+
}
21+
}
22+
})
823
</script>

0 commit comments

Comments
 (0)