perf: 优化体积,highlight.js按需导入与i18n按需加载 (#696)
* perf: 优化打包体积,highlight.js按需导入与i18n按需加载 1. highlight.js: 从全量导入改为 core + 注册27种常用语言,减少约500~800KB 2. i18n: 只同步加载en语言包,其他8种语言改为异步加载,首屏减少约350~400KB 3. 使用vue-i18n的setLocaleMessage API动态注册语言包 4. 新增switchLocale函数统一处理语言切换 5. 同步更新相关测试文件的mock路径和API适配 * 修复类型断言
This commit is contained in:
committed by
GitHub
parent
1b4733e755
commit
f6df0fecfa
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { switchLocale } from '@/i18n'
|
||||
|
||||
const { locale } = useI18n()
|
||||
|
||||
@@ -16,7 +17,8 @@ const options = [
|
||||
{ label: 'Português', value: 'pt' },
|
||||
]
|
||||
|
||||
function handleChange(val: string) {
|
||||
async function handleChange(val: string) {
|
||||
await switchLocale(val)
|
||||
locale.value = val
|
||||
localStorage.setItem('hermes_locale', val)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user