diff --git a/src/components/ThemeSwitcher.vue b/src/components/ThemeSwitcher.vue
deleted file mode 100644
index 5a407d90..00000000
--- a/src/components/ThemeSwitcher.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/charts/DonutChart.vue b/src/components/charts/DonutChart.vue
index 57c73fd1..3907848b 100644
--- a/src/components/charts/DonutChart.vue
+++ b/src/components/charts/DonutChart.vue
@@ -1,21 +1,30 @@
-
+
diff --git a/src/components/charts/PriceMarketChart.vue b/src/components/charts/PriceMarketChart.vue
index 56cfb8eb..b86876e0 100644
--- a/src/components/charts/PriceMarketChart.vue
+++ b/src/components/charts/PriceMarketChart.vue
@@ -3,40 +3,56 @@ import ApexCharts from 'vue3-apexcharts';
import { getMarketPriceChartConfig } from './apexChartConfig';
import { useIndexModule } from '@/modules/[chain]/indexStore';
import { computed, ref } from '@vue/reactivity';
+import { useBaseStore } from '@/stores';
const store = useIndexModule();
+const baseStore = useBaseStore();
const chartConfig = computed(() => {
- const labels = store.marketData.prices.map((item: any) => item[0]);
- return getMarketPriceChartConfig(window.localStorage.getItem('theme') || 'dark', labels);
+ const theme = baseStore.theme;
+ const labels = store.marketData.prices.map((item: any) => item[0]);
+ return getMarketPriceChartConfig(theme, labels);
});
const kind = ref('price');
const series = computed(() => {
- return [
- {
- name: 'Price',
- data:
- kind.value === 'price'
- ? store.marketData.prices.map((item: any) => item[1])
- : store.marketData.total_volumes.map((item: any) => item[1]),
- },
- ];
+ return [
+ {
+ name: 'Price',
+ data:
+ kind.value === 'price'
+ ? store.marketData.prices.map((item: any) => item[1])
+ : store.marketData.total_volumes.map(
+ (item: any) => item[1]
+ ),
+ },
+ ];
});
function changeChart(type: string) {
- kind.value = type;
+ kind.value = type;
}
-
-
+
+
diff --git a/src/layouts/components/NavBarI18n.vue b/src/layouts/components/NavBarI18n.vue
index b71a47f1..f52d50ac 100644
--- a/src/layouts/components/NavBarI18n.vue
+++ b/src/layouts/components/NavBarI18n.vue
@@ -2,56 +2,61 @@
import { ref, watch } from 'vue';
import { Icon } from '@iconify/vue';
const i18nLangs: Array<{ label: string; i18nLang: string }> = [
- {
- label: 'English',
- i18nLang: 'en',
- },
- {
- label: '中文',
- i18nLang: 'cn',
- },
+ {
+ label: 'English',
+ i18nLang: 'en',
+ },
+ {
+ label: '中文',
+ i18nLang: 'cn',
+ },
];
let locale = ref(useI18n({ useScope: 'global' }).locale);
watch(locale, (val: string) => {
- document.documentElement.setAttribute('lang', val as string);
+ document.documentElement.setAttribute('lang', val as string);
});
let currentLang = ref(localStorage.getItem('lang') || 'en');
watch(currentLang, (val: string) => {
- document.documentElement.setAttribute('lang', val as string);
+ document.documentElement.setAttribute('lang', val as string);
});
const handleLangChange = (lang: string) => {
- locale.value = lang;
- currentLang.value = lang;
- localStorage.setItem('lang', lang);
+ locale.value = lang;
+ currentLang.value = lang;
+ localStorage.setItem('lang', lang);
};
-
+
+ {{ lang.label }}
+
+
+
diff --git a/src/layouts/components/NavbarThemeSwitcher.vue b/src/layouts/components/NavbarThemeSwitcher.vue
index bb1f2bed..dca49ed1 100644
--- a/src/layouts/components/NavbarThemeSwitcher.vue
+++ b/src/layouts/components/NavbarThemeSwitcher.vue
@@ -1,45 +1,48 @@
-
-
-
+
+
+
diff --git a/src/stores/useBaseStore.ts b/src/stores/useBaseStore.ts
index ca5edd22..09c8f24b 100644
--- a/src/stores/useBaseStore.ts
+++ b/src/stores/useBaseStore.ts
@@ -7,101 +7,111 @@ import { hashTx } from '@/libs';
import { fromBase64 } from '@cosmjs/encoding';
export const useBaseStore = defineStore('baseStore', {
- state: () => {
- return {
- earlest: {} as Block,
- latest: {} as Block,
- recents: [] as Block[],
- };
- },
- getters: {
- blocktime(): number {
- if (this.earlest && this.latest) {
- if (
- this.latest.block?.header?.height !==
- this.earlest.block?.header?.height
- ) {
- const diff = dayjs(this.latest.block?.header?.time).diff(
- this.earlest.block?.header?.time
- );
- return diff;
- }
- }
- return 6000;
+ state: () => {
+ return {
+ earlest: {} as Block,
+ latest: {} as Block,
+ recents: [] as Block[],
+ theme: (window.localStorage.getItem('theme') || 'dark') as
+ | 'light'
+ | 'dark',
+ };
},
- blockchain() {
- return useBlockchain();
- },
- currentChainId(): string {
- return this.latest.block?.header.chain_id || ""
- },
- txsInRecents() {
- const txs = [] as { height: string; hash: string; tx: DecodedTxRaw }[];
- this.recents.forEach((b) =>
- b.block?.data?.txs.forEach((tx: string) => {
- if (tx) {
- const raw = fromBase64(tx);
- try {
- txs.push({
- height: b.block.header.height,
- hash: hashTx(raw),
- tx: decodeTxRaw(raw),
- });
- } catch (e) {
- console.error(e);
+ getters: {
+ blocktime(): number {
+ if (this.earlest && this.latest) {
+ if (
+ this.latest.block?.header?.height !==
+ this.earlest.block?.header?.height
+ ) {
+ const diff = dayjs(this.latest.block?.header?.time).diff(
+ this.earlest.block?.header?.time
+ );
+ return diff;
+ }
}
- }
- })
- );
- return txs;
- },
- },
- actions: {
- async initial() {
- this.fetchLatest();
- },
- async clearRecentBlocks() {
- this.recents = [];
- },
- async fetchLatest() {
- this.latest = await this.blockchain.rpc?.getBaseBlockLatest();
- if (
- !this.earlest ||
- this.earlest?.block?.header?.chain_id !=
- this.latest?.block?.header?.chain_id
- ) {
- //reset earlest and recents
- this.earlest = this.latest;
- this.recents = [];
- }
- //check if the block exists in recents
- if (
- this.recents.findIndex(
- (x) => x?.block_id?.hash === this.latest?.block_id?.hash
- ) === -1
- ) {
- if (this.recents.length >= 50) {
- this.recents.shift();
- }
- this.recents.push(this.latest);
- }
- return this.latest;
+ return 6000;
+ },
+ blockchain() {
+ return useBlockchain();
+ },
+ currentChainId(): string {
+ return this.latest.block?.header.chain_id || '';
+ },
+ txsInRecents() {
+ const txs = [] as {
+ height: string;
+ hash: string;
+ tx: DecodedTxRaw;
+ }[];
+ this.recents.forEach((b) =>
+ b.block?.data?.txs.forEach((tx: string) => {
+ if (tx) {
+ const raw = fromBase64(tx);
+ try {
+ txs.push({
+ height: b.block.header.height,
+ hash: hashTx(raw),
+ tx: decodeTxRaw(raw),
+ });
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ })
+ );
+ return txs;
+ },
},
+ actions: {
+ async initial() {
+ this.fetchLatest();
+ },
+ async clearRecentBlocks() {
+ this.recents = [];
+ },
+ async fetchLatest() {
+ this.latest = await this.blockchain.rpc?.getBaseBlockLatest();
+ if (
+ !this.earlest ||
+ this.earlest?.block?.header?.chain_id !=
+ this.latest?.block?.header?.chain_id
+ ) {
+ //reset earlest and recents
+ this.earlest = this.latest;
+ this.recents = [];
+ }
+ //check if the block exists in recents
+ if (
+ this.recents.findIndex(
+ (x) => x?.block_id?.hash === this.latest?.block_id?.hash
+ ) === -1
+ ) {
+ if (this.recents.length >= 50) {
+ this.recents.shift();
+ }
+ this.recents.push(this.latest);
+ }
+ return this.latest;
+ },
- async fetchValidatorByHeight(height?: number, offset = 0) {
- return this.blockchain.rpc.getBaseValidatorsetAt(String(height), offset);
+ async fetchValidatorByHeight(height?: number, offset = 0) {
+ return this.blockchain.rpc.getBaseValidatorsetAt(
+ String(height),
+ offset
+ );
+ },
+ async fetchLatestValidators(offset = 0) {
+ return this.blockchain.rpc.getBaseValidatorsetLatest(offset);
+ },
+ async fetchBlock(height?: number | string) {
+ return this.blockchain.rpc.getBaseBlockAt(String(height));
+ },
+ async fetchAbciInfo() {
+ return this.blockchain.rpc.getBaseNodeInfo();
+ },
+ // async fetchNodeInfo() {
+ // return this.blockchain.rpc.no()
+ // }
},
- async fetchLatestValidators(offset = 0) {
- return this.blockchain.rpc.getBaseValidatorsetLatest(offset);
- },
- async fetchBlock(height?: number | string) {
- return this.blockchain.rpc.getBaseBlockAt(String(height));
- },
- async fetchAbciInfo() {
- return this.blockchain.rpc.getBaseNodeInfo();
- },
- // async fetchNodeInfo() {
- // return this.blockchain.rpc.no()
- // }
- },
});