优化登陆逻辑代码

This commit is contained in:
zhl 2021-06-11 11:35:15 +08:00
parent 0c3bc9bc48
commit 885f35851a

View File

@ -173,26 +173,19 @@ export default class extends Vue {
})
}
private handleLogin() {
(this.$refs.loginForm as ElForm).validate(async(valid: boolean) => {
if (valid) {
private async handleLogin() {
try {
await (this.$refs.loginForm as ElForm).validate()
this.loading = true
await UserModule.Login(this.loginForm)
this.$router.push({
await 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(() => {
} catch (err) {
console.warn(err)
this.loading = false
}, 0.5 * 1000)
} else {
return false
}
})
}
private getOtherQuery(query: Dictionary<string>) {