diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 877f0ae..1d83abc 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -173,26 +173,19 @@ export default class extends Vue { }) } - private handleLogin() { - (this.$refs.loginForm as ElForm).validate(async(valid: boolean) => { - if (valid) { - this.loading = true - await UserModule.Login(this.loginForm) - this.$router.push({ - path: this.redirect || '/', - query: this.otherQuery - }).catch(err => { - // console.warn(err) - this.loading = false - }) - // Just to simulate the time of the request - setTimeout(() => { - this.loading = false - }, 0.5 * 1000) - } else { - return false - } - }) + private async handleLogin() { + try { + await (this.$refs.loginForm as ElForm).validate() + this.loading = true + await UserModule.Login(this.loginForm) + await this.$router.push({ + path: this.redirect || '/', + query: this.otherQuery + }) + } catch (err) { + console.warn(err) + this.loading = false + } } private getOtherQuery(query: Dictionary) {