1
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
<script>
|
||||
import config from '@/config'
|
||||
import LoginForm from '@component/login-form'
|
||||
import Main from '@component/main'
|
||||
import ParentView from '@component/parent-view'
|
||||
import Page404 from '@/views/error-page/404.vue'
|
||||
import { mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
@@ -39,11 +42,35 @@ export default {
|
||||
LoginForm,
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['handleLogin']),
|
||||
...mapActions('user', ['handleLogin']),
|
||||
async handleSubmit({ userName, password }) {
|
||||
let user = { name: userName, password: password }
|
||||
await this.handleLogin(user)
|
||||
window.location.reload()
|
||||
try {
|
||||
let userFrom = { name: userName, password: password }
|
||||
await this.handleLogin({
|
||||
userFrom,
|
||||
Main,
|
||||
ParentView,
|
||||
Page404
|
||||
})
|
||||
this.$Message.success('登录成功!')
|
||||
window.location.reload()
|
||||
} catch (error) {
|
||||
console.error('登录失败:', error)
|
||||
// 处理不同类型的错误
|
||||
let errorMsg = '登录失败,请检查用户名和密码'
|
||||
|
||||
if (error) {
|
||||
if (typeof error === 'string') {
|
||||
errorMsg = error
|
||||
} else if (error.message) {
|
||||
errorMsg = error.message
|
||||
} else if (error.data && error.data.message) {
|
||||
errorMsg = error.data.message
|
||||
}
|
||||
}
|
||||
|
||||
this.$Message.error(errorMsg)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user