From aef6e5f0e3314cee043429cb3efb8db29b0d2b8d Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 15 May 2023 18:43:26 +0800 Subject: [PATCH 1/7] update endpoint stratigy --- src/layouts/components/ChainProfile.vue | 2 +- src/router/index.ts | 4 +++- src/stores/useBlockchain.ts | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/layouts/components/ChainProfile.vue b/src/layouts/components/ChainProfile.vue index b9d4628d..1b0589d2 100644 --- a/src/layouts/components/ChainProfile.vue +++ b/src/layouts/components/ChainProfile.vue @@ -5,7 +5,7 @@ const baseStore = useBaseStore(); chainStore.initial(); chainStore.$subscribe((m, s) => { if (!Array.isArray(m.events) && m.events.key === 'endpoint') { - chainStore.initial(); + // chainStore.initial(); } }); diff --git a/src/router/index.ts b/src/router/index.ts index 20ca2ac5..682f75e4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -13,7 +13,9 @@ router.beforeEach((to) => { const { chain } = to.params if(chain){ const blockchain = useBlockchain() - blockchain.setCurrent(chain.toString()) + if(chain !== blockchain.chainName) { + blockchain.setCurrent(chain.toString()) + } } }) diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 9e11c3c8..502c8f94 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -122,11 +122,16 @@ export const useBlockchain = defineStore('blockchain', { }, async randomSetupEndpoint() { - const all = this.current?.endpoints?.rest; - if (all) { - const rn = Math.random(); - const endpoint = all[Math.floor(rn * all.length)]; - await this.setRestEndpoint(endpoint); + const end = localStorage.getItem(`endpoint-${this.chainName}`) + if(end) { + this.setRestEndpoint(JSON.parse(end)) + } else { + const all = this.current?.endpoints?.rest; + if (all) { + const rn = Math.random(); + const endpoint = all[Math.floor(rn * all.length)]; + await this.setRestEndpoint(endpoint); + } } }, @@ -134,9 +139,12 @@ export const useBlockchain = defineStore('blockchain', { this.connErr = ''; this.endpoint = endpoint; this.rpc = new CosmosRestClient(endpoint.address, DEFAULT); + localStorage.setItem(`endpoint-${this.chainName}`, JSON.stringify(endpoint)) }, setCurrent(name: string) { - this.chainName = name; + if(name !== this.chainName) { + this.chainName = name; + } }, }, }); From 8f1561dd74f1be6017483046c771ba0b1f94c8a6 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 16 May 2023 16:19:22 +0800 Subject: [PATCH 2/7] add uptime overview --- src/modules/[chain]/uptime/favorite.vue | 0 src/modules/[chain]/uptime/index.vue | 33 ++--- src/modules/[chain]/uptime/overview.vue | 188 ++++++++++++++++++++++++ 3 files changed, 201 insertions(+), 20 deletions(-) delete mode 100644 src/modules/[chain]/uptime/favorite.vue create mode 100644 src/modules/[chain]/uptime/overview.vue diff --git a/src/modules/[chain]/uptime/favorite.vue b/src/modules/[chain]/uptime/favorite.vue deleted file mode 100644 index e69de29b..00000000 diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue index a86a8f03..45b76c4c 100644 --- a/src/modules/[chain]/uptime/index.vue +++ b/src/modules/[chain]/uptime/index.vue @@ -23,16 +23,6 @@ const commits = ref([] as Commit[]); const keyword = ref(''); const live = ref(true); -// storage local favorite validator ids -const local = ref( - JSON.parse(localStorage.getItem('uptime-validators') || '{}') as Record< - string, - string[] - > -); -const currentPined = local.value[chainStore.chainName] -const selected = ref(currentPined || []); // favorite validators on selected blockchain - const signingInfo = ref({} as Record); // filter validators by keywords @@ -90,10 +80,17 @@ onUnmounted(() => { }); -watchEffect(() => { - local.value[chainStore.chainName] = selected.value; - localStorage.setItem('uptime-validators', JSON.stringify(local.value)); -}); +// watchEffect((x) => { +// const list = selected.value.map(x => { +// const val = stakingStore.validators.find(v => v.operator_address === x) +// return { +// name: val?.description.moniker || "", +// address: x +// } +// }) +// local.value[chainStore.chainName] = list; +// localStorage.setItem('uptime-validators', JSON.stringify(local.value)); +// });