diff --git a/.env.example b/.env.example index 47ba6b0..05a6a31 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ VUE_APP_VUEX_KEY=ex_vuex VUE_APP_TITLE=联盟链浏览器 VUE_APP_API_URL=/api VUE_APP_BLOCK_URL=https://explorer.lianshang.vip/api +VUE_APP_ESDB_URL=/esdb VUE_APP_MAIN_COIN_SYMBOL=XHC diff --git a/README.md b/README.md index eab3b6f..993df64 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ yarn serve yarn build ``` -### Lints and fixes files -``` -yarn lint -``` +### Nginx Configuration -### Customize configuration -See [Configuration Reference](https://cli.vuejs.org/config/). +``` +location /api { + proxy_pass http://172.95.27.1:8901/; +} +``` diff --git a/src/api/interfaces/esdb.ts b/src/api/interfaces/esdb.ts index 9097986..febbf12 100644 --- a/src/api/interfaces/esdb.ts +++ b/src/api/interfaces/esdb.ts @@ -1,4 +1,3 @@ -import { AuthResponse } from '@/types/auth' import axios, { AxiosRequestConfig } from 'axios' const request = axios.create({ @@ -6,7 +5,7 @@ const request = axios.create({ timeout: 5000 }) const axiosConf = (config: AxiosRequestConfig) => { - config.headers.Accept = 'application/json' + config.headers!.Accept = 'application/json' return config } request.interceptors.response.use(async (response) => { @@ -22,25 +21,28 @@ request.interceptors.request.use(axiosConf, err => { return Promise.reject(err) }) -const txList = (size?: number): Promise => { +const txList = (params?: any): Promise> => { const body = { id: 1, method: 'Tx.TxList', - params: [{ - 'sort': [{ - 'key': 'height', - 'ascending': false - }], - 'page': { - 'number': 1, - 'size': size - } - }] + params: [params] } return request.post('', body) } -export default { - txList +const txCount = (params?: any): Promise> => { + const body = { + id: 1, + method: 'Tx.TxCount', + params: [params] + } + + return request.post('', body) +} + + +export default { + txList, + txCount } diff --git a/src/components/Footer.vue b/src/components/Footer.vue index a135c5e..3799b13 100644 --- a/src/components/Footer.vue +++ b/src/components/Footer.vue @@ -1,8 +1,8 @@ diff --git a/src/components/Header.vue b/src/components/Header.vue index 5f6ee20..b1962bc 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -2,7 +2,7 @@
diff --git a/src/components/Nav.vue b/src/components/Nav.vue index f868ae8..bf6d36d 100644 --- a/src/components/Nav.vue +++ b/src/components/Nav.vue @@ -24,10 +24,10 @@ const navList = ref([ title: '查看区块', route: 'Block' }, - // { - // title: '查看数据', - // route: 'Trade' - // }, + { + title: '查看数据', + route: 'Trade' + }, { title: 'Token', route: 'Token' diff --git a/src/types/block.d.ts b/src/types/block.d.ts index 2f4356a..737fa80 100644 --- a/src/types/block.d.ts +++ b/src/types/block.d.ts @@ -97,14 +97,15 @@ export declare type BlockDetail = { } export declare type TradeItem = { - txHash: string - blockTime: number - fromAddr: string + hash: string + block_time: number + from: string + execer: string + action_name: string amount: number + fee: number assets: any - tx: { - to: string - } + to: string } export declare type TotalFee = { diff --git a/src/utils/filters.ts b/src/utils/filters.ts index 08840d5..85d0816 100644 --- a/src/utils/filters.ts +++ b/src/utils/filters.ts @@ -12,7 +12,7 @@ export const filterHash = (str: string, num?: number): string => { // 解析资产符号 export const parseSymbol = (assets?: AssetType[]): string => { if (assets) { - return assets[0].symbol + return assets[0]?.symbol } else { return store.getters.symbol } diff --git a/src/utils/request.ts b/src/utils/request.ts index 89a1a7d..0eb480c 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,8 +12,8 @@ const request = axios.create({ * @param config */ const axiosConf = (config: AxiosRequestConfig) => { - config.headers.Authorization = vuex.getters.accessToken - config.headers.Accept = 'application/json' + config.headers!.Authorization = vuex.getters.accessToken + config.headers!.Accept = 'application/json' return config } diff --git a/src/views/Address/index.vue b/src/views/Address/index.vue index ca43460..9c572ca 100644 --- a/src/views/Address/index.vue +++ b/src/views/Address/index.vue @@ -70,7 +70,6 @@ @@ -83,33 +82,33 @@ - - - + + + + + + + diff --git a/src/views/Block/detail.vue b/src/views/Block/detail.vue index 5c4c645..751cf75 100644 --- a/src/views/Block/detail.vue +++ b/src/views/Block/detail.vue @@ -147,7 +147,6 @@ watch(route, (to) => { } }) - const handleCurrentChange = (e: number) => { console.log(e) } diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue index 64749ab..5e687e6 100644 --- a/src/views/Home/index.vue +++ b/src/views/Home/index.vue @@ -30,7 +30,7 @@

最新交易

- +
@@ -38,31 +38,31 @@
交易哈希: - - {{ filterHash(item.txHash, 10) }} + + {{ filterHash(item.hash, 10) }}
- +
发送方: - - {{ filterHash(item.fromAddr, 10) }} + + {{ filterHash(item.from, 10) }}
接收方: - - {{ filterHash(item.tx.to, 10) }} + + {{ filterHash(item.to, 10) }}
交易资产
-
{{ item.amount }} {{ parseSymbol(item.assets) }}
+
{{ (item.amount / 1e8).toFixed(4) }} {{ parseSymbol(item.assets) }}
@@ -119,14 +119,12 @@ if (blockList.value.length === 0) { if (tradeList.value.length === 0) { const initTrade = { - txHash: ' ', - blockTime: 0, - fromAddr: ' ', + hash: ' ', + block_time: 0, + from: ' ', amount: 0, assets: null, - tx: { - to: ' ' - } + to: ' ' } as TradeItem for (let i = 0; i < 6; i++) { tradeList.value.push(initTrade) @@ -145,20 +143,19 @@ const getBlockList = () => { }) } -async function getTradeList () { - let txHashes = [] - for (let i = 0; i < blockList.value.length; i++) { - let res = await block.getBlockOverview(blockList.value[i].hash) - txHashes.push(...res.result.txHashes) - - if (txHashes.length > pageSize) { - txHashes = txHashes.slice(0, 6) - break +const getTradeList = () => { + const params = { + 'sort': [{ + 'key': 'height', + 'ascending': false + }], + 'page': { + 'number': 1, + 'size': pageSize } } - - block.getTxByHashes(txHashes).then(res => { - tradeList.value = res.result.txs + esdb.txList(params).then(res => { + tradeList.value = res }).finally(() => { tradeLoading.value = false }) diff --git a/src/views/Trade/index.vue b/src/views/Trade/index.vue index 3f87061..05564a4 100644 --- a/src/views/Trade/index.vue +++ b/src/views/Trade/index.vue @@ -8,15 +8,58 @@ :page-size="pageSize" @current-change="handleCurrentChange" > - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -29,26 +72,52 @@ export default {