add actions, mutations
This commit is contained in:
@@ -11,13 +11,9 @@
|
||||
<input placeholder="Password" v-model="password">
|
||||
</sui-form-field>
|
||||
<sui-button type="submit" fluid color='teal'>Login</sui-button>
|
||||
<sui-button type="button" @click="go_oauth" class="twitch-button" fluid color='violet'>Login with Twitch</sui-button>
|
||||
</sui-form>
|
||||
</sui-segment>
|
||||
<sui-message>
|
||||
<div class="oauth">
|
||||
or login with <a href="#">twitch</a> ?
|
||||
</div>
|
||||
</sui-message>
|
||||
</div>
|
||||
</sui-container>
|
||||
</template>
|
||||
@@ -31,11 +27,16 @@
|
||||
.oauth {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.twitch-button {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import {mapMutations} from 'vuex'
|
||||
import {mapMutations, mapActions} from 'vuex'
|
||||
import {apiUrl} from '@/tools'
|
||||
export default {
|
||||
name: 'LoginForm',
|
||||
data () {
|
||||
@@ -44,14 +45,25 @@ export default {
|
||||
password: ''
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.checkSession((flag) => {
|
||||
// check login session
|
||||
// true === isLogin
|
||||
console.log(flag)
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['toggleLoading']),
|
||||
...mapActions(['checkSession']),
|
||||
login: function () {
|
||||
console.log('login submit')
|
||||
this.toggleLoading(1)
|
||||
setTimeout(() => {
|
||||
this.toggleLoading(0)
|
||||
}, 1000)
|
||||
},
|
||||
go_oauth: function () {
|
||||
window.location.href = apiUrl.replace(/\/$/, '') + '/twitch/login?tourl=' + encodeURIComponent(window.location.href)
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
|
||||
+2
-3
@@ -1,6 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import mutations from './mutations'
|
||||
import actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
@@ -11,7 +12,5 @@ export default new Vuex.Store({
|
||||
},
|
||||
mutations,
|
||||
getters,
|
||||
actions: {
|
||||
|
||||
}
|
||||
actions
|
||||
})
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
toggleLoading (state, loading = null) {
|
||||
state.loading = !!loading
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user