From d7160ee5006274646b121629a4716e731e2d3d3b Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 18 Nov 2021 22:01:19 +0800 Subject: [PATCH] add links to menu --- src/libs/data/data.js | 5 +++++ src/navigation/vertical/index.js | 31 +++++++++++++++++++++++++++++++ src/store/chains/index.js | 4 +++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/libs/data/data.js b/src/libs/data/data.js index 88ce163a..3d91ac45 100644 --- a/src/libs/data/data.js +++ b/src/libs/data/data.js @@ -321,6 +321,11 @@ export function formatTokenAmount(tokenAmount, fraction = 2, denom = 'uatom') { return parseFloat(amount) } +export function isTestnet() { + return (window.location.hostname.startsWith('testnet') + || window.location.search.indexOf('testnet') > -1) +} + export function formatToken(token, IBCDenom = {}, decimals = 2) { if (token) { return `${formatTokenAmount(token.amount, decimals, token.denom)} ${formatTokenDenom(IBCDenom[token.denom] || token.denom)}` diff --git a/src/navigation/vertical/index.js b/src/navigation/vertical/index.js index 52cc34e6..9ad9da77 100644 --- a/src/navigation/vertical/index.js +++ b/src/navigation/vertical/index.js @@ -1,4 +1,5 @@ import store from '@/store' +import { isTestnet } from '../../libs/data/data' const modules = [ { @@ -71,6 +72,36 @@ function processMenu() { menu.children = children chainMenus.push(menu) }) + chainMenus.push({ header: 'LINKS' }) + if (isTestnet()) { + chainMenus.push({ + title: 'Mainnet Explorer', + href: 'https://ping.pub', + icon: 'ChromeIcon', + }) + } else { + chainMenus.push({ + title: 'Testnet Explorer', + href: 'http://testnet.ping.pub', + icon: 'LifeBuoyIcon', + }) + } + chainMenus.push({ + title: 'Discord', + href: 'https://discord.gg/CmjYVSr6GW', + icon: 'EyeIcon', + }) + chainMenus.push({ + title: 'Twitter', + href: 'https://twitter.com/ping_pub', + icon: 'TwitterIcon', + }) + chainMenus.push({ + title: 'Github', + href: 'https://github.com/ping-pub/explorer', + icon: 'GithubIcon', + }) + return chainMenus } diff --git a/src/store/chains/index.js b/src/store/chains/index.js index 319d60d4..38f82692 100644 --- a/src/store/chains/index.js +++ b/src/store/chains/index.js @@ -1,7 +1,9 @@ +import { isTestnet } from '@/libs/data/data' + let chains = {} let configs = require.context('../../chains/mainnet', false, /\.json$/) -if (window.location.hostname.startsWith('testnet') || window.location.search.indexOf('testnet') > -1) { +if (isTestnet()) { configs = require.context('../../chains/testnet', false, /\.json$/) }