From bc25fce1ccc7f081ee99aa89782d59771c025d9b Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 27 Aug 2022 21:14:16 +0800 Subject: [PATCH] add alias support --- src/chains/mainnet/akash.json | 3 ++- src/chains/mainnet/band.json | 3 ++- src/chains/mainnet/iris.json | 3 ++- src/router/index.js | 14 +++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/chains/mainnet/akash.json b/src/chains/mainnet/akash.json index fedfcedd..58f63c25 100644 --- a/src/chains/mainnet/akash.json +++ b/src/chains/mainnet/akash.json @@ -1,5 +1,6 @@ { - "chain_name": "akash-network", + "chain_name": "akash", + "alias": "akash-network", "api": ["https://akash.c29r3.xyz:443/api", "https://akash.api.ping.pub"], "rpc": ["http://rpc.akash.forbole.com:80", "http://akashsentry01.skynetvalidators.com:26657"], "snapshot_provider": "", diff --git a/src/chains/mainnet/band.json b/src/chains/mainnet/band.json index e93b18f0..fa9bbd76 100644 --- a/src/chains/mainnet/band.json +++ b/src/chains/mainnet/band.json @@ -1,5 +1,6 @@ { - "chain_name": "band-protocol", + "chain_name": "band", + "alias": "band-protocol", "api": "https://laozi1.bandchain.org/api", "rpc": ["http://rpc.laozi1.bandchain.org:80", "http://rpc.laozi1.bandchain.org:80"], "snapshot_provider": "", diff --git a/src/chains/mainnet/iris.json b/src/chains/mainnet/iris.json index 10cbb91b..1a8bbc7a 100644 --- a/src/chains/mainnet/iris.json +++ b/src/chains/mainnet/iris.json @@ -1,5 +1,6 @@ { - "chain_name": "iris-network", + "chain_name": "iris", + "alias": "iris-network", "api": "https://iris.api.ping.pub", "rpc": ["http://34.82.96.8:26657","http://34.77.68.145:26657"], "snapshot_provider": "fcc1d9bc43163b20ce5163cf41a302b33f25375f@34.82.96.8:26656", diff --git a/src/router/index.js b/src/router/index.js index 94d531ef..7dcbc14f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -403,14 +403,14 @@ const router = new VueRouter({ }) router.beforeEach((to, from, next) => { - const c = to.params.chain - if (c) { - store.commit('select', { chain_name: String(c).toLowerCase() }) - } + const c = String(to.params.chain).toLowerCase() - const config = JSON.parse(localStorage.getItem('chains')) - // const has = Object.keys(config).findIndex(i => i === c) - if (!config || Object.keys(config).findIndex(i => i === String(c).toLowerCase()) > -1) { + const configs = JSON.parse(localStorage.getItem('chains')) + const conf = Object.values(configs).find(i => i.chain_name === c || i.alias === c) + if (!configs || conf) { + if (conf) { + store.commit('select', { chain_name: conf.chain_name }) + } next() } else if (c) { if (c === 'index.php') {