From f6f8eecff0ee3954d4789d470849a80d18e22562 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 11 Feb 2019 00:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=9B=E5=8C=BA=E5=9D=97=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E5=9D=97=E5=87=BA=E7=8E=B0=E5=9C=A8=E6=9C=80?= =?UTF-8?q?=E4=B8=8A=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/en.js | 12 ++++++++++++ src/i18n/zh-CN.js | 7 +++++-- src/services/axios.js | 8 ++++++-- src/store/modules/chain.js | 3 ++- src/store/modules/network.js | 2 +- src/store/modules/node.js | 24 +++++++++++++++++++----- src/store/modules/owner.js | 31 +++++++++++++++++++------------ src/views/Chain.vue | 3 ++- src/views/Node.vue | 9 ++++++--- src/views/Owner.vue | 14 +++++++------- 10 files changed, 79 insertions(+), 34 deletions(-) diff --git a/src/i18n/en.js b/src/i18n/en.js index 71e3546..d707f96 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -44,4 +44,16 @@ export default { thHash: 'Hash', tableNone: '暂无数据', }, + node: { + tableHeader: '本节点打包的区块列表', + searchHolder: '输入要查询的区块高度或者区块哈希', + thHeight: '区块高度', + thTimestamp: '时间戳', + thType: '区块类型', + thHash: '区块哈希', + tableNone: '暂无数据', + thWinner: '获胜者', + thPacker: '打包区块者', + thRewardPacker: '打包奖励', + }, } diff --git a/src/i18n/zh-CN.js b/src/i18n/zh-CN.js index dd8795e..7622823 100644 --- a/src/i18n/zh-CN.js +++ b/src/i18n/zh-CN.js @@ -15,7 +15,7 @@ export default { }, owner: { tableHeader: '我的交易', - searchHolder: '请输入该输入的', + searchHolder: '请输入查询内容', thId: '交易 ID', thType: '类型', thSender: '发送者', @@ -48,9 +48,12 @@ export default { tableHeader: '本节点打包的区块列表', searchHolder: '输入要查询的区块高度或者区块哈希', thHeight: '区块高度', - thTimestamp: '时间戳', thType: '区块类型', thHash: '区块哈希', + thTimestamp: '时间戳', + thWinner: '获胜者', + thPacker: '打包区块者', + thRewardPacker: '打包奖励', tableNone: '暂无数据', }, } diff --git a/src/services/axios.js b/src/services/axios.js index 413e834..4b7eba8 100644 --- a/src/services/axios.js +++ b/src/services/axios.js @@ -1,5 +1,9 @@ import axios from 'axios' // import app from './app' - +// let baseURL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/api/` +// let baseURL = `${window.location.protocol}//${window.location.hostname}:8888/api/` +let baseURL = `http://test-us.bittic.net:8888/api/` +let socketUrl = 'ws://test-us.bittic.net:8888' // 控制台应当默认访问控制台所在主机(localhost 或者 window.location.hostname)的 TIC后台,或者让用户在控制台启动时,自己设置一个节点主机。 -axios.defaults.baseURL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/api/` +axios.defaults.baseURL = baseURL +axios.defaults.socketUrl = socketUrl diff --git a/src/store/modules/chain.js b/src/store/modules/chain.js index 57f6403..347e505 100644 --- a/src/store/modules/chain.js +++ b/src/store/modules/chain.js @@ -43,7 +43,8 @@ export default { }, addItem(state, block) { - state.itemList.push(block) + let temp = [block] + state.itemList = temp.concat(state.itemList) }, SOCKET_CONNECT(state, status) { diff --git a/src/store/modules/network.js b/src/store/modules/network.js index 9dd876d..9c2a58c 100644 --- a/src/store/modules/network.js +++ b/src/store/modules/network.js @@ -42,7 +42,7 @@ export default { actions: { async updateNetInfo({ state, commit }) { - let result = await axios.post('Peer/getPeerList', {}) + let result = await axios.post('Peer/peerStat', {}) commit('setPeerNumber', (result && result.data) ? result.data.length : 0) diff --git a/src/store/modules/node.js b/src/store/modules/node.js index 9ebdcfa..7bdc402 100644 --- a/src/store/modules/node.js +++ b/src/store/modules/node.js @@ -6,16 +6,22 @@ export default { pageEntity: [5, 10, 25], headers: [ { text: 'node.thHeight', value: 'height', align: 'center' }, - { text: 'node.thTimestamp', value: 'timestamp', align: 'center' }, { text: 'node.thType', value: 'type', align: 'center' }, { text: 'node.thHash', value: 'hash', align: 'center' }, + { text: 'node.thTimestamp', value: 'timestamp', align: 'center' }, + // { text: 'node.thWinner', value: 'winnerPubkey', align: 'center' }, + { text: 'node.thPacker', value: 'packerPubkey', align: 'center' }, + { text: 'node.thRewardPacker', value: 'rewardPacker', align: 'center' }, ], - itemList: [ + blockList: [ { height: 'loading', timestamp: 'loading', type: 'loading', hash: 'loading', + rewardPacker: 'loading', + winnerPubkey: 'loading', + packerPubkey: 'loading', }, ], fetching: false, @@ -31,14 +37,22 @@ export default { setIpAddress(state, ipAddress) { state.ipAddress = ipAddress }, - setItemList(state, itemList) { - state.itemList = itemList + setBlockList(state, blockList) { + state.blockList = blockList }, }, actions: { - updateNodeInfo({ state, commit }) { + async updateNodeInfo({ state, commit }) { + let account = sessionStorage.getItem('KEY_ACCOUNT') commit('setIpAddress', axios.defaults.baseURL) + try { + account = JSON.parse(account) + const myBlocks = await axios.post('Block/getBlockList', { + Block: { packerPubkey: account.pubkey }, + }) + commit('setBlockList', myBlocks && myBlocks.data ? myBlocks.data : []) + } catch (e) {} }, }, diff --git a/src/store/modules/owner.js b/src/store/modules/owner.js index 4eb964c..1ef4d33 100644 --- a/src/store/modules/owner.js +++ b/src/store/modules/owner.js @@ -16,16 +16,16 @@ export default { { text: 'owner.thRemark', value: 'remark', align: 'center' }, ], itemList: [ - // { - // id: 'xxxxx', - // type: 'zzz', - // sender: 'xxx', - // receiver: 'dddd', - // date: '333', - // amount: '12', - // fee: 32, - // remark: 'xxxx', - // }, + { + id: 'loading', + type: 'loading', + sender: 'loading', + receiver: 'loading', + date: 'loading', + amount: 'loading', + fee: 'loading', + remark: 'loading', + }, ], fetching: false, filter: '', @@ -45,6 +45,9 @@ export default { setAddress(state, address) { state.address = address }, + setActions(state, actions) { + state.itemList = actions + }, }, actions: { @@ -53,10 +56,14 @@ export default { try { account = JSON.parse(account) commit('setAddress', account.address) - const result = await axios.post('Account/getBalance', { + const balance = await axios.post('Account/getBalance', { Account: { address: account.address }, }) - commit('setBalance', (result && result.data) ? result.data : 0) + commit('setBalance', (balance && balance.data) ? balance.data : 0) + const actions = await axios.post('Action/getActionList', { + Action: { actorAddress: account.address }, + }) + commit('setActions', actions && actions.data ? actions.data : []) } catch (e) {} }, }, diff --git a/src/views/Chain.vue b/src/views/Chain.vue index 6395135..ead8355 100644 --- a/src/views/Chain.vue +++ b/src/views/Chain.vue @@ -92,8 +92,9 @@ import io from 'socket.io-client' import axios from 'axios' const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('chain') +const socketUrl = 'ws://test-us.bittic.net:8888' -Vue.use(VueSocketio, io(axios.defaults.baseURL), store) +Vue.use(VueSocketio, io(socketUrl), store) export default { name: 'Chain', diff --git a/src/views/Node.vue b/src/views/Node.vue index 7f96f22..6baf5d5 100644 --- a/src/views/Node.vue +++ b/src/views/Node.vue @@ -25,7 +25,7 @@