diff --git a/frontend/src/i18n/en_US.js b/frontend/src/i18n/en_US.js index 39e856ed50..8fb701f1d9 100644 --- a/frontend/src/i18n/en_US.js +++ b/frontend/src/i18n/en_US.js @@ -15,6 +15,12 @@ const en_US = { 'prompt': 'Prompt', 'operating': 'Operating', 'input_limit': 'Within {0} and {1} characters', + 'login': 'Sign In', + 'welcome': 'Welcome back, please enter username and password to log in to MeterSphere', + 'username': 'Username', + 'password': 'Password', + 'input_username': 'Please enter username', + 'input_password': 'Please enter password', }, workspace: { 'create': 'Create Workspace', diff --git a/frontend/src/i18n/zh_CN.js b/frontend/src/i18n/zh_CN.js index 265f8f57ad..d9c1bcbda5 100644 --- a/frontend/src/i18n/zh_CN.js +++ b/frontend/src/i18n/zh_CN.js @@ -15,6 +15,12 @@ const zh_CN = { 'prompt': '提示', 'operating': '操作', 'input_limit': '长度在 {0} 到 {1} 个字符', + 'login': '登录', + 'welcome': '欢迎回来,请输入用户名和密码登录MeterSphere', + 'username': '用户名', + 'password': '密码', + 'input_username': '请输入用户名', + 'input_password': '请输入密码', }, workspace: { 'create': '创建工作空间', diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index 6c612a882f..6b395cc0db 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -7,25 +7,27 @@
- 登录 + {{$t('commons.login')}} MeterSphere
- 欢迎回来,请输入用户名和密码登录MeterSphere + {{$t('commons.welcome')}}
- -
- 登录 + + {{$t('commons.login')}}
@@ -48,7 +50,7 @@ export default { name: "Login", data() { - let validateEmail = (rule, value, callback) => { + /*let validateEmail = (rule, value, callback) => { // eslint-disable-next-line no-useless-escape let EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (!EMAIL_REGEX.test(value)) { @@ -56,7 +58,7 @@ } else { callback(); } - }; + };*/ return { form: { username: '', @@ -64,12 +66,11 @@ }, rules: { username: [ - {required: true, message: '请输入邮箱', trigger: 'blur'}, - {validator: validateEmail, trigger: 'blur'} + {required: true, message: this.$t('commons.input_username'), trigger: 'blur'}, ], password: [ - {required: true, message: '请输入密码', trigger: 'blur'}, - {min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur'} + {required: true, message: this.$t('commons.input_password'), trigger: 'blur'}, + {min: 6, max: 20, message: this.$t('commons.input_limit', [6, 20]), trigger: 'blur'} ] }, msg: '', diff --git a/frontend/src/login/login.js b/frontend/src/login/login.js index 030f88b11d..955cb94982 100644 --- a/frontend/src/login/login.js +++ b/frontend/src/login/login.js @@ -1,10 +1,16 @@ import Vue from 'vue'; -import {Button, Col, Form, FormItem, Input, Row} from 'element-ui'; +import ElementUI, {Button, Col, Form, FormItem, Input, Row} from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; import Login from "./Login.vue"; import Ajax from "../common/ajax"; +import i18n from "../i18n/i18n"; Vue.config.productionTip = false; + +Vue.use(ElementUI, { + i18n: (key, value) => i18n.t(key, value) +}); + Vue.use(Row); Vue.use(Col); Vue.use(Form); @@ -13,7 +19,9 @@ Vue.use(Input); Vue.use(Button); Vue.use(Ajax); + new Vue({ el: '#login', + i18n, render: h => h(Login) });