add actions, mutations
This commit is contained in:
parent
06e2bfded6
commit
218721bc15
17
package-lock.json
generated
17
package-lock.json
generated
@ -1906,6 +1906,15 @@
|
||||
"integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8=",
|
||||
"dev": true
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
|
||||
"integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.2",
|
||||
"is-buffer": "1.1.6"
|
||||
}
|
||||
},
|
||||
"babel-code-frame": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "http://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz",
|
||||
@ -3704,7 +3713,6 @@
|
||||
"version": "3.1.0",
|
||||
"resolved": "http://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
|
||||
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
@ -5234,7 +5242,6 @@
|
||||
"version": "1.5.2",
|
||||
"resolved": "http://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.2.tgz",
|
||||
"integrity": "sha1-Wp2A4BZZV+XvDBIQZ4/FxKy5+wM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "3.1.0"
|
||||
}
|
||||
@ -6957,8 +6964,7 @@
|
||||
"is-buffer": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "http://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz",
|
||||
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
|
||||
"dev": true
|
||||
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
|
||||
},
|
||||
"is-builtin-module": {
|
||||
"version": "1.0.0",
|
||||
@ -8031,8 +8037,7 @@
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "http://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"multicast-dns": {
|
||||
"version": "6.2.3",
|
||||
|
@ -8,6 +8,7 @@
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"semantic-ui-css": "^2.3.3",
|
||||
"semantic-ui-vue": "^0.2.11",
|
||||
"vue": "^2.5.17",
|
||||
|
@ -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 () {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user