Compare commits

...

2 Commits

Author SHA1 Message Date
MaYuanhai 1592a0a364 perf[Login]: optimize input focus interaction (#1798) 2019-04-01 17:39:01 +08:00
Pan 53f1820d09 fix[Mock]: fixed mock bug 2019-04-01 17:38:44 +08:00
2 changed files with 16 additions and 2 deletions

View File

@ -11,7 +11,9 @@ Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() { Mock.XHR.prototype.send = function() {
if (this.custom.xhr) { if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false this.custom.xhr.withCredentials = this.withCredentials || false
this.custom.xhr.responseType = this.responseType if (this.responseType) {
this.custom.xhr.responseType = this.responseType
}
} }
this.proxy_send(...arguments) this.proxy_send(...arguments)
} }

View File

@ -13,6 +13,7 @@
<svg-icon icon-class="user" /> <svg-icon icon-class="user" />
</span> </span>
<el-input <el-input
ref="username"
v-model="loginForm.username" v-model="loginForm.username"
:placeholder="$t('login.username')" :placeholder="$t('login.username')"
name="username" name="username"
@ -26,6 +27,7 @@
<svg-icon icon-class="password" /> <svg-icon icon-class="password" />
</span> </span>
<el-input <el-input
ref="password"
v-model="loginForm.password" v-model="loginForm.password"
:type="passwordType" :type="passwordType"
:placeholder="$t('login.password')" :placeholder="$t('login.password')"
@ -96,7 +98,7 @@ export default {
return { return {
loginForm: { loginForm: {
username: 'admin', username: 'admin',
password: '1111111' password: '111111'
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }], username: [{ required: true, trigger: 'blur', validator: validateUsername }],
@ -119,6 +121,13 @@ export default {
created() { created() {
// window.addEventListener('hashchange', this.afterQRScan) // window.addEventListener('hashchange', this.afterQRScan)
}, },
mounted() {
if (this.loginForm.username === '') {
this.$refs.username.focus()
} else if (this.loginForm.password === '') {
this.$refs.password.focus()
}
},
destroyed() { destroyed() {
// window.removeEventListener('hashchange', this.afterQRScan) // window.removeEventListener('hashchange', this.afterQRScan)
}, },
@ -129,6 +138,9 @@ export default {
} else { } else {
this.passwordType = 'password' this.passwordType = 'password'
} }
this.$nextTick(() => {
this.$refs.password.focus()
})
}, },
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {