Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(数据统计): 优化
gaoSir5d4be9d6988d
diff --git a/src/app/[lng]/dataStatistics/DataStatisticsCore.tsx b/src/app/[lng]/dataStatistics/DataStatisticsCore.tsxindex 920a87c6..6ca0f51f 100644--- a/src/app/[lng]/dataStatistics/DataStatisticsCore.tsx+++ b/src/app/[lng]/dataStatistics/DataStatisticsCore.tsx@@ -56,7 +56,6 @@ export const DataStatisticsCore = () => {// 获取数据统计useEffect(() => {- if (filteredAccountList.length == 0) return;getStatistics();}, [timeRangeValue, getStatistics, filteredAccountList]);diff --git a/src/app/[lng]/dataStatistics/components/DataStatisticsHeader/index.tsx b/src/app/[lng]/dataStatistics/components/DataStatisticsHeader/index.tsxindex c0fb1e48..88b42f08 100644--- a/src/app/[lng]/dataStatistics/components/DataStatisticsHeader/index.tsx+++ b/src/app/[lng]/dataStatistics/components/DataStatisticsHeader/index.tsx@@ -88,36 +88,36 @@ const DataStatisticsHeader = memo(</div><div className="dataStatisticsHeader-accounts">- <div className="dataStatisticsHeader-accountCount">- <div className="dataStatisticsHeader-accountCount-title">- <AccountCount />- 累计账号数- </div>- <div className="dataStatisticsHeader-accountCount-number">- {filteredAccountList.length}- </div>- <Tag bordered={false} icon={<CheckCircleOutlined />}>- 在线{" "}- <b>- {filteredAccountList.filter((v) => v.status === 1).length}- </b>- </Tag>- <br />- <Tag bordered={false} icon={<WarningOutlined />}>- 离线{" "}- <b>- {filteredAccountList.filter((v) => v.status === 0).length}- </b>- </Tag>- </div>+ {filteredAccountList.length === 0 ? (+ <>+ <Empty style={{ width: "100%", height: "100%" }} />+ </>+ ) : (+ <>+ <div className="dataStatisticsHeader-accountCount">+ <div className="dataStatisticsHeader-accountCount-title">+ <AccountCount />+ 累计账号数+ </div>+ <div className="dataStatisticsHeader-accountCount-number">+ {filteredAccountList.length}+ </div>+ <Tag bordered={false} icon={<CheckCircleOutlined />}>+ 在线{" "}+ <b>+ {filteredAccountList.filter((v) => v.status === 1).length}+ </b>+ </Tag>+ <br />+ <Tag bordered={false} icon={<WarningOutlined />}>+ 离线{" "}+ <b>+ {filteredAccountList.filter((v) => v.status === 0).length}+ </b>+ </Tag>+ </div>- <div className="dataStatisticsHeader-accounts-swiper">- {filteredAccountList.length === 0 ? (- <>- <Empty style={{ width: "100%", height: "100%" }} />- </>- ) : (- <>+ <div className="dataStatisticsHeader-accounts-swiper"><Button className="swiper-prev" icon={<LeftOutlined />} />{accountGroupList.length === 0 ? (@@ -173,9 +173,9 @@ const DataStatisticsHeader = memo()}<Button className="swiper-next" icon={<RightOutlined />} />- </>- )}- </div>+ </div>+ </>+ )}</div></div>);diff --git a/src/app/[lng]/dataStatistics/useDataStatistics.tsx b/src/app/[lng]/dataStatistics/useDataStatistics.tsxindex 7ffd6d9a..293947ad 100644--- a/src/app/[lng]/dataStatistics/useDataStatistics.tsx+++ b/src/app/[lng]/dataStatistics/useDataStatistics.tsx@@ -127,6 +127,10 @@ export const useDataStatisticsStore = create(// 获取数据统计async getStatistics() {+ if (get().filteredAccountList.length === 0) {+ return;+ }+set({loading: true,});@@ -160,6 +164,7 @@ export const useDataStatisticsStore = create(// 分拣数据sortingData() {const data = get().originData;+if (!data) return;// 1. 汇总各指标总数