feat[login]:add 18n to login form
This commit is contained in:
		@@ -44,5 +44,14 @@ export default {
 | 
				
			|||||||
    theme: 'Theme',
 | 
					    theme: 'Theme',
 | 
				
			||||||
    clipboardDemo: 'Clipboard',
 | 
					    clipboardDemo: 'Clipboard',
 | 
				
			||||||
    i18n: 'I18n'
 | 
					    i18n: 'I18n'
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  login: {
 | 
				
			||||||
 | 
					    title: 'Login Form',
 | 
				
			||||||
 | 
					    logIn: 'Log in',
 | 
				
			||||||
 | 
					    username: 'Username',
 | 
				
			||||||
 | 
					    password: 'Password',
 | 
				
			||||||
 | 
					    any: 'any',
 | 
				
			||||||
 | 
					    thirdparty: 'Or connect with',
 | 
				
			||||||
 | 
					    thirdpartyTips: 'Local can not be simulated, please combine their own business simulation! ! !'
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ const messages = {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const i18n = new VueI18n({
 | 
					const i18n = new VueI18n({
 | 
				
			||||||
  locale: Cookies.get('language') || 'zh', // set locale
 | 
					  locale: Cookies.get('language') || 'en', // set locale
 | 
				
			||||||
  messages // set locale messages
 | 
					  messages // set locale messages
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,5 +44,14 @@ export default {
 | 
				
			|||||||
    theme: '换肤',
 | 
					    theme: '换肤',
 | 
				
			||||||
    clipboardDemo: 'clipboard',
 | 
					    clipboardDemo: 'clipboard',
 | 
				
			||||||
    i18n: '国际化'
 | 
					    i18n: '国际化'
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  login: {
 | 
				
			||||||
 | 
					    title: '系统登录',
 | 
				
			||||||
 | 
					    logIn: '登录',
 | 
				
			||||||
 | 
					    username: '账号',
 | 
				
			||||||
 | 
					    password: '密码',
 | 
				
			||||||
 | 
					    any: '随便填',
 | 
				
			||||||
 | 
					    thirdparty: '第三方登录',
 | 
				
			||||||
 | 
					    thirdpartyTips: '本地不能模拟,请结合自己业务进行模拟!!!'
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					// 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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,22 +1,15 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="login-container">
 | 
					  <div class="login-container">
 | 
				
			||||||
    <el-form class="card-box 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">
 | 
				
			||||||
      <h3 class="title">系统登录</h3>
 | 
					      <div class="title-container">
 | 
				
			||||||
      <el-dropdown trigger="click" class='international' @command="handleSetLanguage">
 | 
					        <h3 class="title">{{ translateKey('title')}}</h3>
 | 
				
			||||||
        <div>
 | 
					        <lang-select class="set-language"></lang-select>
 | 
				
			||||||
          <svg-icon class-name='right-menu-item international-icon' icon-class="language" />
 | 
					      </div>
 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <el-dropdown-menu slot="dropdown">
 | 
					 | 
				
			||||||
          <el-dropdown-item command="zh" :disabled="language==='zh'">中文</el-dropdown-item>
 | 
					 | 
				
			||||||
          <el-dropdown-item command="en" :disabled="language==='en'">English</el-dropdown-item>
 | 
					 | 
				
			||||||
        </el-dropdown-menu>
 | 
					 | 
				
			||||||
      </el-dropdown>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      <el-form-item prop="username">
 | 
					      <el-form-item prop="username">
 | 
				
			||||||
        <span class="svg-container svg-container_login">
 | 
					        <span class="svg-container svg-container_login">
 | 
				
			||||||
          <svg-icon icon-class="user" />
 | 
					          <svg-icon icon-class="user" />
 | 
				
			||||||
        </span>
 | 
					        </span>
 | 
				
			||||||
        <el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="邮箱" />
 | 
					        <el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="username" />
 | 
				
			||||||
      </el-form-item>
 | 
					      </el-form-item>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <el-form-item prop="password">
 | 
					      <el-form-item prop="password">
 | 
				
			||||||
@@ -24,21 +17,31 @@
 | 
				
			|||||||
          <svg-icon icon-class="password" />
 | 
					          <svg-icon icon-class="password" />
 | 
				
			||||||
        </span>
 | 
					        </span>
 | 
				
			||||||
        <el-input name="password" :type="pwdType" @keyup.enter.native="handleLogin" v-model="loginForm.password" autoComplete="on"
 | 
					        <el-input name="password" :type="pwdType" @keyup.enter.native="handleLogin" v-model="loginForm.password" autoComplete="on"
 | 
				
			||||||
          placeholder="密码" />
 | 
					          placeholder="password" />
 | 
				
			||||||
        <span class="show-pwd" @click="showPwd"><svg-icon icon-class="eye" /></span>
 | 
					        <span class="show-pwd" @click="showPwd">
 | 
				
			||||||
 | 
					          <svg-icon icon-class="eye" />
 | 
				
			||||||
 | 
					        </span>
 | 
				
			||||||
      </el-form-item>
 | 
					      </el-form-item>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">登录</el-button>
 | 
					      <el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">{{translateKey('logIn')}}</el-button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="tips">账号:admin 密码随便填</div>
 | 
					      <div class="tips">
 | 
				
			||||||
      <div class="tips">账号:editor  密码随便填</div>
 | 
					        <span>{{translateKey('username')}} : admin</span>
 | 
				
			||||||
 | 
					        <span>{{translateKey('password')}} : {{translateKey('any')}}</span>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					      <div class="tips">
 | 
				
			||||||
 | 
					        <span>{{translateKey('username')}} : editor </span>
 | 
				
			||||||
 | 
					        <span>{{translateKey('password')}} : {{translateKey('any')}}</span>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <el-button class="thirdparty-button" type="primary" @click="showDialog=true">打开第三方登录</el-button>
 | 
					      <el-button class="thirdparty-button" type="primary" @click="showDialog=true">{{translateKey('thirdparty')}}</el-button>
 | 
				
			||||||
    </el-form>
 | 
					    </el-form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <el-dialog title="第三方验证" :visible.sync="showDialog">
 | 
					    <el-dialog :title="translateKey('thirdparty')" :visible.sync="showDialog">
 | 
				
			||||||
      本地不能模拟,请结合自己业务进行模拟!!!<br/><br/><br/>
 | 
					      {{translateKey('thirdpartyTips')}}
 | 
				
			||||||
      邮箱登录成功,请选择第三方验证<br/>
 | 
					      <br/>
 | 
				
			||||||
 | 
					      <br/>
 | 
				
			||||||
 | 
					      <br/>
 | 
				
			||||||
      <social-sign />
 | 
					      <social-sign />
 | 
				
			||||||
    </el-dialog>
 | 
					    </el-dialog>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,22 +50,23 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import { isvalidUsername } from '@/utils/validate'
 | 
					import { isvalidUsername } from '@/utils/validate'
 | 
				
			||||||
 | 
					import LangSelect from '@/components/LangSelect'
 | 
				
			||||||
import socialSign from './socialsignin'
 | 
					import socialSign from './socialsignin'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  components: { socialSign },
 | 
					  components: { LangSelect, socialSign },
 | 
				
			||||||
  name: 'login',
 | 
					  name: 'login',
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
    const validateUsername = (rule, value, callback) => {
 | 
					    const validateUsername = (rule, value, callback) => {
 | 
				
			||||||
      if (!isvalidUsername(value)) {
 | 
					      if (!isvalidUsername(value)) {
 | 
				
			||||||
        callback(new Error('请输入正确的用户名'))
 | 
					        callback(new Error('Please enter the correct user name'))
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        callback()
 | 
					        callback()
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const validatePassword = (rule, value, callback) => {
 | 
					    const validatePassword = (rule, value, callback) => {
 | 
				
			||||||
      if (value.length < 6) {
 | 
					      if (value.length < 6) {
 | 
				
			||||||
        callback(new Error('密码不能小于6位'))
 | 
					        callback(new Error('The password can not be less than 6 digits'))
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        callback()
 | 
					        callback()
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -82,6 +86,9 @@ 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 = ''
 | 
				
			||||||
@@ -135,19 +142,15 @@ export default {
 | 
				
			|||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style rel="stylesheet/scss" lang="scss">
 | 
					<style rel="stylesheet/scss" lang="scss">
 | 
				
			||||||
  @import "src/styles/mixin.scss";
 | 
					$bg:#2d3a4b;
 | 
				
			||||||
  $bg:#2d3a4b;
 | 
					$light_gray:#eee;
 | 
				
			||||||
  $dark_gray:#889aa4;
 | 
					 | 
				
			||||||
  $light_gray:#eee;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .login-container {
 | 
					/* reset element-ui css */
 | 
				
			||||||
    @include relative;
 | 
					.login-container {
 | 
				
			||||||
    height: 100vh;
 | 
					  .el-input {
 | 
				
			||||||
    background-color: $bg;
 | 
					    display: inline-block;
 | 
				
			||||||
    input:-webkit-autofill {
 | 
					    height: 47px;
 | 
				
			||||||
      -webkit-box-shadow: 0 0 0px 1000px #293444 inset !important;
 | 
					    width: 85%;
 | 
				
			||||||
      -webkit-text-fill-color: #fff !important;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    input {
 | 
					    input {
 | 
				
			||||||
      background: transparent;
 | 
					      background: transparent;
 | 
				
			||||||
      border: 0px;
 | 
					      border: 0px;
 | 
				
			||||||
@@ -156,27 +159,62 @@ export default {
 | 
				
			|||||||
      padding: 12px 5px 12px 15px;
 | 
					      padding: 12px 5px 12px 15px;
 | 
				
			||||||
      color: $light_gray;
 | 
					      color: $light_gray;
 | 
				
			||||||
      height: 47px;
 | 
					      height: 47px;
 | 
				
			||||||
    }
 | 
					      &:-webkit-autofill {
 | 
				
			||||||
    .el-input {
 | 
					        -webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
 | 
				
			||||||
      display: inline-block;
 | 
					        -webkit-text-fill-color: #fff !important;
 | 
				
			||||||
      height: 47px;
 | 
					 | 
				
			||||||
      width: 85%;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    .tips {
 | 
					 | 
				
			||||||
      font-size: 14px;
 | 
					 | 
				
			||||||
      color: #fff;
 | 
					 | 
				
			||||||
      margin-bottom: 10px;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    .svg-container {
 | 
					 | 
				
			||||||
      padding: 6px 5px 6px 15px;
 | 
					 | 
				
			||||||
      color: $dark_gray;
 | 
					 | 
				
			||||||
      vertical-align: middle;
 | 
					 | 
				
			||||||
      width: 30px;
 | 
					 | 
				
			||||||
      display: inline-block;
 | 
					 | 
				
			||||||
      &_login {
 | 
					 | 
				
			||||||
        font-size: 20px;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .el-form-item {
 | 
				
			||||||
 | 
					    border: 1px solid rgba(255, 255, 255, 0.1);
 | 
				
			||||||
 | 
					    background: rgba(0, 0, 0, 0.1);
 | 
				
			||||||
 | 
					    border-radius: 5px;
 | 
				
			||||||
 | 
					    color: #454545;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style rel="stylesheet/scss" lang="scss" scoped>
 | 
				
			||||||
 | 
					@import "src/styles/mixin.scss";
 | 
				
			||||||
 | 
					$bg:#2d3a4b;
 | 
				
			||||||
 | 
					$dark_gray:#889aa4;
 | 
				
			||||||
 | 
					$light_gray:#eee;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.login-container {
 | 
				
			||||||
 | 
					  @include relative;
 | 
				
			||||||
 | 
					  height: 100vh;
 | 
				
			||||||
 | 
					  background-color: $bg;
 | 
				
			||||||
 | 
					  .login-form {
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    left: 0;
 | 
				
			||||||
 | 
					    right: 0;
 | 
				
			||||||
 | 
					    width: 520px;
 | 
				
			||||||
 | 
					    padding: 35px 35px 15px 35px;
 | 
				
			||||||
 | 
					    margin: 120px auto;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .tips {
 | 
				
			||||||
 | 
					    font-size: 14px;
 | 
				
			||||||
 | 
					    color: #fff;
 | 
				
			||||||
 | 
					    margin-bottom: 10px;
 | 
				
			||||||
 | 
					    span {
 | 
				
			||||||
 | 
					      &:first-of-type {
 | 
				
			||||||
 | 
					        margin-right: 16px;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .svg-container {
 | 
				
			||||||
 | 
					    padding: 6px 5px 6px 15px;
 | 
				
			||||||
 | 
					    color: $dark_gray;
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
 | 
					    width: 30px;
 | 
				
			||||||
 | 
					    display: inline-block;
 | 
				
			||||||
 | 
					    &_login {
 | 
				
			||||||
 | 
					      font-size: 20px;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .title-container {
 | 
				
			||||||
 | 
					    position: relative;
 | 
				
			||||||
    .title {
 | 
					    .title {
 | 
				
			||||||
      font-size: 26px;
 | 
					      font-size: 26px;
 | 
				
			||||||
      font-weight: 400;
 | 
					      font-weight: 400;
 | 
				
			||||||
@@ -185,33 +223,26 @@ export default {
 | 
				
			|||||||
      text-align: center;
 | 
					      text-align: center;
 | 
				
			||||||
      font-weight: bold;
 | 
					      font-weight: bold;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    .login-form {
 | 
					    .set-language {
 | 
				
			||||||
 | 
					      color: #fff;
 | 
				
			||||||
      position: absolute;
 | 
					      position: absolute;
 | 
				
			||||||
      left: 0;
 | 
					      top: 5px;
 | 
				
			||||||
      right: 0;
 | 
					      right: 0px;
 | 
				
			||||||
      width: 400px;
 | 
					 | 
				
			||||||
      padding: 35px 35px 15px 35px;
 | 
					 | 
				
			||||||
      margin: 120px auto;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    .el-form-item {
 | 
					 | 
				
			||||||
      border: 1px solid rgba(255, 255, 255, 0.1);
 | 
					 | 
				
			||||||
      background: rgba(0, 0, 0, 0.1);
 | 
					 | 
				
			||||||
      border-radius: 5px;
 | 
					 | 
				
			||||||
      color: #454545;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    .show-pwd {
 | 
					 | 
				
			||||||
      position: absolute;
 | 
					 | 
				
			||||||
      right: 10px;
 | 
					 | 
				
			||||||
      top: 7px;
 | 
					 | 
				
			||||||
      font-size: 16px;
 | 
					 | 
				
			||||||
      color: $dark_gray;
 | 
					 | 
				
			||||||
      cursor: pointer;
 | 
					 | 
				
			||||||
      user-select:none;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    .thirdparty-button{
 | 
					 | 
				
			||||||
      position: absolute;
 | 
					 | 
				
			||||||
      right: 35px;
 | 
					 | 
				
			||||||
      bottom: 28px;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  .show-pwd {
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    right: 10px;
 | 
				
			||||||
 | 
					    top: 7px;
 | 
				
			||||||
 | 
					    font-size: 16px;
 | 
				
			||||||
 | 
					    color: $dark_gray;
 | 
				
			||||||
 | 
					    cursor: pointer;
 | 
				
			||||||
 | 
					    user-select: none;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .thirdparty-button {
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    right: 35px;
 | 
				
			||||||
 | 
					    bottom: 28px;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
</style>
 | 
					</style>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user