add vue i18n

This commit is contained in:
QuangNN 2023-10-08 16:57:07 +07:00
parent 9bb487f05f
commit 5c1bc7b985
8 changed files with 43 additions and 13 deletions

View File

@ -17,7 +17,7 @@ export const PROXY_CONFIG = {
* @转发路径 http://localhost:9999/api/v1/user * @转发路径 http://localhost:9999/api/v1/user
*/ */
'/api/v1': { '/api/v1': {
target: 'http://localhost:9999', target: 'http://127.0.0.1:9999',
changeOrigin: true, changeOrigin: true,
}, },
} }

View File

@ -6,6 +6,19 @@
"message_input_username_password": "请输入用户名和密码", "message_input_username_password": "请输入用户名和密码",
"message_verifying": "正在验证...", "message_verifying": "正在验证...",
"message_login_success": "登录成功" "message_login_success": "登录成功"
},
"workbench": {
"label_workbench": "工作台",
"text_hello": "hello, {username}",
"text_welcome": "今天又是元气满满的一天!",
"label_number_of_items": "项目数",
"label_upcoming": "待办",
"label_information": "消息",
"label_project": "项目",
"label_more": "更多"
},
"errors": {
"text_back_to_home": "返回首页"
} }
} }
} }

View File

@ -6,6 +6,19 @@
"message_input_username_password": "Please enter username and password", "message_input_username_password": "Please enter username and password",
"message_verifying": "Verifying...", "message_verifying": "Verifying...",
"message_login_success": "Login successful" "message_login_success": "Login successful"
},
"workbench": {
"label_workbench": "Workbench",
"text_hello": "hello, {username}",
"text_welcome": "Today is another day full of energy!",
"label_number_of_items": "Number of items",
"label_upcoming": "Upcoming",
"label_information": "Information",
"label_project": "Project",
"label_more": "More"
},
"errors": {
"text_back_to_home": "Back to home"
} }
} }
} }

View File

@ -5,7 +5,7 @@
<icon-custom-unauthorized text-400px text-primary></icon-custom-unauthorized> <icon-custom-unauthorized text-400px text-primary></icon-custom-unauthorized>
</template> </template>
<template #footer> <template #footer>
<n-button type="primary" @click="replace('/')">返回首页</n-button> <n-button type="primary" @click="replace('/')">{{ $t('views.errors.text_back_to_home') }}</n-button>
</template> </template>
</n-result> </n-result>
</AppPage> </AppPage>

View File

@ -5,7 +5,7 @@
<icon-custom-forbidden text-400px text-primary></icon-custom-forbidden> <icon-custom-forbidden text-400px text-primary></icon-custom-forbidden>
</template> </template>
<template #footer> <template #footer>
<n-button type="primary" @click="replace('/')">返回首页</n-button> <n-button type="primary" @click="replace('/')">{{ $t('views.errors.text_back_to_home') }}</n-button>
</template> </template>
</n-result> </n-result>
</AppPage> </AppPage>

View File

@ -5,7 +5,7 @@
<icon-custom-not-found text-400px text-primary></icon-custom-not-found> <icon-custom-not-found text-400px text-primary></icon-custom-not-found>
</template> </template>
<template #footer> <template #footer>
<n-button type="primary" @click="replace('/')">返回首页</n-button> <n-button type="primary" @click="replace('/')">{{ $t('views.errors.text_back_to_home') }}</n-button>
</template> </template>
</n-result> </n-result>
</AppPage> </AppPage>

View File

@ -5,7 +5,7 @@
<icon-custom-server-error text-400px text-primary></icon-custom-server-error> <icon-custom-server-error text-400px text-primary></icon-custom-server-error>
</template> </template>
<template #footer> <template #footer>
<n-button type="primary" @click="replace('/')">返回首页</n-button> <n-button type="primary" @click="replace('/')">{{ $t('views.errors.text_back_to_home') }}</n-button>
</template> </template>
</n-result> </n-result>
</AppPage> </AppPage>

View File

@ -6,8 +6,8 @@
<div flex items-center> <div flex items-center>
<img rounded-full width="60" :src="userStore.avatar" /> <img rounded-full width="60" :src="userStore.avatar" />
<div ml-10> <div ml-10>
<p text-20 font-semibold>hello, {{ userStore.name }}</p> <p text-20 font-semibold> {{ $t('views.workbench.text_hello', {username: userStore.name}) }}</p>
<p mt-5 text-14 op-60>今天又是元气满满的一天!</p> <p mt-5 text-14 op-60>{{ $t('views.workbench.text_welcome') }}</p>
</div> </div>
</div> </div>
<n-space :size="12" :wrap="false"> <n-space :size="12" :wrap="false">
@ -16,9 +16,9 @@
</div> </div>
</n-card> </n-card>
<n-card title="项目" size="small" :segmented="true" mt-15 rounded-10> <n-card :title="$t('views.workbench.label_project')" size="small" :segmented="true" mt-15 rounded-10>
<template #header-extra> <template #header-extra>
<n-button text type="primary">更多</n-button> <n-button text type="primary">{{$t('views.workbench.label_more')}}</n-button>
</template> </template>
<div flex flex-wrap justify-between> <div flex flex-wrap justify-between>
<n-card <n-card
@ -29,7 +29,7 @@
title="Vue FastAPI Admin" title="Vue FastAPI Admin"
size="small" size="small"
> >
<p op-60>一个基于 Vue3.0FastAPINaive UI 的轻量级后台管理模板</p> <p op-60>{{dummyText}}</p>
</n-card> </n-card>
</div> </div>
</n-card> </n-card>
@ -39,21 +39,25 @@
<script setup> <script setup>
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import { useI18n } from 'vue-i18n'
const dummyText = "一个基于 Vue3.0、FastAPI、Naive UI 的轻量级后台管理模板"
const {t} = useI18n({ useScope: "global" })
const statisticData = [ const statisticData = [
{ {
id: 0, id: 0,
label: '项目数', label: t('views.workbench.label_number_of_items'),
value: '25', value: '25',
}, },
{ {
id: 1, id: 1,
label: '待办', label: t('views.workbench.label_upcoming'),
value: '4/16', value: '4/16',
}, },
{ {
id: 2, id: 2,
label: '消息', label: t('views.workbench.label_information'),
value: '12', value: '12',
}, },
] ]