perf[i18n]: direct use $t

This commit is contained in:
Pan 2017-12-28 11:43:12 +08:00
parent d22165ebad
commit 9b246ee444
10 changed files with 36 additions and 48 deletions

View File

@ -48,7 +48,7 @@
**本项目并不是一个脚手架,更倾向于是一个集成解决方案** **本项目并不是一个脚手架,更倾向于是一个集成解决方案**
**该项目不支持低版本览器(如ie)有需求请自行添加polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)** **该项目不支持低版本览器(如ie)有需求请自行添加polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)**
<p align="center"> <p align="center">
<img width="900" src="https://wpimg.wallstcn.com/a5894c1b-f6af-456e-82df-1151da0839bf.png"> <img width="900" src="https://wpimg.wallstcn.com/a5894c1b-f6af-456e-82df-1151da0839bf.png">

View File

@ -66,8 +66,8 @@ export default {
github: 'Github Repository' github: 'Github Repository'
}, },
permission: { permission: {
permissions: 'Your permissions', roles: 'Your roles',
switchPermissions: 'Switch permissions' switchRoles: 'Switch roles'
}, },
components: { components: {
documentation: 'Documentation', documentation: 'Documentation',

View File

@ -66,8 +66,8 @@ export default {
github: 'Github 地址' github: 'Github 地址'
}, },
permission: { permission: {
permissions: '你的权限', roles: '你的权限',
switchPermissions: '切换权限' switchRoles: '切换权限'
}, },
components: { components: {
documentation: '文档', documentation: '文档',

View File

@ -9,6 +9,10 @@ Vue.use(Router)
/* Layout */ /* Layout */
import Layout from '../views/layout/Layout' import Layout from '../views/layout/Layout'
/** note: submenu only apppear when children.length>=1
* detail see https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/
/** /**
* hidden: true if `hidden:true` will not show in the sidebar(default is false) * hidden: true if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb

View File

@ -1,4 +1,4 @@
// translate router.meta.title , be used in breadcrumb sidebar tagsview // translate router.meta.title, be used in breadcrumb sidebar tagsview
export function generateTitle(title) { export function generateTitle(title) {
return this.$t('route.' + title) // $t :this method from vue-i18n ,inject in @/lang/index.js return this.$t('route.' + title) // $t :this method from vue-i18n, inject in @/lang/index.js
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container documentation-container"> <div class="app-container documentation-container">
<a class="document-btn" target='_blank' href="https://panjiachen.github.io/vue-element-admin-site/#/">{{translateKey('documentation')}}</a> <a class="document-btn" target='_blank' href="https://panjiachen.github.io/vue-element-admin-site/#/">{{$t('documentation.documentation')}}</a>
<a class="document-btn" target='_blank' href="https://github.com/PanJiaChen/vue-element-admin/">{{translateKey('github')}}</a> <a class="document-btn" target='_blank' href="https://github.com/PanJiaChen/vue-element-admin/">{{$t('documentation.github')}}</a>
<dropdown-menu style="float:left;margin-left:50px;" title='系列文章' :items='articleList'></dropdown-menu> <dropdown-menu style="float:left;margin-left:50px;" title='系列文章' :items='articleList'></dropdown-menu>
</div> </div>
</template> </template>
@ -22,11 +22,6 @@ export default {
{ title: '优雅的使用 icon', href: 'https://segmentfault.com/a/https://segmentfault.com/a/1190000012213278' } { title: '优雅的使用 icon', href: 'https://segmentfault.com/a/https://segmentfault.com/a/1190000012213278' }
] ]
} }
},
methods: {
translateKey(key) {
return this.$t('documentation.' + key)
}
} }
} }
</script> </script>

View File

@ -7,13 +7,13 @@
<div class="right-menu"> <div class="right-menu">
<error-log class="errLog-container right-menu-item"></error-log> <error-log class="errLog-container right-menu-item"></error-log>
<el-tooltip effect="dark" :content="translateKey('screenfull')" placement="bottom"> <el-tooltip effect="dark" :content="$t('navbar.screenfull')" placement="bottom">
<screenfull class="screenfull right-menu-item"></screenfull> <screenfull class="screenfull right-menu-item"></screenfull>
</el-tooltip> </el-tooltip>
<lang-select class="international right-menu-item"></lang-select> <lang-select class="international right-menu-item"></lang-select>
<el-tooltip effect="dark" :content="translateKey('theme')" placement="bottom"> <el-tooltip effect="dark" :content="$t('navbar.theme')" placement="bottom">
<theme-picker class="theme-switch right-menu-item"></theme-picker> <theme-picker class="theme-switch right-menu-item"></theme-picker>
</el-tooltip> </el-tooltip>
@ -25,16 +25,16 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<router-link to="/"> <router-link to="/">
<el-dropdown-item> <el-dropdown-item>
{{translateKey('dashboard')}} {{$t('navbar.dashboard')}}
</el-dropdown-item> </el-dropdown-item>
</router-link> </router-link>
<a target='_blank' href="https://github.com/PanJiaChen/vue-element-admin/"> <a target='_blank' href="https://github.com/PanJiaChen/vue-element-admin/">
<el-dropdown-item> <el-dropdown-item>
{{translateKey('github')}} {{$t('navbar.github')}}
</el-dropdown-item> </el-dropdown-item>
</a> </a>
<el-dropdown-item divided> <el-dropdown-item divided>
<span @click="logout" style="display:block;">{{translateKey('logOut')}}</span> <span @click="logout" style="display:block;">{{$t('navbar.logOut')}}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -75,9 +75,6 @@ export default {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.reload()// vue-router bug location.reload()// vue-router bug
}) })
},
translateKey(key) {
return this.$t('navbar.' + key)
} }
} }
} }

View File

@ -2,7 +2,7 @@
<div class="login-container"> <div class="login-container">
<el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left"> <el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left">
<div class="title-container"> <div class="title-container">
<h3 class="title">{{ translateKey('title')}}</h3> <h3 class="title">{{$t('login.title')}}</h3>
<lang-select class="set-language"></lang-select> <lang-select class="set-language"></lang-select>
</div> </div>
<el-form-item prop="username"> <el-form-item prop="username">
@ -23,22 +23,22 @@
</span> </span>
</el-form-item> </el-form-item>
<el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">{{translateKey('logIn')}}</el-button> <el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">{{$t('login.logIn')}}</el-button>
<div class="tips"> <div class="tips">
<span>{{translateKey('username')}} : admin</span> <span>{{$t('login.username')}} : admin</span>
<span>{{translateKey('password')}} : {{translateKey('any')}}</span> <span>{{$t('login.password')}} : {{$t('login.any')}}</span>
</div> </div>
<div class="tips"> <div class="tips">
<span>{{translateKey('username')}} : editor </span> <span>{{$t('login.username')}} : editor </span>
<span>{{translateKey('password')}} : {{translateKey('any')}}</span> <span>{{$t('login.password')}} : {{$t('login.any')}}</span>
</div> </div>
<el-button class="thirdparty-button" type="primary" @click="showDialog=true">{{translateKey('thirdparty')}}</el-button> <el-button class="thirdparty-button" type="primary" @click="showDialog=true">{{$t('login.thirdparty')}}</el-button>
</el-form> </el-form>
<el-dialog :title="translateKey('thirdparty')" :visible.sync="showDialog"> <el-dialog :title="$t('login.thirdparty')" :visible.sync="showDialog">
{{translateKey('thirdpartyTips')}} {{$t('login.thirdpartyTips')}}
<br/> <br/>
<br/> <br/>
<br/> <br/>
@ -86,9 +86,6 @@ export default {
} }
}, },
methods: { methods: {
translateKey(key) {
return this.$t('login.' + key)
},
showPwd() { showPwd() {
if (this.pwdType === 'password') { if (this.pwdType === 'password') {
this.pwdType = '' this.pwdType = ''

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div style="margin-bottom:15px;">{{translateKey('permissions')}} {{roles}}</div> <div style="margin-bottom:15px;">{{$t('permission.roles')}} {{roles}}</div>
{{translateKey('switchPermissions')}} {{$t('permission.switchRoles')}}
<el-radio-group v-model="role"> <el-radio-group v-model="role">
<el-radio-button label="editor"></el-radio-button> <el-radio-button label="editor"></el-radio-button>
</el-radio-group> </el-radio-group>
@ -29,11 +29,6 @@ export default{
this.$router.push({ path: '/permission/index?' + +new Date() }) this.$router.push({ path: '/permission/index?' + +new Date() })
}) })
} }
},
methods: {
translateKey(key) {
return this.$t('permission.' + key)
}
} }
} }
</script> </script>