feat: 把i18n的东西放到 i18n.vue
This commit is contained in:
parent
7e2cda4886
commit
960580fd62
@ -29,6 +29,10 @@ const i18n = createI18n({
|
||||
* @param { string } localeKey 多语言的key,eg: "app.name"
|
||||
*/
|
||||
export const translate = (localeKey: string) => {
|
||||
if (!localeKey) {
|
||||
console.error(`[i18n] Function translate(), localeKey param is required`)
|
||||
return ''
|
||||
}
|
||||
const locale = getLocale()
|
||||
const message = messages[locale]
|
||||
if (Object.keys(message).includes(localeKey)) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
<template>{{ $t('app.name') }}</template>
|
||||
|
||||
<route lang="json">
|
||||
{
|
||||
"style": {
|
||||
@ -7,3 +5,11 @@
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>{{ $t('app.name') }}</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { testI18n } from '@/utils/index'
|
||||
|
||||
testI18n()
|
||||
</script>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<route lang="json5" type="home">
|
||||
{
|
||||
style: {
|
||||
// "navigationStyle": "custom",
|
||||
navigationBarTitleText: '%app.name%',
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '首页',
|
||||
},
|
||||
}
|
||||
</route>
|
||||
@ -12,7 +12,6 @@
|
||||
class="bg-white h-full overflow-hidden pt-2 px-4"
|
||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
||||
>
|
||||
<view>{{ $t('app.name') }}</view>
|
||||
<view class="mt-12">
|
||||
<image src="/static/logo.svg" alt="" class="w-40 h-40 block mx-auto" />
|
||||
</view>
|
||||
@ -38,15 +37,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { testI18n } from '@/utils/index'
|
||||
|
||||
testI18n()
|
||||
|
||||
// 获取屏幕边界到安全区域距离
|
||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
|
||||
const author = ref('菲鸽')
|
||||
console.log(author)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user