Skip to content

Let's use AI to Earn!

11

daoyian4515f89241aa
diff --git a/@types/resources.d.ts b/@types/resources.d.ts
index 41e10181..a1b733dc 100644
--- a/@types/resources.d.ts
+++ b/@types/resources.d.ts
@@ -7,6 +7,40 @@ interface Resources {
title: "AIToEarn官方网站";
content: "最好用的开源矩阵工具";
};
+ // "hot-content": {
+ // all: string;
+ // loading: string;
+ // noData: string;
+ // rank: string;
+ // cover: string;
+ // title: string;
+ // author: string;
+ // category: string;
+ // likes: string;
+ // shares: string;
+ // comments: string;
+ // collections: string;
+ // publishTime: string;
+ // fans: string;
+ // viewMore: string;
+ // timeRange: string;
+ // filter: string;
+ // hotTopics: string;
+ // viralTitles: string;
+ // topics: string;
+ // engagement: string;
+ // rising: string;
+ // noHotTopics: string;
+ // noViralTitles: string;
+ // noTopicData: string;
+ // total: string;
+ // items: string;
+ // video: string;
+ // noImage: string;
+ // platform: string;
+ // hotEvents: string;
+ // hotContent: string;
+ // };
}
export default Resources;
diff --git a/src/app/[lng]/hot-content/page.tsx b/src/app/[lng]/hot-content/page.tsx
index e377fde3..886d8bd3 100644
--- a/src/app/[lng]/hot-content/page.tsx
+++ b/src/app/[lng]/hot-content/page.tsx
@@ -9,6 +9,7 @@ import SideMenu from '@/components/hot-content/SideMenu';
import HotContent from '@/components/hot-content/HotContent';
import './page.css';
import { HotTopic } from '@/api/types/hotTopic';
+import { useTransClient } from '@/app/i18n/client';
// 添加必要的类型定义
interface ResponseType<T> {
@@ -17,6 +18,7 @@ interface ResponseType<T> {
message: string;
}
+
interface TopicContent {
id: string;
title: string;
@@ -124,6 +126,7 @@ const buttonStyles = {
};
const HotContentNew: React.FC = () => {
+ const { t } = useTransClient('hot-content');
// 状态管理
const [platforms, setPlatforms] = useState<Platform[]>([]);
const [selectedPlatform, setSelectedPlatform] = useState<Platform | null>(null);
@@ -622,8 +625,11 @@ const HotContentNew: React.FC = () => {
// 格式化数字
const formatNumber = (num: number | null) => {
- if (num === null) return '0';
- return num >= 10000 ? `${(num / 10000).toFixed(1)}w` : num.toString();
+ if (num === null || num === undefined) return '-';
+ if (num >= 10000) {
+ return `${(num / 10000).toFixed(1)}w`;
+ }
+ return num.toLocaleString();
};
// 处理热门专题点击
@@ -1253,23 +1259,20 @@ const HotContentNew: React.FC = () => {
<div className="viral-title-container">
{/* 顶部筛选区 */}
<div className="viral-title-filter">
-
-
{/* 分类筛选 */}
<div className="filter-section">
- <span className="filter-label">分类:</span>
+ <span className="filter-label">{t('category')}:</span>
<div className="filter-buttons">
<button
className={`filter-button ${selectedViralCategory === '' ? 'active' : ''}`}
onClick={() => {
if (selectedViralPlatform) {
- // 点击"全部"时重新获取所有分类的数据
fetchViralTitleContents(selectedViralPlatform.id, selectedTimeType);
setSelectedViralCategory('');
}
}}
>
- 全部
+ {t('all')}
</button>
{viralTitleCategories.map((category) => (
<button
@@ -1285,7 +1288,7 @@ const HotContentNew: React.FC = () => {
{/* 时间筛选 */}
<div className="filter-section">
- <span className="filter-label">时间范围:</span>
+ <span className="filter-label">{t('timeRange')}:</span>
<div className="filter-buttons">
{timeTypes.map((timeRange) => (
<button
@@ -1304,15 +1307,13 @@ const HotContentNew: React.FC = () => {
<div className="viral-title-content">
{viralTitleLoading ? (
<div className="loading-state">
- <span>加载中...</span>
+ <span>{t('loading')}</span>
</div>
) : Object.keys(viralTitleData).length > 0 ? (
- // 根据选中的分类显示不同视图
selectedViralCategory === '' ? (
- // 显示所有分类
Object.keys(viralTitleData).map(category => (
<div key={category} className="category-section">
- <h3 className="category-title">{category} </h3>
+ <h3 className="category-title">{category}</h3>
<div className="viral-title-list">
{viralTitleData[category].slice(0,5).map((title, index) => (
<div
@@ -1326,53 +1327,51 @@ const HotContentNew: React.FC = () => {
<div className="list-item-details">
<div className="list-item-title">{title.title}</div>
<span className="list-item-engagement">
- 互动量: {formatNumber(title.engagement)}
+ {t('engagement')}: {formatNumber(title.engagement)}
</span>
</div>
</div>
))}
</div>
- {/* 查看更多按钮 */}
<div className="view-more-button">
<button
className="view-more-btn"
onClick={() => handleViewMoreClick(category)}
>
- 查看更多
+ {t('viewMore')}
</button>
</div>
</div>
))
) : (
- // 显示单个分类的全部数据
<div className="category-section">
- <h3 className="category-title">{selectedViralCategory}</h3>
- <div className="viral-title-list">
- {viralTitleData[selectedViralCategory]?.map((title, index) => (
- <div
- key={title.id || index}
- className="viral-title-list-item"
- onClick={() => title.url && handleContentClick(title.url, title.title)}
- >
- <span className={`list-item-rank ${index < 3 ? 'top' : ''}`}>
- {index + 1}
+ <h3 className="category-title">{selectedViralCategory}</h3>
+ <div className="viral-title-list">
+ {viralTitleData[selectedViralCategory]?.map((title, index) => (
+ <div
+ key={title.id || index}
+ className="viral-title-list-item"
+ onClick={() => title.url && handleContentClick(title.url, title.title)}
+ >
+ <span className={`list-item-rank ${index < 3 ? 'top' : ''}`}>
+ {index + 1}
+ </span>
+ <div className="list-item-details">
+ <span className="list-item-category">{title.category}</span>
+ <div className="list-item-title">{title.title}</div>
+ <span className="list-item-engagement">
+ {t('engagement')}: {formatNumber(title.engagement)}
</span>
- <div className="list-item-details">
- <span className="list-item-category">{title.category}</span>
- <div className="list-item-title">{title.title}</div>
- <span className="list-item-engagement">
- 互动量: {formatNumber(title.engagement)}
- </span>
- </div>
</div>
- ))}
- </div>
+ </div>
+ ))}
+ </div>
</div>
)
) : (
<div className="empty-state">
<div className="empty-state-icon">📝</div>
- <div>暂无爆款标题数据</div>
+ <div>{t('noViralTitles')}</div>
</div>
)}
</div>
@@ -1419,7 +1418,7 @@ const HotContentNew: React.FC = () => {
{/* 时间筛选 */}
<div className="topic-filter-section">
- <span className="topic-filter-label">时间范围:</span>
+ <span className="topic-filter-label">{t('timeRange')}:</span>
<div className="topic-filter-buttons">
{timeTypes.map((timeRange) => (
<button
@@ -1436,7 +1435,7 @@ const HotContentNew: React.FC = () => {
{/* 分类筛选 */}
{selectedMsgType === 'aigc' && topicTypes.length > 1 && (
<div className="topic-filter-section">
- <span className="topic-filter-label">分类:</span>
+ <span className="topic-filter-label">{t('category')}:</span>
<div className="topic-filter-buttons">
{topicTypes.map((type) => (
<button
@@ -1460,20 +1459,20 @@ const HotContentNew: React.FC = () => {
<div className="topic-list-container">
{topicLoading ? (
<div className="topic-loading-state">
- <span className="topic-loading-text">加载中...</span>
+ <span className="topic-loading-text">{t('loading')}</span>
</div>
) : topicContents.length > 0 ? (
<>
{/* 表头 */}
<div className="topic-list-header">
- <div className="topic-header-col topic-header-col.rank-col">排名</div>
- <div className="topic-header-col topic-header-col.cover-col">封面</div>
- <div className="topic-header-col topic-header-col.info-col">标题/作者</div>
- <div className="topic-header-col topic-header-col.category-col">分类</div>
- <div className="topic-header-col topic-header-col.stats-col">点赞</div>
- <div className="topic-header-col topic-header-col.stats-col">分享</div>
- <div className="topic-header-col topic-header-col.stats-col">评论数</div>
- <div className="topic-header-col topic-header-col.stats-col">收藏数</div>
+ <div className="topic-header-col topic-header-col.rank-col">{t('rank')}</div>
+ <div className="topic-header-col topic-header-col.cover-col">{t('cover')}</div>
+ <div className="topic-header-col topic-header-col.info-col">{t('title')}/{t('author')}</div>
+ <div className="topic-header-col topic-header-col.category-col">{t('category')}</div>
+ <div className="topic-header-col topic-header-col.stats-col">{t('likes')}</div>
+ <div className="topic-header-col topic-header-col.stats-col">{t('shares')}</div>
+ <div className="topic-header-col topic-header-col.stats-col">{t('comments')}</div>
+ <div className="topic-header-col topic-header-col.stats-col">{t('collections')}</div>
</div>
{/* 内容列表 */}
@@ -1505,12 +1504,12 @@ const HotContentNew: React.FC = () => {
/>
) : (
<div className="topic-item-cover-placeholder">
- 暂无图片
+ {t('noImage')}
</div>
)}
{item.type === 'video' && (
<div className="topic-item-cover-video-tag">
- 视频
+ {t('video')}
</div>
)}
</div>
@@ -1547,12 +1546,12 @@ const HotContentNew: React.FC = () => {
{item.fans > 0 && (
<span className="topic-author-fans">
{item.fans >= 10000
- ? `${(item.fans / 10000).toFixed(1)}万粉丝`
- : `${item.fans}粉丝`}
+ ? `${(item.fans / 10000).toFixed(1)}万${t('fans')}`
+ : `${item.fans}${t('fans')}`}
</span>
)}
<span className="topic-publish-time">
- 发布于{' '}
+ {t('publishTime')}{' '}
{dayjs(item.publishTime).format(
'YYYY-MM-DD HH:mm',
)}
@@ -1578,7 +1577,7 @@ const HotContentNew: React.FC = () => {
? `${(item.likeCount / 10000).toFixed(1)}w`
: item.likeCount}
</div>
- <div className="topic-stat-label">点赞</div>
+ <div className="topic-stat-label">{t('likes')}</div>
</div>
{/* 分享数 */}
@@ -1588,7 +1587,7 @@ const HotContentNew: React.FC = () => {
? `${(item.shareCount / 10000).toFixed(1)}w`
: item.shareCount}
</div>
- <div className="topic-stat-label">分享</div>
+ <div className="topic-stat-label">{t('shares')}</div>
</div>
{/* 评论数 */}
@@ -1600,7 +1599,7 @@ const HotContentNew: React.FC = () => {
: item.commentCount
: '-'}
</div>
- <div className="topic-stat-label">{'评论数'}</div>
+ <div className="topic-stat-label">{t('comments')}</div>
</div>
{/* 收藏数 */}
@@ -1612,7 +1611,7 @@ const HotContentNew: React.FC = () => {
: item.collectCount
: '-'}
</div>
- <div className="topic-stat-label">{'收藏数'}</div>
+ <div className="topic-stat-label">{t('collections')}</div>
</div>
</div>
))}
@@ -1626,7 +1625,7 @@ const HotContentNew: React.FC = () => {
pageSize={topicPagination.itemsPerPage}
showSizeChanger={false}
showQuickJumper
- showTotal={(total) => `共 ${total} 条`}
+ showTotal={(total) => `${t('total')} ${total} ${t('items')}`}
onChange={handleTopicPageChange}
/>
</div>
@@ -1634,7 +1633,7 @@ const HotContentNew: React.FC = () => {
</>
) : (
<div className="topic-empty-state">
- 暂无专题数据
+ {t('noTopicData')}
</div>
)}
</div>
@@ -1644,7 +1643,7 @@ const HotContentNew: React.FC = () => {
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{hotTopicLoading ? (
<div className="loading-container col-span-full">
- <span className="loading-text">加载中...</span>
+ <span className="loading-text">{t('loading')}</span>
</div>
) : hotTopics && hotTopics.length > 0 ? (
hotTopics.map((platformData) => (
@@ -1670,7 +1669,7 @@ const HotContentNew: React.FC = () => {
</div>
)}
<span className="platform-name">
- {platformData.platform.name} · 热点
+ {platformData.platform.name} · {t('hotTopics')}
</span>
</div>
</div>
@@ -1700,7 +1699,7 @@ const HotContentNew: React.FC = () => {
<div className="hot-topic-metrics">
{topic.isRising && (
<span className="text-xs text-[#ff4d4f] bg-[#fff1f0] px-1 rounded">
- 热
+ {t('rising')}
</span>
)}
<span className="hot-topic-value">
@@ -1727,7 +1726,7 @@ const HotContentNew: React.FC = () => {
) : (
<div className="empty-state">
<div className="empty-state-icon">📊</div>
- <div className="empty-state-text">暂无热点数据</div>
+ <div className="empty-state-text">{t('noHotTopics')}</div>
</div>
)}
</div>
@@ -1737,7 +1736,7 @@ const HotContentNew: React.FC = () => {
) : (
<div className="empty-state col-span-full">
<div className="empty-state-icon">📊</div>
- <div className="empty-state-text">暂无热点事件数据</div>
+ <div className="empty-state-text">{t('noHotTopics')}</div>
</div>
)}
</div>
@@ -1757,7 +1756,7 @@ const HotContentNew: React.FC = () => {
<iframe
src={previewUrl}
style={{ width: '100%', height: '600px', border: 'none' }}
- title="内容预览"
+ title={t('hotContent')}
/>
</Modal>
</div>
diff --git a/src/app/i18n/locales/en/hot-content.json b/src/app/i18n/locales/en/hot-content.json
new file mode 100644
index 00000000..e509ea8e
--- /dev/null
+++ b/src/app/i18n/locales/en/hot-content.json
@@ -0,0 +1,34 @@
+{
+ "all": "All",
+ "loading": "Loading...",
+ "noData": "No Data",
+ "rank": "Rank",
+ "cover": "Cover",
+ "title": "Title",
+ "author": "Author",
+ "category": "Category",
+ "likes": "Likes",
+ "shares": "Shares",
+ "comments": "Comments",
+ "collections": "Collections",
+ "publishTime": "Published at",
+ "fans": "fans",
+ "viewMore": "View More",
+ "timeRange": "Time Range",
+ "filter": "Filter",
+ "hotTopics": "Hot Topics",
+ "viralTitles": "Viral Titles",
+ "topics": "Topics",
+ "engagement": "Engagement",
+ "rising": "Hot",
+ "noHotTopics": "No hot topics data",
+ "noViralTitles": "No viral titles data",
+ "noTopicData": "No topic data",
+ "total": "Total",
+ "items": "items",
+ "video": "Video",
+ "noImage": "No Image",
+ "platform": "Platform",
+ "hotEvents": "Hot Events",
+ "hotContent": "Hot Content"
+}
\ No newline at end of file
diff --git a/src/app/i18n/locales/zh-CN/hot-content.json b/src/app/i18n/locales/zh-CN/hot-content.json
new file mode 100644
index 00000000..c5cc1eac
--- /dev/null
+++ b/src/app/i18n/locales/zh-CN/hot-content.json
@@ -0,0 +1,34 @@
+{
+ "all": "全部",
+ "loading": "加载中...",
+ "noData": "暂无数据",
+ "rank": "排名",
+ "cover": "封面",
+ "title": "标题",
+ "author": "作者",
+ "category": "分类",
+ "likes": "点赞",
+ "shares": "分享",
+ "comments": "评论数",
+ "collections": "收藏数",
+ "publishTime": "发布于",
+ "fans": "粉丝",
+ "viewMore": "查看更多",
+ "timeRange": "时间范围",
+ "filter": "筛选",
+ "hotTopics": "热门专题",
+ "viralTitles": "爆款标题",
+ "topics": "专题",
+ "engagement": "互动量",
+ "rising": "热",
+ "noHotTopics": "暂无热点数据",
+ "noViralTitles": "暂无爆款标题数据",
+ "noTopicData": "暂无专题数据",
+ "total": "共",
+ "items": "条",
+ "video": "视频",
+ "noImage": "暂无图片",
+ "platform": "平台",
+ "hotEvents": "热点事件",
+ "hotContent": "热点内容"
+}
\ No newline at end of file
diff --git a/src/components/hot-content/SideMenu.tsx b/src/components/hot-content/SideMenu.tsx
index df531103..c8899cc9 100644
--- a/src/components/hot-content/SideMenu.tsx
+++ b/src/components/hot-content/SideMenu.tsx
@@ -2,6 +2,20 @@ import React from 'react';
import { DownOutlined, RightOutlined } from '@ant-design/icons';
import { Platform } from '@/api/hot';
import './SideMenu.css';
+import { useTransClient } from '@/app/i18n/client';
+
+const config = {
+ imageCDN: 'https://yika-bj.oss-cn-beijing.aliyuncs.com/',
+ apiBaseURL: 'https://ttgufwxxqyow.sealosbja.site/api',
+};
+
+// 处理图片地址
+const getImageUrl = (path: string) => {
+ if (!path) return '';
+ if (path.startsWith('http')) return path;
+ return `${config.imageCDN}${path}`;
+};
+
interface SideMenuProps {
platforms: Platform[];
@@ -27,7 +41,7 @@ interface SideMenuProps {
onHotPlatformExpand: () => void;
onViralPlatformSelect: (platform: Platform, timeType: string) => void;
onMsgTypeClick: (type: string) => void;
- getImageUrl: (path: string) => string;
+ // getImageUrl: (path: string) => string;
onHotContentClick: () => void;
onViralTitleCategorySelect: (category: string) => void;
}
@@ -56,22 +70,24 @@ const SideMenu: React.FC<SideMenuProps> = ({
onHotPlatformExpand,
onViralPlatformSelect,
onMsgTypeClick,
- getImageUrl,
+ // getImageUrl,
onHotContentClick,
onViralTitleCategorySelect,
}) => {
+ const { t } = useTransClient('hot-content');
+
return (
<div className="side-menu">
{/* 热门内容 */}
<div className="menu-section">
<div className="menu-header" onClick={() => { onContentExpand(); onHotContentClick(); }}>
- <span className="menu-title">热门内容</span>
+ <span className="menu-title">{t('hotContent')}</span>
{contentExpanded ? <DownOutlined /> : <RightOutlined />}
</div>
{contentExpanded && (
<ul className="menu-list">
{loading ? (
- <div className="loading">加载中...</div>
+ <div className="loading">{t('loading')}</div>
) : (
platforms.map((platform) => (
<li
@@ -97,7 +113,7 @@ const SideMenu: React.FC<SideMenuProps> = ({
{/* 热点事件 */}
<div className="menu-section">
<div className="menu-header" onClick={onHotEventExpand}>
- <span className="menu-title">热点事件</span>
+ <span className="menu-title">{t('hotEvents')}</span>
{hotEventExpanded ? <DownOutlined /> : <RightOutlined />}
</div>
{hotEventExpanded && (
@@ -106,7 +122,7 @@ const SideMenu: React.FC<SideMenuProps> = ({
className={`menu-item ${hotPlatformExpanded ? 'active' : ''}`}
onClick={onHotPlatformExpand}
>
- <span>八大平台热点</span>
+ <span>{t('hotTopics')}</span>
</li>
</ul>
)}
@@ -115,13 +131,13 @@ const SideMenu: React.FC<SideMenuProps> = ({
{/* 热门专题 */}
<div className="menu-section">
<div className="menu-header" onClick={onTopicExpand}>
- <span className="menu-title">热门专题</span>
+ <span className="menu-title">{t('topics')}</span>
{topicExpanded ? <DownOutlined /> : <RightOutlined />}
</div>
{topicExpanded && (
<ul className="menu-list">
{loading ? (
- <div className="loading">加载中...</div>
+ <div className="loading">{t('loading')}</div>
) : (
msgTypeList.map((type) => (
<li
@@ -140,13 +156,13 @@ const SideMenu: React.FC<SideMenuProps> = ({
{/* 爆款标题 */}
<div className="menu-section">
<div className="menu-header" onClick={onViralTitleExpand}>
- <span className="menu-title">爆款标题</span>
+ <span className="menu-title">{t('viralTitles')}</span>
{viralTitleExpanded ? <DownOutlined /> : <RightOutlined />}
</div>
{viralTitleExpanded && (
<ul className="menu-list">
{viralTitleLoading ? (
- <div className="loading">加载中...</div>
+ <div className="loading">{t('loading')}</div>
) : (
viralTitlePlatforms.map((platform) => (
<li