mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-06 04:00:06 +08:00
chore: optimize the code; 🌟
This commit is contained in:
parent
3ff12474cd
commit
687a3adc37
@ -100,22 +100,21 @@ export default {
|
|||||||
this.logging = true
|
this.logging = true
|
||||||
const name = this.form.getFieldValue('name')
|
const name = this.form.getFieldValue('name')
|
||||||
const password = this.form.getFieldValue('password')
|
const password = this.form.getFieldValue('password')
|
||||||
// 登录
|
login(name, password).then(this.afterLogin)
|
||||||
login(name, password)
|
|
||||||
.then((res) => {
|
|
||||||
this.logging = false
|
|
||||||
const result = res.data
|
|
||||||
if (result.code >= 0) {
|
|
||||||
const user = result.data.user
|
|
||||||
this.$router.push('/dashboard/workplace')
|
|
||||||
this.$store.commit('account/setUser', user)
|
|
||||||
this.$message.success(result.message, 3)
|
|
||||||
} else {
|
|
||||||
this.error = result.message
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
afterLogin(res) {
|
||||||
|
this.logging = false
|
||||||
|
const result = res.data
|
||||||
|
if (result.code >= 0) {
|
||||||
|
const user = result.data.user
|
||||||
|
this.$router.push('/dashboard/workplace')
|
||||||
|
this.$store.commit('account/setUser', user)
|
||||||
|
this.$message.success(result.message, 3)
|
||||||
|
} else {
|
||||||
|
this.error = result.message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import {request, METHOD} from '@/utils/request'
|
|||||||
* @param password 账户密码
|
* @param password 账户密码
|
||||||
* @returns {Promise<AxiosResponse<T>>}
|
* @returns {Promise<AxiosResponse<T>>}
|
||||||
*/
|
*/
|
||||||
function login(name, password) {
|
async function login(name, password) {
|
||||||
return request(LOGIN, METHOD.POST, {
|
return request(LOGIN, METHOD.POST, {
|
||||||
name: name,
|
name: name,
|
||||||
password: password
|
password: password
|
||||||
|
@ -6,7 +6,7 @@ const METHOD = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* axios请求函数
|
* axios请求
|
||||||
* @param url 请求地址
|
* @param url 请求地址
|
||||||
* @param method {METHOD} http method
|
* @param method {METHOD} http method
|
||||||
* @param params 请求参数
|
* @param params 请求参数
|
||||||
|
Loading…
x
Reference in New Issue
Block a user