From ed92ffe83788a6937edf10ddffca20a077002d57 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 16 Jun 2023 08:21:29 +0800 Subject: [PATCH] improve portfolio --- src/components/charts/apexChartConfig.ts | 33 +++++++++++++--------- src/modules/[chain]/index.vue | 4 +-- src/modules/wallet/portfolio.vue | 35 ++++++++++++++---------- src/stores/useFormatter.ts | 24 ++++++++++++++++ 4 files changed, 67 insertions(+), 29 deletions(-) diff --git a/src/components/charts/apexChartConfig.ts b/src/components/charts/apexChartConfig.ts index c219ea83..3d5dcedd 100644 --- a/src/components/charts/apexChartConfig.ts +++ b/src/components/charts/apexChartConfig.ts @@ -258,17 +258,23 @@ export const getMarketPriceChartConfig = ( }, }; }; + +// const donutColors = Array.from({length: 19}, () => (`#${Math.floor(Math.random()*16777215+100000).toString(16)}`)) +const donutColors = ['#c2992c', '#aa1cdb', '#83b0ad', '#bac470', '#cd1bb3', '#f65f30', '#5cfc8a', '#14aced', '#bf725b', '#2e9d9', '#2d5087', '#acfe3e', '#bbf511', '#53cd60', '#5d842d', '#61cd7c', '#c5cf75', '#ad5eb', '#164731'] + export const getDonutChartConfig = ( theme: string, labels: string[] ) => { - const donutColors = { - series1: '#fdd835', - series2: '#00d4bd', - series3: '#826bf8', - series4: '#32baff', - series5: '#ffa1a1', - }; + // const donutColors = { + // series1: '#fdd835', + // series2: '#00d4bd', + // series3: '#826bf8', + // series4: '#32baff', + // series5: '#ffa1a1', + // }; + + console.log(donutColors) const { themeSecondaryTextColor, themePrimaryTextColor } = colorVariables(theme); @@ -276,12 +282,13 @@ export const getDonutChartConfig = ( return { stroke: { width: 0 }, labels, - colors: [ - donutColors.series1, - donutColors.series5, - donutColors.series3, - donutColors.series2, - ], + colors: donutColors, + // colors: [ + // donutColors.series1, + // donutColors.series5, + // donutColors.series3, + // donutColors.series2, + // ], dataLabels: { enabled: true, formatter: (val: string) => `${parseInt(val, 10)}%`, diff --git a/src/modules/[chain]/index.vue b/src/modules/[chain]/index.vue index 3b54f71a..ca89b720 100644 --- a/src/modules/[chain]/index.vue +++ b/src/modules/[chain]/index.vue @@ -202,7 +202,7 @@ const amount = computed({
-
- Buy {{ coinInfo.symbol || '' }} diff --git a/src/modules/wallet/portfolio.vue b/src/modules/wallet/portfolio.vue index f9890611..510bc3b1 100644 --- a/src/modules/wallet/portfolio.vue +++ b/src/modules/wallet/portfolio.vue @@ -27,17 +27,17 @@ scanLocalKeys().forEach((wallet) => { // load balance & delegations if (imported) imported.forEach((x) => { - if (x.endpoint) { + if (x.endpoint && x.address) { const client = CosmosRestClient.newDefault(x.endpoint); client.getBankBalances(x.address).then((res) => { const bal = res.balances.filter((x) => x.denom.length < 10); - balances.value[x.address] = bal; + if(bal) balances.value[x.address || ""] = bal; bal.forEach((b) => { tokenMeta.value[b.denom] = x; }); }); client.getStakingDelegations(x.address).then((res) => { - delegations.value[x.address] = res.delegation_responses; + if(res && res.delegation_responses) delegations.value[x.address || ""] = res.delegation_responses; res.delegation_responses.forEach((del) => { tokenMeta.value[del.balance.denom] = x; }); @@ -98,9 +98,11 @@ const tokenList = computed(() => { }); return list.filter((x) => x.value > 0).sort((a, b) => b.value - a.value); }); +