Skip to content

Let's use AI to Earn!

feat(数据统计): 1. echarts图优化。 2. 平台名称进行国际化。

gaoSircb2247486dc1
diff --git a/@types/resources.d.ts b/@types/resources.d.ts
index 57c6ed82..ef278b82 100644
--- a/@types/resources.d.ts
+++ b/@types/resources.d.ts
@@ -367,8 +367,17 @@ interface Resources {
"online": "在线",
"offline": "离线",
"fansCount": "粉丝数",
+ "growthFansCount": "涨粉数",
"loginFailed": "登陆失败",
- "relogin": "重新登录"
+ "relogin": "重新登录",
+ "dataDetails": "数据明细",
+ "timeRange": "时间范围:",
+ "yesterdayIncrease": "昨日新增",
+ "readCount": "播放数",
+ "commentCount": "评论数",
+ "likeCount": "点赞数",
+ "collectCount": "收藏数",
+ "forwardCount": "分享数"
},
"demo": {
"demoText": "测试文字",
diff --git a/src/app/[lng]/dataStatistics/echart/drawDataStatisticsEchartLine.ts b/src/app/[lng]/dataStatistics/echart/drawDataStatisticsEchartLine.ts
index a0875d9c..f43aa5de 100644
--- a/src/app/[lng]/dataStatistics/echart/drawDataStatisticsEchartLine.ts
+++ b/src/app/[lng]/dataStatistics/echart/drawDataStatisticsEchartLine.ts
@@ -1,5 +1,6 @@
import * as echarts from "echarts";
-import { useDataStatisticsStore } from "../useDataStatistics"; // 引入store
+import { useDataStatisticsStore } from "../useDataStatistics";
+import { describeNumber } from "@/utils"; // 引入store
type EChartsOption = echarts.EChartsOption;
@@ -42,6 +43,11 @@ export default function drawDataStatisticsEchartLine(elId: string) {
},
yAxis: {
type: "value",
+ axisLabel: {
+ formatter: function (value: number) {
+ return describeNumber(value);
+ },
+ },
},
// @ts-ignore
series: series,
diff --git a/src/app/[lng]/dataStatistics/useDataStatistics.tsx b/src/app/[lng]/dataStatistics/useDataStatistics.tsx
index 27b75ca8..a9a6001c 100644
--- a/src/app/[lng]/dataStatistics/useDataStatistics.tsx
+++ b/src/app/[lng]/dataStatistics/useDataStatistics.tsx
@@ -15,6 +15,7 @@ import { StatisticsPeriodModel } from "@/api/types/dataStatistics";
import { message } from "antd";
import drawDataStatisticsEchartLine from "@/app/[lng]/dataStatistics/echart/drawDataStatisticsEchartLine";
import { directTrans } from "@/app/i18n/client";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
export interface IDataStatisticsStore {
// 当前选择的账户组IDs
@@ -207,7 +208,7 @@ export const useDataStatisticsStore = create(
data.groupedByDate.forEach((g) =>
g.records.forEach((r) => platformSet.add(r.platform)),
);
- const platforms = Array.from(platformSet).sort();
+ const platforms = Array.from(platformSet).sort() as PlatType[];
// 初始化矩阵
const chartData: Record<string, number[]> = {};
@@ -228,10 +229,12 @@ export const useDataStatisticsStore = create(
});
// 组装 ECharts 格式
- const legend = platforms;
+ const legend = platforms.map(
+ (v) => AccountPlatInfoMap.get(v)?.name || v,
+ );
const xAxis = dates;
const series = platforms.map((p) => ({
- name: p,
+ name: AccountPlatInfoMap.get(p)?.name || p,
type: "line",
stack: "Total",
data: chartData[p],
diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.ts
index c2f481ea..e98dc1ad 100644
--- a/src/app/config/platConfig.ts
+++ b/src/app/config/platConfig.ts
@@ -8,11 +8,11 @@ import twitterSvg from "@/assets/svgs/plat/twtter.svg";
import facebookSvg from "@/assets/svgs/plat/facebook.svg";
import instagramSvg from "@/assets/svgs/plat/instagram.svg";
import threadsSvg from "@/assets/svgs/plat/xiancheng.svg";
-import wxGzhSvg from "@/assets/svgs/plat/wx-gzh.svg";
import wxSphSvg from "@/assets/svgs/plat/wx-sph.svg";
import gongzhonghaoSvg from "@/assets/svgs/plat/gongzhonghao.png";
import pinterestSvg from "@/assets/svgs/plat/pinterest.svg";
import xhsSvg from "@/assets/svgs/plat/xhs.svg";
+import { directTrans } from "@/app/i18n/client";
// 平台类型
export enum PlatType {
@@ -70,11 +70,10 @@ export interface IAccountPlatInfo {
// 各个平台的信息
export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
-
[
PlatType.Xhs,
{
- name: "小红书",
+ name: "rednote",
icon: xhsSvg,
url: "https://www.xiaohongshu.com/",
themeColor: "red",
@@ -90,7 +89,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.KWAI,
{
- name: "快手",
+ name: "kwai",
icon: ksSvg,
url: "https://cp.kuaishou.com/profile",
pubTypes: new Set([PubType.VIDEO]),
@@ -104,7 +103,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.BILIBILI,
{
- name: "Bilibili",
+ name: "bilibili",
icon: bilibiliSvg,
url: "https://cp.kuaishou.com/profile",
pubTypes: new Set([PubType.VIDEO]),
@@ -119,7 +118,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.WxGzh,
{
- name: "微信公众号",
+ name: "wxgzh",
icon: gongzhonghaoSvg.src,
url: "https://mp.weixin.qq.com/",
pubTypes: new Set([PubType.ImageText, PubType.Article]),
@@ -135,7 +134,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.Douyin,
{
- name: "抖音",
+ name: "douyin",
icon: douyinSvg,
url: "https://www.douyin.com/",
pubTypes: new Set([]),
@@ -151,7 +150,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.WxSph,
{
- name: "微信视频号",
+ name: "wxsph",
icon: wxSphSvg,
url: "https://mp.weixin.qq.com/",
pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
@@ -275,3 +274,15 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
],
]);
export const AccountPlatInfoArr = Array.from(AccountPlatInfoMap);
+
+// 遍历设置 name getter
+AccountPlatInfoMap.forEach((info) => {
+ const rawName = info.name;
+ Object.defineProperty(info, "name", {
+ get() {
+ return directTrans("account", rawName);
+ },
+ configurable: true,
+ enumerable: true,
+ });
+});
diff --git a/src/app/i18n/locales/en/account.json b/src/app/i18n/locales/en/account.json
index 5017b7dc..83289933 100644
--- a/src/app/i18n/locales/en/account.json
+++ b/src/app/i18n/locales/en/account.json
@@ -93,5 +93,11 @@
"account": "Account",
"platform": "Platform",
"space": "Space"
- }
+ },
+ "rednote": "Rednote",
+ "kwai": "Kwai",
+ "bilibili": "Bilibili",
+ "wxgzh": "WeChat Official Account",
+ "douyin": "Douyin",
+ "wxsph": "WeChat Channels"
}
\ No newline at end of file
diff --git a/src/app/i18n/locales/en/dataStatistics.json b/src/app/i18n/locales/en/dataStatistics.json
index a1c1eda5..ed75e3dc 100644
--- a/src/app/i18n/locales/en/dataStatistics.json
+++ b/src/app/i18n/locales/en/dataStatistics.json
@@ -13,7 +13,7 @@
"loginFailed": "Login Failed",
"relogin": "Relogin",
"dataDetails": "Data Details",
- "timeRange": "Time Range:",
+ "timeRange": "Time Range:",
"yesterdayIncrease": "Yesterday Increase",
"readCount": "Reads",
"commentCount": "Comments",
diff --git a/src/app/i18n/locales/zh-CN/account.json b/src/app/i18n/locales/zh-CN/account.json
index 46ab2ec0..8f5ec3a3 100644
--- a/src/app/i18n/locales/zh-CN/account.json
+++ b/src/app/i18n/locales/zh-CN/account.json
@@ -93,5 +93,11 @@
"account": "账号",
"platform": "平台",
"space": "所属列表"
- }
+ },
+ "rednote": "小红书",
+ "kwai": "快手",
+ "bilibili": "哔哩哔哩",
+ "wxgzh": "微信公众号",
+ "douyin": "抖音",
+ "wxsph": "微信视频号"
}
\ No newline at end of file
diff --git a/src/utils/index.ts b/src/utils/index.ts
index fbbf5d20..0130af7b 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -62,13 +62,13 @@ export function formatSeconds(seconds: number): string {
*/
export function describeNumber(value: number): string {
if (value > 10000) {
- // 数值超过10000,返回'n万'
+ // 数值超过10000,返回'n w'
const wan = Math.floor(value / 10000);
- return `${wan}万`;
+ return `${wan}w`;
} else if (value > 1000) {
- // 数值超过1000,返回'n千'
+ // 数值超过1000,返回'n k'
const qian = Math.floor(value / 1000);
- return `${qian}千`;
+ return `${qian}k`;
} else {
// 数值不超过1000,直接返回数值的字符串形式
return value.toString();