diff --git a/package.json b/package.json index 94a0da8..4a64629 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "vue-axios": "^2.1.3", "vue-i18n": "^8.1.0", "vue-router": "^3.0.1", + "vue-socket.io": "^2.1.1-b", "vuetify": "^1.2.5", "vuex": "^3.0.1" }, diff --git a/src/i18n/en.js b/src/i18n/en.js index 833aac7..89d69ad 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -35,12 +35,12 @@ export default { tableNone: '暂无数据', }, chain: { - tableHeader: '区块列表', + tableHeader: 'Block List', searchHolder: '请输入该输入的', - thHeight: '区块高度', - thTimestamp: '时间戳', - thType: '区块类型', - thId: '区块 ID', + thHeight: 'Height', + thTimestamp: 'Timestamp', + thType: 'Type', + thHash: 'Hash', tableNone: '暂无数据', }, } diff --git a/src/i18n/zh-CN.js b/src/i18n/zh-CN.js index 93a4f6d..c40360c 100644 --- a/src/i18n/zh-CN.js +++ b/src/i18n/zh-CN.js @@ -36,11 +36,11 @@ export default { }, chain: { tableHeader: '区块列表', - searchHolder: '请输入该输入的', + searchHolder: '输入要查询的区块高度或者区块哈希', thHeight: '区块高度', thTimestamp: '时间戳', thType: '区块类型', - thId: '区块 ID', + thHash: '区块哈希', tableNone: '暂无数据', }, } diff --git a/src/services/axios.js b/src/services/axios.js index c0d5a18..edcb4e7 100644 --- a/src/services/axios.js +++ b/src/services/axios.js @@ -1,4 +1,4 @@ import axios from 'axios' 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/' diff --git a/src/store/modules/chain.js b/src/store/modules/chain.js index 8b210d3..25a6bd9 100644 --- a/src/store/modules/chain.js +++ b/src/store/modules/chain.js @@ -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: {}, } diff --git a/src/store/modules/owner.js b/src/store/modules/owner.js index 6cced85..ebd969b 100644 --- a/src/store/modules/owner.js +++ b/src/store/modules/owner.js @@ -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) diff --git a/src/views/Chain.vue b/src/views/Chain.vue index 0bca62e..4f176ec 100644 --- a/src/views/Chain.vue +++ b/src/views/Chain.vue @@ -36,7 +36,7 @@