Commit 2291358b authored by chenqikuai's avatar chenqikuai

save blockChainBrowser home page

parent f4ea6753
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-i18n": "^8.24.4", "vue-i18n": "^8.24.4",
"vue-router": "^3.2.0", "vue-router": "^3.2.0",
"vuex": "^3.4.0" "vuex": "^3.4.0",
"ycc-api": "^0.0.1"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/eslint-plugin": "^4.18.0",
...@@ -36,9 +37,9 @@ ...@@ -36,9 +37,9 @@
"@vue/eslint-config-typescript": "^7.0.0", "@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"typescript": "~4.1.5",
"vue-template-compiler": "^2.6.11",
"sass": "^1.26.5", "sass": "^1.26.5",
"sass-loader": "^8.0.2" "sass-loader": "^8.0.2",
"typescript": "~4.1.5",
"vue-template-compiler": "^2.6.11"
} }
} }
...@@ -33,35 +33,14 @@ export default Vue.extend({ ...@@ -33,35 +33,14 @@ export default Vue.extend({
if (parseInt(String(local / 1000 - this.time)) >= 86400) if (parseInt(String(local / 1000 - this.time)) >= 86400)
this.showTime = filters.formatTime(this.time) this.showTime = filters.formatTime(this.time)
else if (parseInt(String(local / 1000 - this.time)) >= 3600) else if (parseInt(String(local / 1000 - this.time)) >= 3600)
this.showTime = `${h}${ this.showTime = `${h}${h == 1 ? 'hour' : 'hours'}${m}${
h == 1 m == 1 ? 'min' : 'mins'
? this.$root.$t('components.hour') }${s}${s == 1 ? 'sec' : 'secs'}`
: this.$root.$t('components.hours')
}${m}${
m == 1
? this.$root.$t('components.min')
: this.$root.$t('components.mins')
}${s}${
s == 1
? this.$root.$t('components.sec')
: this.$root.$t('components.secs')
}`
else if (parseInt(String(local / 1000 - this.time)) >= 60) else if (parseInt(String(local / 1000 - this.time)) >= 60)
this.showTime = `${m}${ this.showTime = `${m}${m == 1 ? 'min' : 'mins'}${s}${
m == 1 s == 1 ? 'sec' : 'secs'
? this.$root.$t('components.min')
: this.$root.$t('components.mins')
}${s}${
s == 1
? this.$root.$t('components.sec')
: this.$root.$t('components.secs')
}`
else
this.showTime = `${s}${
s == 1
? this.$root.$t('components.sec')
: this.$root.$t('components.secs')
}` }`
else this.showTime = `${s}${s == 1 ? 'sec' : 'secs'}`
}, },
}, },
beforeDestroy() { beforeDestroy() {
......
<template> <template>
<div> <div>
<latest-container title="最新区块"> <latest-container title="最新区块" to="/block">
<div <div
class="item flex px-7 py-4" class="item flex px-7 py-4"
v-for="(item, i) in latestBlocks" v-for="(item, i) in latestBlocks"
...@@ -9,14 +9,25 @@ ...@@ -9,14 +9,25 @@
<div <div
class="txNumberBox text-footer-color text-sm font-bold text-center pt-2 flex-shrink-0" class="txNumberBox text-footer-color text-sm font-bold text-center pt-2 flex-shrink-0"
> >
<div>{{ item.txNum }} 笔交易</div> <div>{{ (item && item.txs && item.txs.length) || '' }} 笔交易</div>
<div style="color: rgba(37, 69, 203, 0.3);"> <div style="color: rgba(37, 69, 203, 0.3);">
{{ item.timestamp }}s前 <Count v-if="item.blockTime" :time="item.blockTime"></Count>
</div> </div>
</div> </div>
<div class="w-full ml-5"> <div class="w-full ml-5">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="height">{{ item.height }}</div> <div class="height">
<router-link
:to="{
path: '/blockDetail',
query: {
height: item.height,
},
}"
>
{{ item.height }}
</router-link>
</div>
<div> <div>
<span class="graytxt">区块奖励:</span> <span class="graytxt">区块奖励:</span>
<span> <span>
...@@ -27,7 +38,18 @@ ...@@ -27,7 +38,18 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div> <div>
<span class="graytxt">打包地址:</span> <span class="graytxt">打包地址:</span>
<span class="text-app-color-2">{{ item.address }}</span> <router-link
:to="{
path: '/address',
query: {
address: item.minerHash,
},
}"
>
<span class="text-app-color-2">
{{ item.minerHash | filterHash }}
</span>
</router-link>
</div> </div>
<div class="graytxt">投票节点5+打包节点10</div> <div class="graytxt">投票节点5+打包节点10</div>
</div> </div>
...@@ -40,17 +62,13 @@ ...@@ -40,17 +62,13 @@
<script lang="ts"> <script lang="ts">
import Vue, { PropType } from 'vue' import Vue, { PropType } from 'vue'
import LatestContainer from '@/components/pc/BlockChainBrowser/LatestContainer.vue' import LatestContainer from '@/components/pc/BlockChainBrowser/LatestContainer.vue'
import { iBlockMsg } from 'ycc-api/dist/cmjs/service/home/types'
import Count from '@/components/pc/BlockChainBrowser/Count.vue'
export default Vue.extend({ export default Vue.extend({
components: { LatestContainer }, components: { LatestContainer, Count },
props: { props: {
latestBlocks: Array as PropType< latestBlocks: Array as PropType<iBlockMsg[]>,
{
txNum: number
timestamp: number
height: number
address: string
}[]
>,
}, },
}) })
</script> </script>
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
{{ title }} {{ title }}
</div> </div>
<div class="seeMore cursor-pointer"> <div class="seeMore cursor-pointer">
查看更多 <router-link :to="to">
查看更多
</router-link>
</div> </div>
</div> </div>
<div> <div>
...@@ -19,6 +21,7 @@ import Vue from 'vue' ...@@ -19,6 +21,7 @@ import Vue from 'vue'
export default Vue.extend({ export default Vue.extend({
props: { props: {
title: String, title: String,
to: String,
}, },
}) })
</script> </script>
......
<template> <template>
<div> <div>
<latest-container title="最新交易"> <latest-container title="最新交易" to="/tradeList">
<div <div
class="item flex px-7 py-4 justify-between" class="item flex px-7 py-4 justify-between"
v-for="(item, i) in latestTxs" v-for="(item, i) in latestTxs"
......
...@@ -2,7 +2,7 @@ import { iAsset } from "@/types/trade"; ...@@ -2,7 +2,7 @@ import { iAsset } from "@/types/trade";
//截断哈希 //截断哈希
export default { export default {
filterHash: (str: string): string => { filterHash: (str = ""): string => {
const num = 8; const num = 8;
return str.substring(0, num) + "..." + str.substring(str.length - 4); return str.substring(0, num) + "..." + str.substring(str.length - 4);
}, },
......
...@@ -25,6 +25,8 @@ import ChainSearch from '@/components/pc/BlockChainBrowser/ChainSearch.vue' ...@@ -25,6 +25,8 @@ import ChainSearch from '@/components/pc/BlockChainBrowser/ChainSearch.vue'
import ChainOverview from '@/components/pc/BlockChainBrowser/ChainOverview/index.vue' import ChainOverview from '@/components/pc/BlockChainBrowser/ChainOverview/index.vue'
import LatestBlock from '@/components/pc/BlockChainBrowser/LatestBlock/index.vue' import LatestBlock from '@/components/pc/BlockChainBrowser/LatestBlock/index.vue'
import LatestTx from '@/components/pc/BlockChainBrowser/LatestTx/index.vue' import LatestTx from '@/components/pc/BlockChainBrowser/LatestTx/index.vue'
import { getLatestBlock } from 'ycc-api/dist/cmjs/service/home/index'
import { iBlockMsg } from 'ycc-api/dist/cmjs/service/home/types'
export default Vue.extend({ export default Vue.extend({
components: { components: {
...@@ -60,44 +62,7 @@ export default Vue.extend({ ...@@ -60,44 +62,7 @@ export default Vue.extend({
}, },
], ],
value: '', value: '',
latestBlocks: [ latestBlocks: [] as iBlockMsg[],
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
{
height: 2000,
address: 'aldskjfalkdjf',
timestamp: 1012930,
txNum: 20,
},
],
latestTxs: [ latestTxs: [
{ {
hash: 'lkajskfdkasdf', hash: 'lkajskfdkasdf',
...@@ -123,6 +88,15 @@ export default Vue.extend({ ...@@ -123,6 +88,15 @@ export default Vue.extend({
], ],
} }
}, },
mounted() {
this.latestBlocks = (' '
.repeat(6)
.split(' ')
.map((i) => ({})) as unknown) as iBlockMsg[]
getLatestBlock('ycc', '/yccApi').then((ret) => {
this.latestBlocks = ret || []
})
},
methods: { methods: {
setValue(v: string) { setValue(v: string) {
this.value = v this.value = v
......
...@@ -13,6 +13,20 @@ module.exports = { ...@@ -13,6 +13,20 @@ module.exports = {
'^/api': '' '^/api': ''
} }
}, },
"/coin": {
target: "https://b.biqianbao.net/",
pathRewrite: {
"^/coin": ""
},
changeOrigin: true,
},
"/yccApi": {
target: "https://mainnet.yuan.org/api",
pathRewrite: {
"^/yccApi": ""
},
changeOrigin: true,
},
} }
}, },
configureWebpack: { configureWebpack: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment