mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 15:01:23 +08:00
Optimized the front-end login logic
This commit is contained in:
@@ -84,7 +84,7 @@
|
|||||||
import { getCaptchaSrc, login, verifyCaptcha } from '@/utils/auth'
|
import { getCaptchaSrc, login, verifyCaptcha } from '@/utils/auth'
|
||||||
import backShape from '@/assets/svg/back-shape.svg'
|
import backShape from '@/assets/svg/back-shape.svg'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { LOGIN_SUCCESS, PRODUCTION_NAME } from '@/constants/Common.constants'
|
import { LOGIN_SUCCESS, LOGOUT_FAILED, PRODUCTION_NAME } from '@/constants/Common.constants'
|
||||||
import { setToken } from '@/utils/common'
|
import { setToken } from '@/utils/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -151,21 +151,31 @@ export default {
|
|||||||
}
|
}
|
||||||
login(this.userName, this.password).then((res) => {
|
login(this.userName, this.password).then((res) => {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
if (data.code === LOGIN_SUCCESS) {
|
switch (data.code) {
|
||||||
setToken(data.data.token)
|
case LOGIN_SUCCESS:
|
||||||
ElMessage.success({
|
setToken(data.data.token)
|
||||||
dangerouslyUseHTMLString: true,
|
ElMessage.success({
|
||||||
message: '<strong>登录成功</strong>'
|
dangerouslyUseHTMLString: true,
|
||||||
})
|
message: '<strong>登录成功</strong>'
|
||||||
setTimeout(function () {
|
})
|
||||||
_this.$router.push('/')
|
setTimeout(function () {
|
||||||
}, 1500)
|
_this.$router.push('/')
|
||||||
} else {
|
}, 1500)
|
||||||
ElMessage.error({
|
break
|
||||||
dangerouslyUseHTMLString: true,
|
case LOGOUT_FAILED:
|
||||||
message: '<strong>用户名</strong> 或 <strong>密码</strong> 错误'
|
ElMessage.error({
|
||||||
})
|
dangerouslyUseHTMLString: true,
|
||||||
this.resetLogin()
|
message: '<strong>用户名</strong> 或 <strong>密码</strong> 错误'
|
||||||
|
})
|
||||||
|
this.resetLogin()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>服务器出错了</strong>,请稍后重试'
|
||||||
|
})
|
||||||
|
this.resetLogin()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user