add vue i18n
This commit is contained in:
parent
5daaca331f
commit
1740d3d281
@ -5,6 +5,7 @@ import messages from './messages'
|
|||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
legacy: false,
|
legacy: false,
|
||||||
|
globalInjection: true,
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
messages: messages
|
messages: messages
|
||||||
|
|||||||
@ -24,8 +24,38 @@
|
|||||||
"label_project": "项目",
|
"label_project": "项目",
|
||||||
"label_more": "更多"
|
"label_more": "更多"
|
||||||
},
|
},
|
||||||
|
"profile": {
|
||||||
|
"label_profile": "个人中心",
|
||||||
|
"label_modify_information": "修改信息",
|
||||||
|
"label_change_password": "修改密码",
|
||||||
|
"label_avatar": "头像",
|
||||||
|
"label_username": "用户姓名",
|
||||||
|
"label_email": "邮箱",
|
||||||
|
"label_old_password": "旧密码",
|
||||||
|
"label_new_password": "新密码",
|
||||||
|
"label_confirm_password": "确认密码",
|
||||||
|
"placeholder_username": "请填写姓名",
|
||||||
|
"placeholder_email": "请填写邮箱",
|
||||||
|
"placeholder_old_password": "请输入旧密码",
|
||||||
|
"placeholder_new_password": "请输入新密码",
|
||||||
|
"placeholder_confirm_password": "请再次输入新密码",
|
||||||
|
"message_username_required": "请输入昵称",
|
||||||
|
"message_old_password_required": "请输入旧密码",
|
||||||
|
"message_new_password_required": "请输入新密码",
|
||||||
|
"message_password_confirmation_required": "请再次输入密码",
|
||||||
|
"message_password_confirmation_diff": "两次密码输入不一致"
|
||||||
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
|
"label_error": "错误页",
|
||||||
"text_back_to_home": "返回首页"
|
"text_back_to_home": "返回首页"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"common": {
|
||||||
|
"text": {
|
||||||
|
"update_success": "修改成功"
|
||||||
|
},
|
||||||
|
"buttons": {
|
||||||
|
"update": "修改"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,8 +24,38 @@
|
|||||||
"label_project": "Project",
|
"label_project": "Project",
|
||||||
"label_more": "More"
|
"label_more": "More"
|
||||||
},
|
},
|
||||||
|
"profile": {
|
||||||
|
"label_profile": "Profile",
|
||||||
|
"label_modify_information": "Modify your information",
|
||||||
|
"label_change_password": "Change password",
|
||||||
|
"label_avatar": "Avatar",
|
||||||
|
"label_username": "Username",
|
||||||
|
"label_email": "Email",
|
||||||
|
"label_old_password": "Old password",
|
||||||
|
"label_new_password": "New password",
|
||||||
|
"label_confirm_password": "Password confirmation",
|
||||||
|
"placeholder_username": "Please fill in your name",
|
||||||
|
"placeholder_email": "Please fill in your email address",
|
||||||
|
"placeholder_old_password": "Please enter the old password",
|
||||||
|
"placeholder_new_password": "Please enter a new password",
|
||||||
|
"placeholder_confirm_password": "Please enter the confirm password",
|
||||||
|
"message_username_required": "Please enter username",
|
||||||
|
"message_old_password_required": "Please enter the old password",
|
||||||
|
"message_new_password_required": "Please enter a new password",
|
||||||
|
"message_password_confirmation_required": "Please enter confirm password",
|
||||||
|
"message_password_confirmation_diff": "Two password inputs are inconsistent"
|
||||||
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
|
"label_error": "Error",
|
||||||
"text_back_to_home": "Back to home"
|
"text_back_to_home": "Back to home"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"common": {
|
||||||
|
"text": {
|
||||||
|
"update_success": "Update success"
|
||||||
|
},
|
||||||
|
"buttons": {
|
||||||
|
"update": "Update"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,11 @@
|
|||||||
|
import i18n from '~/i18n'
|
||||||
|
const {t} = i18n.global
|
||||||
|
|
||||||
const Layout = () => import('@/layout/index.vue')
|
const Layout = () => import('@/layout/index.vue')
|
||||||
|
|
||||||
export const basicRoutes = [
|
export const basicRoutes = [
|
||||||
{
|
{
|
||||||
name: '工作台',
|
name: t('views.workbench.label_workbench'),
|
||||||
path: '/',
|
path: '/',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/workbench', // 默认跳转到首页
|
redirect: '/workbench', // 默认跳转到首页
|
||||||
@ -10,9 +13,9 @@ export const basicRoutes = [
|
|||||||
{
|
{
|
||||||
path: 'workbench',
|
path: 'workbench',
|
||||||
component: () => import('@/views/workbench/index.vue'),
|
component: () => import('@/views/workbench/index.vue'),
|
||||||
name: '工作台',
|
name: t('views.workbench.label_workbench'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '工作台',
|
title: t('views.workbench.label_workbench'),
|
||||||
icon: 'icon-park-outline:workbench',
|
icon: 'icon-park-outline:workbench',
|
||||||
affix: true,
|
affix: true,
|
||||||
},
|
},
|
||||||
@ -21,7 +24,7 @@ export const basicRoutes = [
|
|||||||
meta: { order: 0 },
|
meta: { order: 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '个人中心',
|
name: t('views.profile.label_profile'),
|
||||||
path: '/',
|
path: '/',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
isHidden: true,
|
isHidden: true,
|
||||||
@ -29,9 +32,9 @@ export const basicRoutes = [
|
|||||||
{
|
{
|
||||||
path: 'profile',
|
path: 'profile',
|
||||||
component: () => import('@/views/profile/index.vue'),
|
component: () => import('@/views/profile/index.vue'),
|
||||||
name: '个人中心',
|
name: t('views.profile.label_profile'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '个人中心',
|
title: t('views.profile.label_profile'),
|
||||||
icon: 'user',
|
icon: 'user',
|
||||||
affix: true,
|
affix: true,
|
||||||
},
|
},
|
||||||
@ -45,7 +48,7 @@ export const basicRoutes = [
|
|||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/error-page/404',
|
redirect: '/error-page/404',
|
||||||
meta: {
|
meta: {
|
||||||
title: '错误页',
|
title: t('views.errors.label_error'),
|
||||||
icon: 'mdi:alert-circle-outline',
|
icon: 'mdi:alert-circle-outline',
|
||||||
order: 99,
|
order: 99,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { NButton, NForm, NFormItem, NInput, NTabPane, NTabs, NImage } from 'naive-ui'
|
import { NButton, NForm, NFormItem, NInput, NTabPane, NTabs, NImage } from 'naive-ui'
|
||||||
|
import {useI18n} from "vue-i18n";
|
||||||
import CommonPage from '@/components/page/CommonPage.vue'
|
import CommonPage from '@/components/page/CommonPage.vue'
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { is } from '~/src/utils'
|
import { is } from '~/src/utils'
|
||||||
|
|
||||||
|
const {t} = useI18n()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ async function updateProfile() {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
userStore.setUserInfo(infoForm.value)
|
userStore.setUserInfo(infoForm.value)
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
$message.success('修改成功')
|
$message.success(t('common.text.update_success'))
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
@ -37,7 +38,7 @@ const infoFormRules = {
|
|||||||
username: [
|
username: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入昵称',
|
message: t('views.profile.message_username_required'),
|
||||||
trigger: ['input', 'blur', 'change'],
|
trigger: ['input', 'blur', 'change'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -77,31 +78,31 @@ const passwordFormRules = {
|
|||||||
old_password: [
|
old_password: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入旧密码',
|
message: t('views.profile.message_old_password_required'),
|
||||||
trigger: ['input', 'blur', 'change'],
|
trigger: ['input', 'blur', 'change'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
new_password: [
|
new_password: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入新密码',
|
message: t('views.profile.message_new_password_required'),
|
||||||
trigger: ['input', 'blur', 'change'],
|
trigger: ['input', 'blur', 'change'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
confirm_password: [
|
confirm_password: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请再次输入密码',
|
message: t('views.profile.message_password_confirmation_required'),
|
||||||
trigger: ['input', 'blur'],
|
trigger: ['input', 'blur'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
validator: validatePasswordStartWith,
|
validator: validatePasswordStartWith,
|
||||||
message: '两次密码输入不一致',
|
message: t('views.profile.message_password_confirmation_diff'),
|
||||||
trigger: 'input',
|
trigger: 'input',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
validator: validatePasswordSame,
|
validator: validatePasswordSame,
|
||||||
message: '两次密码输入不一致',
|
message: t('views.profile.message_password_confirmation_diff'),
|
||||||
trigger: ['blur', 'password-input'],
|
trigger: ['blur', 'password-input'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -121,7 +122,7 @@ function validatePasswordSame(rule, value) {
|
|||||||
<template>
|
<template>
|
||||||
<CommonPage :show-header="false">
|
<CommonPage :show-header="false">
|
||||||
<NTabs type="line" animated>
|
<NTabs type="line" animated>
|
||||||
<NTabPane name="website" tab="修改信息">
|
<NTabPane name="website" :tab="$t('views.profile.label_modify_information')">
|
||||||
<div class="m-30 flex items-center">
|
<div class="m-30 flex items-center">
|
||||||
<NForm
|
<NForm
|
||||||
ref="infoFormRef"
|
ref="infoFormRef"
|
||||||
@ -132,56 +133,56 @@ function validatePasswordSame(rule, value) {
|
|||||||
:rules="infoFormRules"
|
:rules="infoFormRules"
|
||||||
class="w-400"
|
class="w-400"
|
||||||
>
|
>
|
||||||
<NFormItem label="头像" path="avatar">
|
<NFormItem :label="$t('views.profile.label_avatar')" path="avatar">
|
||||||
<NImage width="100" :src="infoForm.avatar"></NImage>
|
<NImage width="100" :src="infoForm.avatar"></NImage>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label="用户姓名" path="username">
|
<NFormItem :label="$t('views.profile.label_username')" path="username">
|
||||||
<NInput v-model:value="infoForm.username" type="text" placeholder="请填写姓名" />
|
<NInput v-model:value="infoForm.username" type="text" :placeholder="$t('views.profile.placeholder_username')" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label="邮箱" path="email">
|
<NFormItem :label="$t('views.profile.label_email')" path="email">
|
||||||
<NInput v-model:value="infoForm.email" type="text" placeholder="请填写邮箱" />
|
<NInput v-model:value="infoForm.email" type="text" :placeholder="$t('views.profile.placeholder_email')" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NButton type="primary" :loading="isLoading" @click="updateProfile"> 修改 </NButton>
|
<NButton type="primary" :loading="isLoading" @click="updateProfile"> {{$t("common.buttons.update")}} </NButton>
|
||||||
</NForm>
|
</NForm>
|
||||||
</div>
|
</div>
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
<NTabPane name="contact" tab="修改密码">
|
<NTabPane name="contact" :tab="$t('views.profile.label_change_password')">
|
||||||
<NForm
|
<NForm
|
||||||
ref="passwordFormRef"
|
ref="passwordFormRef"
|
||||||
label-placement="left"
|
label-placement="left"
|
||||||
label-align="left"
|
label-align="left"
|
||||||
:model="passwordForm"
|
:model="passwordForm"
|
||||||
label-width="100"
|
label-width="200"
|
||||||
:rules="passwordFormRules"
|
:rules="passwordFormRules"
|
||||||
class="m-30 w-400"
|
class="m-30 w-500"
|
||||||
>
|
>
|
||||||
<NFormItem label="旧密码" path="old_password">
|
<NFormItem :label="$t('views.profile.label_old_password')" path="old_password">
|
||||||
<NInput
|
<NInput
|
||||||
v-model:value="passwordForm.old_password"
|
v-model:value="passwordForm.old_password"
|
||||||
type="password"
|
type="password"
|
||||||
show-password-on="mousedown"
|
show-password-on="mousedown"
|
||||||
placeholder="请输入旧密码"
|
:placeholder="$t('views.profile.placeholder_old_password')"
|
||||||
/>
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label="新密码" path="new_password">
|
<NFormItem :label="$t('views.profile.label_new_password')" path="new_password">
|
||||||
<NInput
|
<NInput
|
||||||
v-model:value="passwordForm.new_password"
|
v-model:value="passwordForm.new_password"
|
||||||
:disabled="!passwordForm.old_password"
|
:disabled="!passwordForm.old_password"
|
||||||
type="password"
|
type="password"
|
||||||
show-password-on="mousedown"
|
show-password-on="mousedown"
|
||||||
placeholder="请输入新密码"
|
:placeholder="$t('views.profile.placeholder_new_password')"
|
||||||
/>
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label="确认密码" path="confirm_password">
|
<NFormItem :label="$t('views.profile.label_confirm_password')" path="confirm_password">
|
||||||
<NInput
|
<NInput
|
||||||
v-model:value="passwordForm.confirm_password"
|
v-model:value="passwordForm.confirm_password"
|
||||||
:disabled="!passwordForm.new_password"
|
:disabled="!passwordForm.new_password"
|
||||||
type="password"
|
type="password"
|
||||||
show-password-on="mousedown"
|
show-password-on="mousedown"
|
||||||
placeholder="请再次输入新密码"
|
:placeholder="$t('views.profile.placeholder_confirm_password')"
|
||||||
/>
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NButton type="primary" :loading="isLoading" @click="updatePassword"> 修改 </NButton>
|
<NButton type="primary" :loading="isLoading" @click="updatePassword"> {{$t("common.buttons.update")}} </NButton>
|
||||||
</NForm>
|
</NForm>
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
</NTabs>
|
</NTabs>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user