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=",
|
"integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8=",
|
||||||
"dev": true
|
"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": {
|
"babel-code-frame": {
|
||||||
"version": "6.26.0",
|
"version": "6.26.0",
|
||||||
"resolved": "http://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz",
|
"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",
|
"version": "3.1.0",
|
||||||
"resolved": "http://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
|
"resolved": "http://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
|
||||||
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
|
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ms": "2.0.0"
|
"ms": "2.0.0"
|
||||||
}
|
}
|
||||||
@ -5234,7 +5242,6 @@
|
|||||||
"version": "1.5.2",
|
"version": "1.5.2",
|
||||||
"resolved": "http://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.2.tgz",
|
"resolved": "http://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.2.tgz",
|
||||||
"integrity": "sha1-Wp2A4BZZV+XvDBIQZ4/FxKy5+wM=",
|
"integrity": "sha1-Wp2A4BZZV+XvDBIQZ4/FxKy5+wM=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "3.1.0"
|
"debug": "3.1.0"
|
||||||
}
|
}
|
||||||
@ -6957,8 +6964,7 @@
|
|||||||
"is-buffer": {
|
"is-buffer": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "http://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz",
|
"resolved": "http://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz",
|
||||||
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
|
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-builtin-module": {
|
"is-builtin-module": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -8031,8 +8037,7 @@
|
|||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "http://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
|
"resolved": "http://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"multicast-dns": {
|
"multicast-dns": {
|
||||||
"version": "6.2.3",
|
"version": "6.2.3",
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.18.0",
|
||||||
"semantic-ui-css": "^2.3.3",
|
"semantic-ui-css": "^2.3.3",
|
||||||
"semantic-ui-vue": "^0.2.11",
|
"semantic-ui-vue": "^0.2.11",
|
||||||
"vue": "^2.5.17",
|
"vue": "^2.5.17",
|
||||||
|
@ -11,13 +11,9 @@
|
|||||||
<input placeholder="Password" v-model="password">
|
<input placeholder="Password" v-model="password">
|
||||||
</sui-form-field>
|
</sui-form-field>
|
||||||
<sui-button type="submit" fluid color='teal'>Login</sui-button>
|
<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-form>
|
||||||
</sui-segment>
|
</sui-segment>
|
||||||
<sui-message>
|
|
||||||
<div class="oauth">
|
|
||||||
or login with <a href="#">twitch</a> ?
|
|
||||||
</div>
|
|
||||||
</sui-message>
|
|
||||||
</div>
|
</div>
|
||||||
</sui-container>
|
</sui-container>
|
||||||
</template>
|
</template>
|
||||||
@ -31,11 +27,16 @@
|
|||||||
.oauth {
|
.oauth {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.twitch-button {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapMutations} from 'vuex'
|
import {mapMutations, mapActions} from 'vuex'
|
||||||
|
import {apiUrl} from '@/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'LoginForm',
|
name: 'LoginForm',
|
||||||
data () {
|
data () {
|
||||||
@ -44,14 +45,25 @@ export default {
|
|||||||
password: ''
|
password: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
this.checkSession((flag) => {
|
||||||
|
// check login session
|
||||||
|
// true === isLogin
|
||||||
|
console.log(flag)
|
||||||
|
})
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['toggleLoading']),
|
...mapMutations(['toggleLoading']),
|
||||||
|
...mapActions(['checkSession']),
|
||||||
login: function () {
|
login: function () {
|
||||||
console.log('login submit')
|
console.log('login submit')
|
||||||
this.toggleLoading(1)
|
this.toggleLoading(1)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.toggleLoading(0)
|
this.toggleLoading(0)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
},
|
||||||
|
go_oauth: function () {
|
||||||
|
window.location.href = apiUrl.replace(/\/$/, '') + '/twitch/login?tourl=' + encodeURIComponent(window.location.href)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import mutations from './mutations'
|
import mutations from './mutations'
|
||||||
|
import actions from './actions'
|
||||||
import * as getters from './getters'
|
import * as getters from './getters'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
@ -11,7 +12,5 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
mutations,
|
mutations,
|
||||||
getters,
|
getters,
|
||||||
actions: {
|
actions
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
export default {
|
|
||||||
toggleLoading (state, loading = null) {
|
|
||||||
state.loading = !!loading
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user