Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(热点): 热门专题国际化处理
gaoSire6f2296a9b9f
diff --git a/@types/resources.d.ts b/@types/resources.d.tsindex fb3dfa3e..1202b823 100644--- a/@types/resources.d.ts+++ b/@types/resources.d.ts@@ -738,7 +738,11 @@ interface Resources {"shortDrama": "短剧","cultureTourism": "文旅","contentOverseas": "内容出海",- "hot": "热点"+ "hot": "热点",+ "last3days": "近3天",+ "last7days": "近7天",+ "last15days": "近15天",+ "last30days": "近30天"},"income": {"title": "我的收入",diff --git a/src/app/[lng]/hotContent/components/HotFeatures/index.tsx b/src/app/[lng]/hotContent/components/HotFeatures/index.tsxindex bdf4d4d5..105ba9f8 100644--- a/src/app/[lng]/hotContent/components/HotFeatures/index.tsx+++ b/src/app/[lng]/hotContent/components/HotFeatures/index.tsx@@ -21,6 +21,7 @@ import {HotContentBaseInfo,SingleNumberCall,} from "@/app/[lng]/hotContent/components/HotContent/hotContentCommonWidget";+import { useTransClient } from "@/app/i18n/client"; // 新增export interface IHotFeaturesRef {}@@ -36,7 +37,13 @@ const HotFeatures = memo(twoMenuKey: state.twoMenuKey,})),);- const allDates = useRef(["近3天", "近7天", "近15天", "近30天"]);+ const { t } = useTransClient("hot-content"); // 新增+ const allDates = useRef<string[]>([+ t("last3days"),+ t("last7days"),+ t("last15days"),+ t("last30days"),+ ]);// 当前选择的日期范围const [currDate, setCurrDate] = useState(allDates.current[1]);// 当前选择的平台@@ -63,7 +70,7 @@ const HotFeatures = memo(const columns: TableProps<Topic>["columns"] = [{- title: "排名",+ title: t("rank"),width: 60,render: (text, data, ind) => (<>@@ -78,7 +85,7 @@ const HotFeatures = memo(),},{- title: "基本信息",+ title: t("baseInfo"),dataIndex: "baseInfo",render: (text, data) => {return (@@ -97,7 +104,7 @@ const HotFeatures = memo(},},{- title: () => <p style={{ textAlign: "center" }}>作品分类</p>,+ title: () => <p style={{ textAlign: "center" }}>{t("category")}</p>,dataIndex: "category",key: "category",width: 120,@@ -114,7 +121,7 @@ const HotFeatures = memo(...(dataSource[1]?.shareCount? [{- ...callParamsColumnsCommon("分享数"),+ ...callParamsColumnsCommon(t("shares")),render: (text: any, data: Topic) => (<SingleNumberCall total={data.shareCount} />),@@ -124,7 +131,7 @@ const HotFeatures = memo(...(dataSource[1]?.likeCount? [{- ...callParamsColumnsCommon("点赞数"),+ ...callParamsColumnsCommon(t("likes")),render: (text: any, data: Topic) => (<SingleNumberCall total={data.likeCount} />),@@ -134,7 +141,7 @@ const HotFeatures = memo(...(dataSource[1]?.commentCount? [{- ...callParamsColumnsCommon("评论数"),+ ...callParamsColumnsCommon(t("comments")),render: (text: any, data: Topic) => (<SingleNumberCall total={data.commentCount} />),@@ -144,7 +151,7 @@ const HotFeatures = memo(...(dataSource[1]?.collectCount? [{- ...callParamsColumnsCommon("收藏数"),+ ...callParamsColumnsCommon(t("collections")),render: (text: any, data: Topic) => (<SingleNumberCalltotal={data.collectCount}@@ -157,7 +164,7 @@ const HotFeatures = memo(...(dataSource[1]?.readCount? [{- ...callParamsColumnsCommon("阅读数"),+ ...callParamsColumnsCommon(t("views")),render: (text: any, data: Topic) => (<SingleNumberCall total={data.readCount} highlight={true} />),@@ -167,7 +174,7 @@ const HotFeatures = memo(];return columns;- }, [dataSource]);+ }, [dataSource, t]);// 获取数据const getTableData = useCallback(async () => {@@ -177,7 +184,16 @@ const HotFeatures = memo(page: page.current,pageSize: 20,platformId: hotContentPlatformList.find((v) => v.name === currPlat)?.id,- timeType: currDate,+ timeType:+ currDate === t("last3days")+ ? "近3天"+ : currDate === t("last7days")+ ? "近7天"+ : currDate === t("last15days")+ ? "近15天"+ : currDate === t("last30days")+ ? "近30天"+ : "",msgType: twoMenuKey,});page.current = page.current + 1;diff --git a/src/app/[lng]/hotContent/components/HotTitle/index.tsx b/src/app/[lng]/hotContent/components/HotTitle/index.tsxindex e3411b36..25d82a6f 100644--- a/src/app/[lng]/hotContent/components/HotTitle/index.tsx+++ b/src/app/[lng]/hotContent/components/HotTitle/index.tsx@@ -16,6 +16,7 @@ import HotContentLabel from "@/app/[lng]/hotContent/components/HotContentLabel";import { Spin } from "antd";import { ViralTitle } from "@/api/types/viralTitles";import { HotTitleItem } from "@/app/[lng]/hotContent/components/HotTitle/components/HotTitleCommons";+import { useTransClient } from "@/app/i18n/client";export interface IHotTitleRef {}@@ -39,7 +40,8 @@ const HotTitle = memo(setCurrentRankCategory: state.setCurrentRankCategory,})),);- const labelAll = useRef("全部");+ const { t } = useTransClient("hot-content");+ const labelAll = useRef<string>(t("all"));// 当前选中的标签const [labelValue, setLabelValue] = useState(labelAll.current);const allDates = useRef(["近7天", "近30天", "近90天"]);@@ -89,7 +91,7 @@ const HotTitle = memo(const res = await platformApi.findByPlatformAndCategory(selectedLabelInfo.platId,{- category: labelValue,+ category: labelValue === labelAll.current ? "全部" : labelValue,page: 1,timeType: currDate,pageSize: 50,diff --git a/src/app/i18n/locales/en/hot-content.json b/src/app/i18n/locales/en/hot-content.jsonindex 5f98c04c..6aad72dc 100644--- a/src/app/i18n/locales/en/hot-content.json+++ b/src/app/i18n/locales/en/hot-content.json@@ -50,5 +50,9 @@"shortDrama": "Short Drama","cultureTourism": "Culture & Tourism","contentOverseas": "Content Overseas",- "hot": "Hot"+ "hot": "Hot",+ "last3days": "Last 3 days",+ "last7days": "Last 7 days",+ "last15days": "Last 15 days",+ "last30days": "Last 30 days"}diff --git a/src/app/i18n/locales/zh-CN/hot-content.json b/src/app/i18n/locales/zh-CN/hot-content.jsonindex e909d709..5b94ac48 100644--- a/src/app/i18n/locales/zh-CN/hot-content.json+++ b/src/app/i18n/locales/zh-CN/hot-content.json@@ -50,5 +50,9 @@"shortDrama": "短剧","cultureTourism": "文旅","contentOverseas": "内容出海",- "hot": "热点"+ "hot": "热点",+ "last3days": "近3天",+ "last7days": "近7天",+ "last15days": "近15天",+ "last30days": "近30天"}