This repository was archived by the owner on May 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55</template >
66
77<script >
8-
98export default {
109 name: ' home'
1110}
Original file line number Diff line number Diff line change @@ -68,13 +68,8 @@ export default {
6868 onSubmit () {
6969 this .$refs .login .validate (isValid => {
7070 if (! isValid) return
71- this .loading = true
72- // this.pushLogin({
73- // userInfo: this.loginForm,
74- // replace: this.$router.replace.bind(this.$router)
75- // })
76- // .finally(() => { this.loading = false })
77- this .$router .push (' /' )
71+ this .$store .dispatch (' login/userLogin' , this .userInfo )
72+ .then (() => this .$router .push (' /' ))
7873 })
7974 }
8075 }
Original file line number Diff line number Diff line change 11import login from './login'
22
33export default {
4- login : {
5- namespaced : true ,
6- ...login
7- }
4+ login
85}
Original file line number Diff line number Diff line change 1+ import { userLogin } from 'API'
2+ import types from './mutations/types'
3+
4+ export default {
5+ userLogin ( { commit } , { username, password } ) {
6+ return userLogin ( {
7+ username,
8+ password
9+ } )
10+ . then ( res => {
11+ commit ( types . SET_USERNAME , username )
12+ commit ( types . SET_ACCESS_TOKEN , res . access_token )
13+ } )
14+ . catch ( console . error )
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ import state from './state'
2+ import mutations from './mutations'
3+ import actions from './actions'
4+
15export default {
2- state : { } ,
3- getters : { } ,
4- mutations : { } ,
5- actions : { }
6+ namespaced : true ,
7+ state ,
8+ mutations,
9+ actions
610}
Original file line number Diff line number Diff line change 1+ import types from './types'
2+
3+ export default {
4+ [ types . SET_USERNAME ] ( state , username ) {
5+ state . username = username
6+ } ,
7+ [ types . SET_ACCESS_TOKEN ] ( state , accessToken ) {
8+ state . accessToken = accessToken
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ export default {
2+ SET_USERNAME : 'SET_USERNAME' ,
3+ SET_ACCESS_TOKEN : 'SET_ACCESS_TOKEN'
4+ }
Original file line number Diff line number Diff line change 1+ export default {
2+ username : '' ,
3+ accessToken : ''
4+ }
You can’t perform that action at this time.
0 commit comments