引入socket
This commit is contained in:
@@ -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: {},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user