This commit is contained in:
2021-09-30 09:14:12 +08:00
parent 33dc44c4c7
commit d4c4605d7e
3 changed files with 26 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import { onBeforeRouteLeave } from 'vue-router'
export default () => {
const maxHeight = computed(() => vuex.getters.maxHeight)
const lastHash = computed(() => vuex.getters.lastHash)
// eslint-disable-next-line no-undef
const interval = ref<NodeJS.Timeout | null>()
@@ -26,6 +27,7 @@ export default () => {
})
} else if (maxHeight.value !== res.result.height) {
vuex.dispatch('setMaxHeight', res.result.height).then()
vuex.dispatch('setLastHash', res.result.hash).then()
}
})
}
@@ -35,6 +37,7 @@ export default () => {
})
return {
maxHeight
maxHeight,
lastHash
}
}

View File

@@ -17,6 +17,7 @@ export interface State {
openId: string
loginAt: number
maxHeight: number
lastHash: string
user: BaseInfo
auth?: AuthState
refresh?: RefreshState
@@ -31,6 +32,7 @@ export default createStore<State>({
openId: '',
loginAt: 0,
maxHeight: 0,
lastHash: '',
user: {} as BaseInfo
},
getters: {
@@ -46,6 +48,9 @@ export default createStore<State>({
maxHeight: (state: State): number => {
return state.maxHeight
},
lastHash: (state: State): string => {
return state.lastHash
},
symbol: (): string => {
return process.env.VUE_APP_MAIN_COIN_SYMBOL as string
}
@@ -74,7 +79,10 @@ export default createStore<State>({
},
setMaxHeight: (state: State, height: number): void => {
state.maxHeight = height
}
},
setLastHash: (state: State, hash: string): void => {
state.lastHash = hash
},
},
actions: {
setUserInfo: ({ commit }, info: BaseInfo): void => {

View File

@@ -24,12 +24,22 @@
</template>
<script lang="ts" setup>
import { block } from '@/api'
import { Breadcrumb, Pagination } from '@/components'
import useGetMaxHeight from '@/hooks/useGetMaxHeight'
import { ref } from 'vue'
const currentPage = ref<number>(1)
const pageSize = ref<number>(20)
const pageSize = Number(process.env.VUE_APP_BLOCK_LIST_SIZE)
const maxHeight = 100
const { lastHash } = useGetMaxHeight()
console.log('lastHash', lastHash.value)
// 'TotalFeeKey:'
// base64_encode('TotalFeeKey:' . hex2bin($this->parseHexString($lastHash))),
block.queryTotalFee(['VG90YWxGZWVLZXk6RDX0zTxuG/PZfMvhZPri8RiussF1s1VZmW9EotB9clQ=']).then(res => {
console.log(res)
})
const handleCurrentChange = (e: number) => {
console.log(e)
}