forked from cerc-io/cosmos-explorer
Merge pull request #435 from alisaweb3/v3-single
The timer is cleared uniformly, Interface error interrupt request
This commit is contained in:
commit
e7211c7732
@ -20,7 +20,7 @@ let rate = ref('');
|
|||||||
let height = ref('');
|
let height = ref('');
|
||||||
let round = ref('');
|
let round = ref('');
|
||||||
let step = ref('');
|
let step = ref('');
|
||||||
let timer = null;
|
let timer = null as any;
|
||||||
let updatetime = ref(new Date());
|
let updatetime = ref(new Date());
|
||||||
let positions = ref([]);
|
let positions = ref([]);
|
||||||
let validatorsData = ref([] as any);
|
let validatorsData = ref([] as any);
|
||||||
@ -28,16 +28,21 @@ onMounted(async () => {
|
|||||||
// stakingStore.init();
|
// stakingStore.init();
|
||||||
validatorsData.value = await stakingStore.fetchAcitveValdiators();
|
validatorsData.value = await stakingStore.fetchAcitveValdiators();
|
||||||
rpc.value = rpcList.value[0].address + '/consensus_state';
|
rpc.value = rpcList.value[0].address + '/consensus_state';
|
||||||
fetchPosition();
|
await fetchPosition();
|
||||||
update();
|
update();
|
||||||
|
clearTime()
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
update();
|
update();
|
||||||
}, 6000);
|
}, 6000);
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
timer = null;
|
clearTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function clearTime() {
|
||||||
|
clearInterval(timer);
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
const newTime = computed(() => {
|
const newTime = computed(() => {
|
||||||
return format.toDay(updatetime.value, 'time');
|
return format.toDay(updatetime.value, 'time');
|
||||||
});
|
});
|
||||||
@ -75,12 +80,12 @@ function color(i: number, txt: string) {
|
|||||||
}
|
}
|
||||||
return txt === 'nil-Vote' ? 'gray-700' : 'success';
|
return txt === 'nil-Vote' ? 'gray-700' : 'success';
|
||||||
}
|
}
|
||||||
function onChange() {
|
async function onChange () {
|
||||||
httpstatus.value = 200;
|
httpstatus.value = 200;
|
||||||
httpStatusText.value = '';
|
httpStatusText.value = '';
|
||||||
roundState.value = {};
|
roundState.value = {};
|
||||||
timer = null;
|
clearTime();
|
||||||
fetchPosition();
|
await fetchPosition();
|
||||||
update();
|
update();
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
update();
|
update();
|
||||||
@ -94,6 +99,7 @@ async function fetchPosition() {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error: ${response.status}`);
|
throw new Error(`HTTP error: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
httpstatus.value = response.status;
|
httpstatus.value = response.status;
|
||||||
httpStatusText.value = response.statusText;
|
httpStatusText.value = response.statusText;
|
||||||
|
|
||||||
@ -110,6 +116,7 @@ async function fetchPosition() {
|
|||||||
async function update() {
|
async function update() {
|
||||||
rate.value = '0%';
|
rate.value = '0%';
|
||||||
updatetime.value = new Date();
|
updatetime.value = new Date();
|
||||||
|
console.log(httpstatus, 'httpstatus')
|
||||||
if (httpstatus.value === 200) {
|
if (httpstatus.value === 200) {
|
||||||
fetch(rpc.value)
|
fetch(rpc.value)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user