引入socket
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
<td>{{ props.item.height }}</td>
|
||||
<td>{{ props.item.timestamp }}</td>
|
||||
<td>{{ props.item.type }}</td>
|
||||
<td>{{ props.item.id }}</td>
|
||||
<td>{{ props.item.hash }}</td>
|
||||
</template>
|
||||
<template slot="no-results">
|
||||
{{ $t('chain.tableNone') }}
|
||||
@@ -64,7 +64,7 @@
|
||||
<td>{{ props.item.height }}</td>
|
||||
<td>{{ props.item.timestamp }}</td>
|
||||
<td>{{ props.item.type }}</td>
|
||||
<td>{{ props.item.id }}</td>
|
||||
<td>{{ props.item.hash }}</td>
|
||||
</template>
|
||||
<template slot="no-results">
|
||||
{{ $t('chain.tableNone') }}
|
||||
@@ -85,17 +85,16 @@ import {
|
||||
createNamespacedHelpers,
|
||||
} from 'vuex'
|
||||
|
||||
import Vue from 'vue'
|
||||
import store from '../store'
|
||||
import VueSocketio from 'vue-socket.io'
|
||||
import io from 'socket.io-client'
|
||||
const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('chain')
|
||||
Vue.use(VueSocketio, io('http://localhost:6842'), store)
|
||||
|
||||
export default {
|
||||
name: 'Chain',
|
||||
|
||||
data(){
|
||||
return {
|
||||
blockList:[],
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState([
|
||||
'headers',
|
||||
@@ -107,23 +106,28 @@ export default {
|
||||
]),
|
||||
...mapGetters([]),
|
||||
},
|
||||
|
||||
created: async function(){
|
||||
let result=await axios({
|
||||
method:'post',
|
||||
url:location.protocol+'//'+location.hostname+':6842/api/Block/getBlockList',
|
||||
data: {config:{order:'height DESC'}}
|
||||
})
|
||||
this.blockList=result.data||[]
|
||||
sockets: {
|
||||
connect() {
|
||||
console.log('socket connected')
|
||||
},
|
||||
newBlock(msg) {
|
||||
this.addNewBlock(msg)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.queryBlockList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions([
|
||||
'queryBlockList',
|
||||
'addNewBlock',
|
||||
]),
|
||||
...mapMutations([
|
||||
'inputFilter',
|
||||
'showModal',
|
||||
'hideModal',
|
||||
'addDesserts',
|
||||
]),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ export default {
|
||||
sideSelected: this.$route.path,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState([
|
||||
'sideMenus',
|
||||
@@ -71,7 +70,9 @@ export default {
|
||||
'isLogin',
|
||||
]),
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
...mapMutations([
|
||||
'updateRoute',
|
||||
|
||||
Reference in New Issue
Block a user