引入socket
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
"vue-axios": "^2.1.3",
|
"vue-axios": "^2.1.3",
|
||||||
"vue-i18n": "^8.1.0",
|
"vue-i18n": "^8.1.0",
|
||||||
"vue-router": "^3.0.1",
|
"vue-router": "^3.0.1",
|
||||||
|
"vue-socket.io": "^2.1.1-b",
|
||||||
"vuetify": "^1.2.5",
|
"vuetify": "^1.2.5",
|
||||||
"vuex": "^3.0.1"
|
"vuex": "^3.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ export default {
|
|||||||
tableNone: '暂无数据',
|
tableNone: '暂无数据',
|
||||||
},
|
},
|
||||||
chain: {
|
chain: {
|
||||||
tableHeader: '区块列表',
|
tableHeader: 'Block List',
|
||||||
searchHolder: '请输入该输入的',
|
searchHolder: '请输入该输入的',
|
||||||
thHeight: '区块高度',
|
thHeight: 'Height',
|
||||||
thTimestamp: '时间戳',
|
thTimestamp: 'Timestamp',
|
||||||
thType: '区块类型',
|
thType: 'Type',
|
||||||
thId: '区块 ID',
|
thHash: 'Hash',
|
||||||
tableNone: '暂无数据',
|
tableNone: '暂无数据',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ export default {
|
|||||||
},
|
},
|
||||||
chain: {
|
chain: {
|
||||||
tableHeader: '区块列表',
|
tableHeader: '区块列表',
|
||||||
searchHolder: '请输入该输入的',
|
searchHolder: '输入要查询的区块高度或者区块哈希',
|
||||||
thHeight: '区块高度',
|
thHeight: '区块高度',
|
||||||
thTimestamp: '时间戳',
|
thTimestamp: '时间戳',
|
||||||
thType: '区块类型',
|
thType: '区块类型',
|
||||||
thId: '区块 ID',
|
thHash: '区块哈希',
|
||||||
tableNone: '暂无数据',
|
tableNone: '暂无数据',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import app from './app'
|
import app from './app'
|
||||||
|
|
||||||
axios.defaults.baseURL = app.dev ? 'http://localhost:6842/' : 'http://test-sg.bittic.net:6842/'
|
axios.defaults.baseURL = app.dev ? 'http://test-jp.bittic.net:6842/api/' : 'http://test-sg.bittic.net:6842/api/'
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
|
|
||||||
@@ -7,19 +9,20 @@ export default {
|
|||||||
{ text: 'chain.thHeight', value: 'height', align: 'center' },
|
{ text: 'chain.thHeight', value: 'height', align: 'center' },
|
||||||
{ text: 'chain.thTimestamp', value: 'timestamp', align: 'center' },
|
{ text: 'chain.thTimestamp', value: 'timestamp', align: 'center' },
|
||||||
{ text: 'chain.thType', value: 'type', align: 'center' },
|
{ text: 'chain.thType', value: 'type', align: 'center' },
|
||||||
{ text: 'chain.thId', value: 'id', align: 'center' },
|
{ text: 'chain.thHash', value: 'hash', align: 'center' },
|
||||||
],
|
],
|
||||||
desserts: [
|
desserts: [
|
||||||
{
|
{
|
||||||
height: '1',
|
height: '1',
|
||||||
timestamp: '2011-11-20',
|
timestamp: '2011-11-20',
|
||||||
type: '0',
|
type: '0',
|
||||||
id: 'ajlk;gaklewklgjqwejj',
|
hash: 'null',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
fetching: false,
|
fetching: false,
|
||||||
filter: '',
|
filter: '',
|
||||||
modal: false,
|
modal: false,
|
||||||
|
isConnected: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -34,9 +37,30 @@ export default {
|
|||||||
hideModal(state) {
|
hideModal(state) {
|
||||||
state.modal = false
|
state.modal = false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateDesserts(state, blockList) {
|
||||||
|
state.desserts = blockList
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {},
|
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: {},
|
getters: {},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default {
|
|||||||
let account = sessionStorage.getItem('KEY_ACCOUNT')
|
let account = sessionStorage.getItem('KEY_ACCOUNT')
|
||||||
try {
|
try {
|
||||||
account = JSON.parse(account)
|
account = JSON.parse(account)
|
||||||
const result = await axios.post('api/Account/getBalance', {
|
const result = await axios.post('Account/getBalance', {
|
||||||
Account: { address: account.address },
|
Account: { address: account.address },
|
||||||
})
|
})
|
||||||
commit('updateBalance', result.data || 0)
|
commit('updateBalance', result.data || 0)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<td>{{ props.item.height }}</td>
|
<td>{{ props.item.height }}</td>
|
||||||
<td>{{ props.item.timestamp }}</td>
|
<td>{{ props.item.timestamp }}</td>
|
||||||
<td>{{ props.item.type }}</td>
|
<td>{{ props.item.type }}</td>
|
||||||
<td>{{ props.item.id }}</td>
|
<td>{{ props.item.hash }}</td>
|
||||||
</template>
|
</template>
|
||||||
<template slot="no-results">
|
<template slot="no-results">
|
||||||
{{ $t('chain.tableNone') }}
|
{{ $t('chain.tableNone') }}
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<td>{{ props.item.height }}</td>
|
<td>{{ props.item.height }}</td>
|
||||||
<td>{{ props.item.timestamp }}</td>
|
<td>{{ props.item.timestamp }}</td>
|
||||||
<td>{{ props.item.type }}</td>
|
<td>{{ props.item.type }}</td>
|
||||||
<td>{{ props.item.id }}</td>
|
<td>{{ props.item.hash }}</td>
|
||||||
</template>
|
</template>
|
||||||
<template slot="no-results">
|
<template slot="no-results">
|
||||||
{{ $t('chain.tableNone') }}
|
{{ $t('chain.tableNone') }}
|
||||||
@@ -85,17 +85,16 @@ import {
|
|||||||
createNamespacedHelpers,
|
createNamespacedHelpers,
|
||||||
} from 'vuex'
|
} 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')
|
const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('chain')
|
||||||
|
Vue.use(VueSocketio, io('http://localhost:6842'), store)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Chain',
|
name: 'Chain',
|
||||||
|
|
||||||
data(){
|
|
||||||
return {
|
|
||||||
blockList:[],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
'headers',
|
'headers',
|
||||||
@@ -107,23 +106,28 @@ export default {
|
|||||||
]),
|
]),
|
||||||
...mapGetters([]),
|
...mapGetters([]),
|
||||||
},
|
},
|
||||||
|
sockets: {
|
||||||
created: async function(){
|
connect() {
|
||||||
let result=await axios({
|
console.log('socket connected')
|
||||||
method:'post',
|
},
|
||||||
url:location.protocol+'//'+location.hostname+':6842/api/Block/getBlockList',
|
newBlock(msg) {
|
||||||
data: {config:{order:'height DESC'}}
|
this.addNewBlock(msg)
|
||||||
})
|
},
|
||||||
this.blockList=result.data||[]
|
},
|
||||||
|
mounted() {
|
||||||
|
this.queryBlockList()
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions([
|
...mapActions([
|
||||||
|
'queryBlockList',
|
||||||
|
'addNewBlock',
|
||||||
]),
|
]),
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
'inputFilter',
|
'inputFilter',
|
||||||
'showModal',
|
'showModal',
|
||||||
'hideModal',
|
'hideModal',
|
||||||
|
'addDesserts',
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ export default {
|
|||||||
sideSelected: this.$route.path,
|
sideSelected: this.$route.path,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
'sideMenus',
|
'sideMenus',
|
||||||
@@ -71,7 +70,9 @@ export default {
|
|||||||
'isLogin',
|
'isLogin',
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
'updateRoute',
|
'updateRoute',
|
||||||
|
|||||||
Reference in New Issue
Block a user