引入socket

This commit is contained in:
lulu
2018-10-23 16:07:51 +08:00
committed by Nova
parent 673e4a11b7
commit 9bedf5dccf
8 changed files with 59 additions and 29 deletions

View File

@@ -1,3 +1,5 @@
import axios from 'axios'
export default {
namespaced: true,
@@ -7,19 +9,20 @@ export default {
{ text: 'chain.thHeight', value: 'height', align: 'center' },
{ text: 'chain.thTimestamp', value: 'timestamp', align: 'center' },
{ text: 'chain.thType', value: 'type', align: 'center' },
{ text: 'chain.thId', value: 'id', align: 'center' },
{ text: 'chain.thHash', value: 'hash', align: 'center' },
],
desserts: [
{
height: '1',
timestamp: '2011-11-20',
type: '0',
id: 'ajlk;gaklewklgjqwejj',
hash: 'null',
},
],
fetching: false,
filter: '',
modal: false,
isConnected: false,
},
mutations: {
@@ -34,9 +37,30 @@ export default {
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: {},
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: {},
}

View File

@@ -47,7 +47,7 @@ export default {
let account = sessionStorage.getItem('KEY_ACCOUNT')
try {
account = JSON.parse(account)
const result = await axios.post('api/Account/getBalance', {
const result = await axios.post('Account/getBalance', {
Account: { address: account.address },
})
commit('updateBalance', result.data || 0)