added language switch on login page

This commit is contained in:
Marvin Zhang
2019-08-24 16:56:08 +08:00
parent b4792680df
commit f6069a74fa
4 changed files with 53 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
<svg width="300" height="300" xmlns="http://www.w3.org/2000/svg">
<circle cx="150" cy="150" r="150" fill="#409eff">
</circle>
<circle cx="150" cy="150" r="110" fill="#fff">
</circle>
<circle cx="150" cy="150" r="70" fill="#409eff">
</circle>
<path d="
M 150,150
L 280,225
A 150,150 90 0 0 280,75
" fill="#409eff">
</path>
</svg>

After

Width:  |  Height:  |  Size: 393 B

View File

@@ -214,6 +214,7 @@ export default {
// 下拉框
User: '用户',
Logout: '退出登录',
Documentation: '文档',
// 选择
'Yes': '是',

View File

@@ -30,7 +30,7 @@
<el-dropdown class="documentation right">
<a href="https://tikazyq.github.io/crawlab-docs" target="_blank">
<font-awesome-icon :icon="['far', 'question-circle']"/>
<span style="margin-left: 5px;">文档</span>
<span style="margin-left: 5px;">{{$t('Documentation')}}</span>
</a>
</el-dropdown>
</div>

View File

@@ -4,7 +4,7 @@
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on"
label-position="left">
<h3 class="title">
CRAWLAB
<span><img style="width:48px;margin-bottom:-5px;margin-right:2px" src="../../assets/logo.svg"></span>RAWLAB
</h3>
<el-form-item prop="username" style="margin-bottom: 28px;">
<el-input
@@ -61,11 +61,18 @@
<img src="https://img.shields.io/badge/github-crawlab-blue">
</a>
</div>
<div class="lang">
<span @click="setLang('zh')" :class="lang==='zh'?'active':''">中文</span>
<span @click="setLang('en')" :class="lang==='en'?'active':''">English</span>
</div>
</el-form>
</div>
</template>
<script>
import {
mapState
} from 'vuex'
import { isValidUsername } from '../../utils/validate'
export default {
@@ -109,6 +116,9 @@ export default {
}
},
computed: {
...mapState('lang', [
'lang'
]),
isSignUp () {
return this.$route.path === '/signup'
},
@@ -149,6 +159,11 @@ export default {
onKeyEnter () {
const func = this.isSignUp ? this.handleSignup : this.handleLogin
func()
},
setLang (lang) {
window.localStorage.setItem('lang', lang)
this.$set(this.$i18n, 'locale', lang)
this.$store.commit('lang/SET_LANG', lang)
}
},
mounted () {
@@ -374,6 +389,7 @@ const initCanvas = () => {
color: #409EFF;
margin: 0px auto 20px auto;
text-align: center;
cursor: default;
}
.show-pwd {
@@ -407,5 +423,25 @@ const initCanvas = () => {
font-weight: 600;
}
}
.lang {
margin-top: 20px;
text-align: center;
span {
cursor: pointer;
margin: 10px;
color: #666;
font-size: 14px;
}
span.active {
font-weight: 600;
}
span:hover {
text-decoration: underline;
}
}
}
</style>