diff --git a/src/hooks/useGetMaxHeight.ts b/src/hooks/useGetMaxHeight.ts
index 5196d0c..7b73bbb 100644
--- a/src/hooks/useGetMaxHeight.ts
+++ b/src/hooks/useGetMaxHeight.ts
@@ -1,9 +1,10 @@
import { block } from '@/api'
import vuex from '@/store'
import { ElMessage } from 'element-plus'
-import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
+import { computed, onMounted, ref } from 'vue'
+import { onBeforeRouteLeave } from 'vue-router'
-export default function () {
+export default () => {
const maxHeight = computed(() => vuex.getters.maxHeight)
// eslint-disable-next-line no-undef
@@ -29,7 +30,7 @@ export default function () {
})
}
- onBeforeUnmount(() => {
+ onBeforeRouteLeave(() => {
clearInterval(Number(interval.value))
})
diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue
index 690d40b..b084956 100644
--- a/src/views/Home/index.vue
+++ b/src/views/Home/index.vue
@@ -33,12 +33,37 @@
查看全部
-
+
- {{ item.from }}
- {{ item.to }}
- {{ item.hash }}
- {{ item.feefmt }}
+
+
+ 交易哈希:
+
+ {{ filterHash(item.txHash, 10) }}
+
+
+
+
+
+
+
+
+ 发送方:
+
+ {{ filterHash(item.fromAddr, 10) }}
+
+
+
+ 接收方:
+
+ {{ filterHash(item.tx.to, 10) }}
+
+
+
+
+
交易资产
+
{{ item.amount }} {{ parseSymbol(item.assets) }}
+
@@ -56,7 +81,7 @@ import { block } from '@/api'
import { Banner, TimeFormat } from '@/components'
import useGetMaxHeight from '@/hooks/useGetMaxHeight'
import { BlockItem } from '@/types/block'
-import { filterHash } from '@/utils/filters'
+import { filterHash, parseSymbol } from '@/utils/filters'
import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
@@ -65,6 +90,7 @@ const { maxHeight } = useGetMaxHeight()
const pageSize = Number(process.env.VUE_APP_HOME_LIST_SIZE)
const blockLoading = ref(true)
+const tradeLoading = ref(true)
onMounted(() => {
getBlockList()
@@ -96,31 +122,30 @@ const getBlockList = () => {
block.getHeaders(start, maxHeight.value, false).then(res => {
blockList.value = res.result.items.reverse()
+ getTradeList()
}).finally(() => {
blockLoading.value = false
})
- // block.getBlocks(start, maxHeight.value, false).then(res => {
- // res.result.items.reverse().forEach((item) => {
- //
- // blockList.value.push({
- // height: item.block.height,
- // blockTime: item.block.blockTime,
- // txCount: item.block.txs.length,
- // // hash: block.getBlockHash(item.block.height)
- // })
- //
- // // block.getBlockHash(item.block.height).then(hash => {
- // // blockList.value.push({
- // // height: item.block.height,
- // // blockTime: item.block.blockTime,
- // // txCount: item.block.txs.length,
- // // hash: hash.result.hash
- // // })
- // // })
- // tradeList.value.push(...item.block.txs)
- // console.log(tradeList.value)
- // })
- // })
+}
+
+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
+ }
+ }
+
+ block.getTxByHashes(txHashes).then(res => {
+ console.log(res.result.txs)
+ tradeList.value = res.result.txs
+ }).finally(() => {
+ tradeLoading.value = false
+ })
}
@@ -161,6 +186,10 @@ const getBlockList = () => {
height: 90px;
padding: 16px;
display: flex;
+
+ .time {
+ color: #9ea2a9;
+ }
}
}
}
@@ -198,18 +227,26 @@ const getBlockList = () => {
.num {
color: #6368de;
+ margin-right: 16px;
}
- .time {
- margin-left: 16px;
- color: #9ea2a9;
- }
}
}
}
.trades {
+ .item {
+ justify-content: space-between;
+
+ .hash,
+ .addr,
+ .asset {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ }
+ }
}
}
diff --git a/src/views/Token/index.vue b/src/views/Token/index.vue
index 5ee7a86..9b9367e 100644
--- a/src/views/Token/index.vue
+++ b/src/views/Token/index.vue
@@ -16,7 +16,11 @@
-
+
+
+ {{ (scope.row.total / 1e8).toFixed(2) }}
+
+
@@ -36,7 +40,7 @@ export default {
import { block } from '@/api'
import { Breadcrumb, TimeFormat } from '@/components'
import { filterHash } from '@/utils/filters'
-import { onMounted, ref } from 'vue'
+import { ref } from 'vue'
const tokens = ref([])
diff --git a/src/views/Trade/detail.vue b/src/views/Trade/detail.vue
index 4b30f49..780c662 100644
--- a/src/views/Trade/detail.vue
+++ b/src/views/Trade/detail.vue
@@ -110,7 +110,6 @@ const detail = ref({
} as BlockDetail)
const blockHash = ref('')
block.queryTransaction(route.params.hash as string).then(res => {
- console.log(res)
detail.value = res.result
block.getBlockHash(res.result.height).then(res => {