integrated vuejs into theme (builded with webpack

This commit is contained in:
2019-04-09 00:21:00 +02:00
parent c344c09c96
commit 9dfc5af5c0
22 changed files with 14317 additions and 23 deletions

View File

@@ -0,0 +1,12 @@
import Vue from 'vue'
import Vuex from 'vuex'
import User from './modules/user'
// https://github.com/vuejs/vuex/tree/dev/examples/shopping-cart
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
User
}
})

View File

@@ -0,0 +1,59 @@
import { HTTP } from 'vuejs/rest/http-axios'
export default {
namespaced: true,
// initial state
state : {
isloggedin: false,
username: '',
token: null
},
// getters
getters : {},
// mutations
mutations : {
// setUser (state, posts) {
// state.all = posts
// }
// setOpened (state, post) {
// state.opened = post
// },
// clearOpened (state) {
// state.opened = null
// }
},
// actions
actions : {
getToken ({ commit, state }, data) {
// console.log('getToken data', data)
let config = {
headers: {
"Content-Type": "application/json"
}
}
// console.log('data', data)
// console.log('config', config)
HTTP.post('/user/login?_format=json', data, config)
.then(response => {
console.log('response', response)
// cb(response.data)
})
.catch(({ error }) => {
console.log('Issue with login', error);
Promise.reject(error);
})
}
// ,
// logout ({ commit }) {
//
// }
}
}