Files
vic-team-vue/src/store/modules/chain.js
2018-10-26 11:24:36 +08:00

67 lines
1.4 KiB
JavaScript

import axios from 'axios'
export default {
namespaced: true,
state: {
pageEntity: [5, 10, 25],
headers: [
{ text: 'chain.thHeight', value: 'height', align: 'center' },
{ text: 'chain.thTimestamp', value: 'timestamp', align: 'center' },
{ text: 'chain.thType', value: 'type', align: 'center' },
{ text: 'chain.thHash', value: 'hash', align: 'center' },
],
desserts: [
{
height: '1',
timestamp: '2011-11-20',
type: '0',
hash: 'null',
},
],
fetching: false,
filter: '',
modal: false,
isConnected: false,
},
mutations: {
inputFilter(state, filter) {
state.filter = filter
},
showModal(state) {
state.modal = true
},
hideModal(state) {
state.modal = false
},
updateDesserts(state, blockList) {
state.desserts = blockList
},
addDesserts(state, block) {
state.desserts.push(block)
},
SOCKET_CONNECT(state, status) {
state.isConnected = true
},
},
actions: {
async queryBlockList({ state, commit }) {
let result = await axios.post('Block/getBlockList', { config: { order: 'height DESC' } })
commit('updateDesserts', result.data || [])
},
addNewBlock({ state, commit }, block) {
console.log(block)
commit('addDesserts', JSON.parse(block))
},
},
getters: {},
}