File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1- import { createApp } from 'vue'
2- import { installI18nOnly } from '@prompt-optimizer/ui'
1+ import { createApp , watch } from 'vue'
2+ import { installI18nOnly , i18n } from '@prompt-optimizer/ui'
33import App from './App.vue'
44
55import './style.css'
@@ -8,4 +8,18 @@ import '@prompt-optimizer/ui/dist/style.css'
88const app = createApp ( App )
99// 只安装i18n插件,语言初始化将在App.vue中服务准备好后进行
1010installI18nOnly ( app )
11+
12+ // 同步文档标题和语言属性
13+ if ( typeof document !== 'undefined' ) {
14+ const syncDocumentTitle = ( ) => {
15+ document . title = i18n . global . t ( 'common.appName' )
16+ const currentLocale = String ( i18n . global . locale . value || '' )
17+ const htmlLang = currentLocale . startsWith ( 'zh' ) ? 'zh' : 'en'
18+ document . documentElement . setAttribute ( 'lang' , htmlLang )
19+ }
20+
21+ syncDocumentTitle ( )
22+ watch ( i18n . global . locale , syncDocumentTitle )
23+ }
24+
1125app . mount ( '#app' )
You can’t perform that action at this time.
0 commit comments