add vue i18n

This commit is contained in:
QuangNN 2023-10-08 17:07:11 +07:00
parent 5c1bc7b985
commit 5daaca331f
3 changed files with 22 additions and 5 deletions

View File

@ -1,5 +1,12 @@
{
"app_name": "Vue FastAPI Admin",
"header": {
"label_profile": "个人信息",
"label_logout": "退出登录",
"label_logout_dialog_title": "提示",
"text_logout_confirm": "确认退出?",
"text_logout_success": "已退出登录"
},
"views": {
"login": {
"text_login": "登录",

View File

@ -1,5 +1,12 @@
{
"app_name": "Vue FastAPI Admin",
"header": {
"label_profile": "Profile",
"label_logout": "Logout",
"label_logout_dialog_title": "Hint",
"text_logout_confirm": "Logout confirm",
"text_logout_success": "Logout success"
},
"views": {
"login": {
"text_login": "Login",

View File

@ -11,6 +11,9 @@
import { useUserStore } from '@/store'
import { renderIcon } from '@/utils'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
const {t} = useI18n()
const router = useRouter()
@ -18,12 +21,12 @@ const userStore = useUserStore()
const options = [
{
label: '个人信息',
label: t('header.label_profile'),
key: 'profile',
icon: renderIcon('mdi-account-arrow-right-outline', { size: '14px' }),
},
{
label: '退出登录',
label: t('header.label_logout'),
key: 'logout',
icon: renderIcon('mdi:exit-to-app', { size: '14px' }),
},
@ -34,12 +37,12 @@ function handleSelect(key) {
router.push('/profile')
} else if (key === 'logout') {
$dialog.confirm({
title: '提示',
title: t('header.label_logout_dialog_title'),
type: 'warning',
content: '确认退出?',
content: t('header.text_logout_confirm'),
confirm() {
userStore.logout()
$message.success('已退出登录')
$message.success(t('header.text_logout_success'))
},
})
}