Skip to content

Let's use AI to Earn!

jiemiao1

bulaienaofutuojiesenzhangf7b2a449b99a
diff --git a/src/api/engagement.ts b/src/api/engagement.ts
index d0a8f2b4..b682c542 100644
--- a/src/api/engagement.ts
+++ b/src/api/engagement.ts
@@ -1,8 +1,29 @@
import http from '@/utils/request';
-import { EngagementPostsParams, EngagementPostsResponse } from './types/engagement';
+import { EngagementPostsParams, EngagementPostsResponse, EngagementCommentsParams, EngagementCommentsResponse, EngagementReplyParams, PostCommentsParamsV2, PostCommentsResponseV2, PublishPostCommentParams, PublishCommentReplyParams } from './types/engagement';
export async function apiGetEngagementPosts(params: EngagementPostsParams) {
- return http.post<EngagementPostsResponse>('api/channel/engagement/posts', params);
+ return http.post<EngagementPostsResponse>('channel/engagement/posts', params);
+}
+
+export async function apiGetEngagementComments(params: EngagementCommentsParams) {
+ return http.post<EngagementCommentsResponse>('channel/engagement/comments', params);
+}
+
+export async function apiReplyEngagementComment(params: EngagementReplyParams) {
+ return http.post<{}>('channel/engagement/comment/reply', params);
+}
+
+// 获取作品一级评论(V2)
+export async function apiGetPostComments(params: PostCommentsParamsV2) {
+ return http.post<PostCommentsResponseV2>('channel/engagement/post/comments', params);
+}
+
+export async function apiPublishPostComment(params: PublishPostCommentParams) {
+ return http.post<{}>('channel/engagement/post/comments/publish', params);
+}
+
+export async function apiPublishCommentReply(params: PublishCommentReplyParams) {
+ return http.post<{}>('channel/engagement/comment/replies/publish', params);
}
diff --git a/src/api/types/engagement.ts b/src/api/types/engagement.ts
index d88d3f99..da9013c9 100644
--- a/src/api/types/engagement.ts
+++ b/src/api/types/engagement.ts
@@ -45,4 +45,85 @@ export interface EngagementPostsResponse {
hasMore: boolean;
}
+export interface EngagementCommentItem {
+ id: string;
+ postId: string;
+ userId: string;
+ userName?: string;
+ userAvatar?: string;
+ content: string;
+ likeCount: number;
+ createdAt: number; // ms timestamp
+ parentId?: string; // 回复时存在
+}
+
+export interface EngagementCommentsParams {
+ postId: string;
+ page: number;
+ pageSize: number;
+}
+
+export interface EngagementCommentsResponse {
+ total: number;
+ comments: EngagementCommentItem[];
+ hasMore: boolean;
+}
+
+export interface EngagementReplyParams {
+ postId: string;
+ parentId?: string;
+ content: string;
+}
+
+// 新版:平台一级评论(支持 keyset/offset 分页)
+export type PostCommentPlatform = 'facebook' | 'instagram' | 'twitter' | 'youtube' | 'tiktok';
+
+export interface PostCommentsAuthor {
+ id?: string;
+ name?: string;
+ avatar?: string;
+}
+
+export interface PostCommentItemV2 {
+ id: string;
+ message: string;
+ author: PostCommentsAuthor;
+ createdAt: string; // ISO 8601
+ hasReplies: boolean;
+}
+
+export interface PostCommentsParamsV2 {
+ accountId: string;
+ platform: PostCommentPlatform;
+ postId: string;
+ pagination?: {
+ before?: string;
+ after?: string;
+ limit?: number;
+ };
+}
+
+export interface PostCommentsResponseV2 {
+ comments: PostCommentItemV2[];
+ total?: number; // offset 模式才会返回
+ cursor?: {
+ before?: string;
+ after?: string;
+ };
+}
+
+export interface PublishPostCommentParams {
+ accountId: string;
+ platform: PostCommentPlatform;
+ postId: string;
+ message: string; // 1-500 chars
+}
+
+export interface PublishCommentReplyParams {
+ accountId: string;
+ platform: PostCommentPlatform;
+ commentId: string;
+ message: string; // 1-500 chars
+}
+
diff --git a/src/app/[lng]/engagement/page.tsx b/src/app/[lng]/engagement/page.tsx
deleted file mode 100644
index bdbaca11..00000000
--- a/src/app/[lng]/engagement/page.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-"use client";
-
-import { useEffect, useMemo, useState } from "react";
-import { Card, Table, Select, Input, DatePicker, Space, Button, Tag } from "antd";
-import { useParams, useRouter } from "next/navigation";
-import { useTransClient } from "@/app/i18n/client";
-import { apiGetEngagementPosts } from "@/api/engagement";
-import { EngagementPlatform, EngagementPostItem } from "@/api/types/engagement";
-
-const { Option } = Select;
-
-export default function EngagementPage() {
- const { t } = useTransClient('engagement');
- const { lng } = useParams();
-
- const [platform, setPlatform] = useState<EngagementPlatform>('bilibili');
- const [uid, setUid] = useState<string>('');
- const [posts, setPosts] = useState<EngagementPostItem[]>([]);
- const [total, setTotal] = useState<number>(0);
- const [hasMore, setHasMore] = useState<boolean>(false);
- const [loading, setLoading] = useState<boolean>(false);
- const [page, setPage] = useState<number>(1);
- const [pageSize, setPageSize] = useState<number>(20);
-
- async function fetchPosts(p: number = page, s: number = pageSize) {
- if (!uid) return;
- setLoading(true);
- try {
- const res = await apiGetEngagementPosts({ platform, uid, page: p, pageSize: s });
- if (res?.data) {
- setPosts(res.data.posts || []);
- setTotal(res.data.total || 0);
- setHasMore(!!res.data.hasMore);
- }
- } finally {
- setLoading(false);
- }
- }
-
- useEffect(() => {
- // 初次加载不自动拉取,等待用户输入 uid 后点击查询
- }, []);
-
- const columns = useMemo(() => [
- { title: t('columns.postId' as any), dataIndex: 'postId', key: 'postId', width: 180, ellipsis: true },
- { title: t('columns.platform' as any), dataIndex: 'platform', key: 'platform', width: 100, render: (v: string) => <Tag>{v}</Tag> },
- { title: t('columns.title' as any), dataIndex: 'title', key: 'title', width: 240, ellipsis: true },
- { title: t('columns.mediaType' as any), dataIndex: 'mediaType', key: 'mediaType', width: 100, render: (v: string) => <Tag color={v==='video'?'blue':v==='image'?'green':'purple'}>{v}</Tag> },
- { title: t('columns.publishTime' as any), dataIndex: 'publishTime', key: 'publishTime', width: 180, render: (ts: number) => new Date(ts).toLocaleString() },
- { title: t('columns.viewCount' as any), dataIndex: 'viewCount', key: 'viewCount', width: 120 },
- { title: t('columns.likeCount' as any), dataIndex: 'likeCount', key: 'likeCount', width: 120 },
- { title: t('columns.commentCount' as any), dataIndex: 'commentCount', key: 'commentCount', width: 120 },
- { title: t('columns.shareCount' as any), dataIndex: 'shareCount', key: 'shareCount', width: 120 },
- { title: t('columns.clickCount' as any), dataIndex: 'clickCount', key: 'clickCount', width: 120 },
- { title: t('columns.impressionCount' as any), dataIndex: 'impressionCount', key: 'impressionCount', width: 140 },
- { title: t('columns.favoriteCount' as any), dataIndex: 'favoriteCount', key: 'favoriteCount', width: 120 },
- { title: t('columns.permaLink' as any), dataIndex: 'permaLink', key: 'permaLink', width: 200, render: (url: string) => url ? <a href={url} target="_blank">{t('columns.open' as any)}</a> : '-' },
- ], [t]);
-
- return (
- <div style={{ padding: 16 }}>
- <Card
- title={t('title' as any)}
- extra={
- <Space wrap>
- <Select value={platform} onChange={setPlatform} style={{ width: 140 }}>
- {['bilibili','douyin','facebook','wxGzh','instagram','KWAI','pinterest','threads','tiktok','twitter','xhs','youtube'].map(p => (
- <Option key={p} value={p}>{p}</Option>
- ))}
- </Select>
- <Input value={uid} placeholder={t('placeholders.uid' as any)} onChange={(e) => setUid(e.target.value)} style={{ width: 220 }} />
- <Button type="primary" onClick={() => { setPage(1); fetchPosts(1, pageSize); }}>{t('actions.search' as any)}</Button>
- <Button onClick={() => { setUid(''); setPosts([]); setTotal(0); }}>{t('actions.reset' as any)}</Button>
- </Space>
- }
- >
- <Table
- rowKey={(r) => `${r.platform}-${r.postId}`}
- columns={columns as any}
- dataSource={posts}
- loading={loading}
- pagination={{
- current: page,
- pageSize,
- total,
- showSizeChanger: true,
- onChange: (p, s) => { setPage(p); setPageSize(s || 20); fetchPosts(p, s || 20); },
- showTotal: (t) => t ? `${t}` : '0'
- }}
- scroll={{ x: 1400 }}
- />
- </Card>
- </div>
- );
-}
-
-
diff --git a/src/app/[lng]/interactive/interactive.module.css b/src/app/[lng]/interactive/interactive.module.css
new file mode 100644
index 00000000..6bb5574f
--- /dev/null
+++ b/src/app/[lng]/interactive/interactive.module.css
@@ -0,0 +1,524 @@
+.container {
+ padding: 24px;
+ min-height: 100vh;
+}
+
+/* 页面头部样式 */
+.header {
+ margin-bottom: 24px;
+}
+
+.headerContent {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ border-radius: 16px;
+ padding: 24px;
+ color: white;
+ box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
+ position: relative;
+ overflow: hidden;
+}
+
+.headerContent::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
+ animation: shimmer 3s ease-in-out infinite;
+}
+
+@keyframes shimmer {
+ 0%, 100% { transform: translateX(-100%); }
+ 50% { transform: translateX(100%); }
+}
+
+.headerLeft {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ position: relative;
+ z-index: 1;
+}
+
+.headerIcon {
+ width: 64px;
+ height: 64px;
+ background: rgba(255, 255, 255, 0.2);
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 28px;
+ backdrop-filter: blur(10px);
+ border: 2px solid rgba(255, 255, 255, 0.3);
+}
+
+.headerText {
+ flex: 1;
+}
+
+.headerTitle {
+ font-size: 28px;
+ font-weight: 700;
+ margin: 0 0 8px 0;
+ background: linear-gradient(135deg, #ffffff, #f0f0f0);
+ -webkit-background-clip: text;
+ -webkit-text-fill-color: transparent;
+ background-clip: text;
+}
+
+.headerSubtitle {
+ font-size: 16px;
+ margin: 0;
+ color: rgba(255, 255, 255, 0.9);
+ font-weight: 400;
+}
+
+.headerRight {
+ position: relative;
+ z-index: 1;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+}
+
+.balanceCard {
+ background: rgba(255, 255, 255, 0.15);
+ border-radius: 12px;
+ padding: 20px;
+ backdrop-filter: blur(10px);
+ border: 1px solid rgba(255, 255, 255, 0.2);
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-width: 200px;
+}
+
+
+.walletLink {
+ display: inline-flex;
+ align-items: center;
+ padding: 6px 8px;
+ color: #ffffff;
+ opacity: 0.9;
+ cursor: pointer;
+ border-radius: 8px;
+ transition: all 0.2s ease;
+}
+
+.walletLink:hover {
+ background: rgba(255, 255, 255, 0.18);
+ opacity: 1;
+}
+
+.balanceIcon {
+ width: 48px;
+ height: 48px;
+ background: rgba(255, 255, 255, 0.2);
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 20px;
+ color: #fff;
+}
+
+.balanceInfo {
+ flex: 1;
+}
+
+.balanceLabel {
+ font-size: 14px;
+ color: rgba(255, 255, 255, 0.8);
+ margin-bottom: 4px;
+}
+
+.balanceAmount {
+ font-size: 24px;
+ font-weight: 700;
+ color: #fff;
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
+}
+
+/* 主要内容样式 */
+.content {
+ background: rgba(255, 255, 255, 0.95);
+ border-radius: 16px;
+ padding: 24px;
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
+ backdrop-filter: blur(10px);
+ border: 1px solid rgba(255, 255, 255, 0.2);
+}
+
+/* 标签页样式 */
+.content .ant-tabs > .ant-tabs-nav {
+ margin-bottom: 24px;
+ background: rgba(255, 255, 255, 0.5);
+ border-radius: 12px;
+ padding: 4px;
+ backdrop-filter: blur(10px);
+}
+
+.content .ant-tabs > .ant-tabs-nav .ant-tabs-tab {
+ padding: 12px 24px;
+ font-size: 16px;
+ font-weight: 600;
+ border-radius: 8px;
+ transition: all 0.3s ease;
+ margin: 0 4px;
+}
+
+.content .ant-tabs > .ant-tabs-nav .ant-tabs-tab-active {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ color: white;
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
+}
+
+.content .ant-tabs > .ant-tabs-nav .ant-tabs-tab:hover {
+ background: rgba(102, 126, 234, 0.1);
+ color: #667eea;
+}
+
+.content .ant-tabs > .ant-tabs-nav .ant-tabs-tab-active:hover {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ color: white;
+}
+
+/* 卡片样式 */
+.content .ant-card {
+ border-radius: 12px;
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
+ border: 1px solid rgba(0, 0, 0, 0.06);
+ overflow: hidden;
+}
+
+.content .ant-card-head {
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);
+}
+
+.content .ant-card-head-title {
+ font-size: 18px;
+ font-weight: 600;
+ color: #495057;
+}
+
+/* 表格样式 */
+.content .ant-table-thead > tr > th {
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
+ color: #495057;
+ font-weight: 600;
+ font-size: 14px;
+ padding: 16px 12px;
+ border-bottom: 2px solid #dee2e6;
+}
+
+.content .ant-table-tbody > tr:hover > td {
+ background-color: rgba(102, 126, 234, 0.05);
+}
+
+.content .ant-table-tbody > tr > td {
+ padding: 12px;
+ font-size: 14px;
+ border-bottom: 1px solid #f0f0f0;
+}
+
+.content .ant-table-tbody > tr:last-child > td {
+ border-bottom: none;
+}
+
+/* 按钮样式 */
+.content .ant-btn {
+ border-radius: 8px;
+ font-weight: 500;
+ transition: all 0.3s ease;
+ border: none;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+}
+
+.content .ant-btn-primary {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ color: white;
+}
+
+.content .ant-btn-primary:hover {
+ background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
+}
+
+.content .ant-btn-primary:disabled {
+ background: #d9d9d9;
+ color: rgba(0, 0, 0, 0.25);
+ transform: none;
+ box-shadow: none;
+}
+
+.content .ant-btn-default {
+ background: white;
+ color: #495057;
+ border: 1px solid #d9d9d9;
+}
+
+.content .ant-btn-default:hover {
+ background: #f8f9fa;
+ border-color: #667eea;
+ color: #667eea;
+ transform: translateY(-1px);
+}
+
+/* 标签样式 */
+.content .ant-tag {
+ border-radius: 6px;
+ font-size: 12px;
+ padding: 4px 8px;
+ font-weight: 500;
+ border: none;
+}
+
+/* 分页样式 */
+.content .ant-pagination {
+ margin-top: 24px;
+ text-align: center;
+}
+
+.content .ant-pagination .ant-pagination-item {
+ border-radius: 8px;
+ border: 1px solid #d9d9d9;
+}
+
+.content .ant-pagination .ant-pagination-item-active {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ border-color: #667eea;
+}
+
+.content .ant-pagination .ant-pagination-item-active a {
+ color: white;
+}
+
+.content .ant-pagination .ant-pagination-prev,
+.content .ant-pagination .ant-pagination-next {
+ border-radius: 8px;
+ border: 1px solid #d9d9d9;
+}
+
+/* 提现弹窗样式 */
+.withdrawModalContent {
+ padding: 20px 0;
+}
+
+.withdrawInfo {
+ background: #f8f9fa;
+ border-radius: 12px;
+ padding: 20px;
+ margin-bottom: 20px;
+ border: 1px solid #e9ecef;
+}
+
+.withdrawItem {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 12px;
+ padding: 8px 0;
+ border-bottom: 1px solid #e9ecef;
+}
+
+.withdrawItem:last-child {
+ margin-bottom: 0;
+ border-bottom: none;
+}
+
+.withdrawLabel {
+ font-weight: 600;
+ color: #495057;
+ font-size: 14px;
+}
+
+.withdrawValue {
+ color: #6c757d;
+ font-size: 14px;
+ word-break: break-all;
+ max-width: 200px;
+ text-align: right;
+}
+
+.withdrawAmount {
+ color: #28a745;
+ font-weight: 700;
+ font-size: 16px;
+}
+
+.withdrawWarning {
+ background: #fff3cd;
+ border: 1px solid #ffeaa7;
+ border-radius: 8px;
+ padding: 16px;
+ color: #856404;
+}
+
+.withdrawWarning p {
+ margin: 0 0 8px 0;
+ font-size: 14px;
+ line-height: 1.5;
+}
+
+.withdrawWarning p:last-child {
+ margin-bottom: 0;
+}
+
+/* 移动端适配 */
+@media (max-width: 768px) {
+ .container {
+ padding: 12px;
+ }
+
+ .headerContent {
+ flex-direction: column;
+ gap: 20px;
+ padding: 20px;
+ text-align: center;
+ }
+
+ .headerLeft {
+ flex-direction: column;
+ gap: 12px;
+ }
+
+ .headerIcon {
+ width: 48px;
+ height: 48px;
+ font-size: 20px;
+ }
+
+ .headerTitle {
+ font-size: 24px;
+ }
+
+ .headerSubtitle {
+ font-size: 14px;
+ }
+
+ .balanceCard {
+ min-width: auto;
+ width: 100%;
+ justify-content: center;
+ }
+
+ .balanceAmount {
+ font-size: 20px;
+ }
+
+ .content {
+ padding: 16px;
+ }
+
+ .content .ant-tabs > .ant-tabs-nav .ant-tabs-tab {
+ padding: 8px 16px;
+ font-size: 14px;
+ }
+
+ .content .ant-table-thead > tr > th,
+ .content .ant-table-tbody > tr > td {
+ padding: 8px 6px;
+ font-size: 12px;
+ }
+
+ .content .ant-btn {
+ font-size: 12px;
+ padding: 4px 8px;
+ }
+
+ .withdrawItem {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 4px;
+ }
+
+ .withdrawValue {
+ max-width: none;
+ text-align: left;
+ }
+}
+
+@media (max-width: 480px) {
+ .headerContent {
+ padding: 16px;
+ }
+
+ .headerTitle {
+ font-size: 20px;
+ }
+
+ .balanceCard {
+ padding: 16px;
+ }
+
+ .content {
+ padding: 12px;
+ }
+
+ .content .ant-tabs > .ant-tabs-nav .ant-tabs-tab {
+ padding: 6px 12px;
+ font-size: 12px;
+ }
+}
+
+/* 互动卡片瀑布流 */
+.grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
+ gap: 12px;
+}
+
+.postCard {
+ background: #fff;
+ border: 1px solid #e9ecef;
+ border-radius: 8px;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+}
+
+.thumb {
+ position: relative;
+ width: 100%;
+ padding-top: 66%;
+ background: #fafafa;
+}
+.thumb img {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+.thumbPlaceholder {
+ position: absolute;
+ inset: 0;
+ display: flex; align-items: center; justify-content: center;
+ color: #999;
+}
+.mediaType {
+ position: absolute;
+ left: 8px; bottom: 8px;
+}
+.postMeta {
+ padding: 10px;
+}
+.postTitle {
+ font-size: 14px; font-weight: 600; color: #111;
+ line-height: 1.4; max-height: 3.2em; overflow: hidden;
+}
+.statsRow {
+ display: flex; gap: 10px; color: #666; font-size: 12px; margin-top: 6px;
+}
+.actionsRow {
+ display: flex; align-items: center; justify-content: space-between; margin-top: 8px;
+}
\ No newline at end of file
diff --git a/src/app/[lng]/interactive/page.tsx b/src/app/[lng]/interactive/page.tsx
new file mode 100644
index 00000000..93e41c30
--- /dev/null
+++ b/src/app/[lng]/interactive/page.tsx
@@ -0,0 +1,271 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { Card, Button, message, Tag, Space, Select, Modal, Input, List, Avatar } from "antd";
+import { DollarOutlined, HistoryOutlined, WalletOutlined } from "@ant-design/icons";
+import { useParams, useRouter } from "next/navigation";
+import { useUserStore } from "@/store/user";
+import { apiGetEngagementPosts, apiGetEngagementComments, apiReplyEngagementComment, apiGetPostComments, apiPublishPostComment, apiPublishCommentReply } from "@/api/engagement";
+import { EngagementPostItem, EngagementPlatform } from "@/api/types/engagement";
+import { useTransClient } from "@/app/i18n/client";
+import styles from "./interactive.module.css";
+import WalletAccountSelect from "@/components/WalletAccountSelect";
+import { useAccountStore } from "@/store/account";
+import { useShallow } from "zustand/react/shallow";
+import AccountSidebar from "@/app/[lng]/accounts/components/AccountSidebar/AccountSidebar";
+import { NoSSR } from "@kwooshung/react-no-ssr";
+
+const { Option } = Select;
+
+export default function InteractivePage() {
+ const router = useRouter();
+ const { lng } = useParams();
+ const { userInfo, token } = useUserStore();
+ const { t } = useTransClient('interactive' as any);
+ const tt = t as any;
+
+ // 账户侧边栏相关
+ const { accountInit, accountActive, setAccountActive } = useAccountStore(
+ useShallow((state) => ({
+ accountInit: state.accountInit,
+ accountActive: state.accountActive,
+ setAccountActive: state.setAccountActive,
+ })),
+ );
+
+ // 互动帖子列表状态
+ const [posts, setPosts] = useState<EngagementPostItem[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [pagination, setPagination] = useState({ current: 1, pageSize: 20, total: 0 });
+ const [platform, setPlatform] = useState<EngagementPlatform | undefined>(undefined);
+ // 评论状态
+ const [commentVisible, setCommentVisible] = useState(false);
+ const [commentLoading, setCommentLoading] = useState(false);
+ const [commentPost, setCommentPost] = useState<EngagementPostItem | null>(null);
+ const [comments, setComments] = useState<any[]>([]);
+ const [commentsCursor, setCommentsCursor] = useState<{ before?: string; after?: string } | undefined>();
+ const [commentsTotal, setCommentsTotal] = useState<number | undefined>(undefined);
+ const [replyText, setReplyText] = useState('');
+
+ // 获取互动帖子
+ const fetchEngagementPosts = async (page: number = 1, pageSize: number = 20) => {
+ if (!accountActive?.uid || !platform) return;
+ setLoading(true);
+ try {
+ const res = await apiGetEngagementPosts({
+ platform,
+ uid: accountActive.uid,
+ page,
+ pageSize
+ });
+ if (res?.data) {
+ setPosts(res.data.posts || []);
+ setPagination({ current: page, pageSize, total: res.data.total || 0 });
+ }
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ // 账户或平台变化时刷新
+ useEffect(() => {
+ if (accountActive?.uid && platform) {
+ fetchEngagementPosts(1, pagination.pageSize);
+ } else {
+ setPosts([]);
+ setPagination((prev) => ({ ...prev, total: 0, current: 1 }));
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [accountActive?.uid, platform]);
+
+ // 当切换账户时,自动根据账户平台设置 platform 并触发刷新
+ useEffect(() => {
+ if (!accountActive) return;
+ const type = String((accountActive as any).type || '').toLowerCase();
+ const map: Record<string, EngagementPlatform> = {
+ bilibili: 'bilibili',
+ douyin: 'douyin',
+ facebook: 'facebook',
+ wxgzh: 'wxGzh',
+ wxsph: 'wxGzh',
+ instagram: 'instagram',
+ kwai: 'KWAI',
+ kuaishou: 'KWAI',
+ pinterest: 'pinterest',
+ threads: 'threads',
+ tiktok: 'tiktok',
+ twitter: 'twitter',
+ xhs: 'xhs',
+ redbook: 'xhs',
+ youtube: 'youtube',
+ };
+ const mapped = map[type];
+ if (mapped && mapped !== platform) {
+ setPlatform(mapped);
+ }
+ // 如果已有 platform 则不覆盖用户手动选择
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [accountActive?.id]);
+
+ const PostCard = ({ item }: { item: EngagementPostItem }) => {
+ return (
+ <div className={styles.postCard}>
+ <div className={styles.thumb}>
+ {item.thumbnail ? (
+ <img src={item.thumbnail} alt={item.title} />
+ ) : (
+ <div className={styles.thumbPlaceholder}>No Image</div>
+ )}
+ <span className={styles.mediaType}>
+ <Tag color={item.mediaType==='video'?'blue':item.mediaType==='image'?'green':'purple'}>{item.mediaType}</Tag>
+ </span>
+ </div>
+ <div className={styles.postMeta}>
+ <div className={styles.postTitle} title={item.title}>{item.title || '-'}</div>
+ <div className={styles.statsRow}>
+ <span>👍 {item.likeCount}</span>
+ <span>💬 {item.commentCount}</span>
+ <span>👁️ {item.viewCount}</span>
+ </div>
+ <div className={styles.actionsRow}>
+ {item.permaLink ? <a href={item.permaLink} target="_blank">打开</a> : <span>-</span>}
+ <Space size={8}>
+ <Button size="small" onClick={() => openComments(item)}>评论</Button>
+ </Space>
+ </div>
+ </div>
+ </div>
+ );
+ };
+
+ const openComments = async (item: EngagementPostItem) => {
+ setCommentPost(item);
+ setComments([]);
+ setCommentVisible(true);
+ await loadCommentsV2(item.postId, undefined, undefined);
+ };
+
+ const loadCommentsV2 = async (postId: string, before?: string, after?: string) => {
+ if (!accountActive?.id || !platform) return;
+ setCommentLoading(true);
+ try {
+ const res = await apiGetPostComments({
+ accountId: accountActive.id,
+ platform: platform as any,
+ postId,
+ pagination: { before, after, limit: 20 }
+ });
+ if (res?.data) {
+ const list = res.data.comments || [];
+ setComments((prev) => after || before ? [...prev, ...list] : list);
+ setCommentsTotal(res.data.total);
+ setCommentsCursor(res.data.cursor);
+ }
+ } finally {
+ setCommentLoading(false);
+ }
+ };
+
+ const submitPostComment = async () => {
+ if (!commentPost || !replyText.trim() || !accountActive?.id || !platform) return;
+ const res = await apiPublishPostComment({ accountId: accountActive.id, platform: platform as any, postId: commentPost.postId, message: replyText.trim() });
+ if (res) {
+ setReplyText('');
+ await loadCommentsV2(commentPost.postId);
+ message.success('已评论');
+ }
+ };
+
+ const submitReply = async (parentId?: string) => {
+ if (!commentPost || !replyText.trim() || !accountActive?.id || !platform) return;
+ const res = await apiPublishCommentReply({ accountId: accountActive.id, platform: platform as any, commentId: parentId || '', message: replyText.trim() });
+ if (res) {
+ setReplyText('');
+ await loadCommentsV2(commentPost.postId);
+ message.success('已回复');
+ }
+ };
+
+ // 删除与收入/提现相关方法(本页不需要)
+
+ // 删除收入/提现相关列定义(本页不需要)
+
+ useEffect(() => {
+ if (!token) {
+ message.error(tt('messages.pleaseLoginFirst'));
+ router.push('/login');
+ return;
+ }
+
+ // 初始化账户
+ accountInit();
+ }, [token, router]);
+
+ return (
+ <NoSSR>
+ <div className={styles.container} style={{ display: 'flex', gap: 16 }}>
+ {/* 左侧账户选择栏 */}
+ <div >
+ <AccountSidebar
+ activeAccountId={accountActive?.id || ''}
+ onAccountChange={(account) => {
+ if (account.id === accountActive?.id) {
+ setAccountActive(undefined);
+ } else {
+ setAccountActive(account);
+ }
+ }}
+ />
+ </div>
+
+ {/* 右侧内容 */}
+ <div style={{ flex: 1, minWidth: 0 }}>
+
+ {/* 主要内容:互动帖子卡片瀑布流 */}
+ <div className={styles.content}>
+ <div className={styles.grid}>
+ {posts.map((item) => (
+ <PostCard key={`${item.platform}-${item.postId}`} item={item} />
+ ))}
+ </div>
+ <div style={{ display: 'flex', justifyContent: 'center', marginTop: 12 }}>
+ <Button loading={loading} onClick={() => fetchEngagementPosts(pagination.current + 1, pagination.pageSize)} disabled={loading || posts.length >= pagination.total}>加载更多</Button>
+ </div>
+ </div>
+
+ {/* 评论弹窗 */}
+ <Modal
+ open={commentVisible}
+ onCancel={() => setCommentVisible(false)}
+ title={commentPost?.title || '评论'}
+ footer={null}
+ width={600}
+ >
+ <List
+ loading={commentLoading}
+ dataSource={comments}
+ renderItem={(c: any) => (
+ <List.Item
+ actions={[<a key="reply" onClick={() => submitReply(c.id)}>回复</a>]}
+ >
+ <List.Item.Meta
+ avatar={<Avatar src={c.author?.avatar} />}
+ title={<span>{c.author?.name || c.author?.id} · {new Date(c.createdAt).toLocaleString()}</span>}
+ description={c.message}
+ />
+ </List.Item>
+ )}
+ />
+ <div style={{ display: 'flex', gap: 8, marginTop: 12 }}>
+ <Input.TextArea value={replyText} onChange={(e) => setReplyText(e.target.value)} rows={3} placeholder="输入评论..." />
+ <Button type="primary" onClick={submitPostComment}>发送</Button>
+ </div>
+ <div style={{ display: 'flex', justifyContent: 'center', marginTop: 10 }}>
+ <Button onClick={() => loadCommentsV2(commentPost!.postId, undefined, commentsCursor?.after)} loading={commentLoading} disabled={!commentsCursor?.after}>加载更多评论</Button>
+ </div>
+ </Modal>
+ </div>
+ </div>
+ </NoSSR>
+ );
+}
diff --git a/src/app/layout/routerData.ts b/src/app/layout/routerData.ts
index 62349da7..2f56f90b 100644
--- a/src/app/layout/routerData.ts
+++ b/src/app/layout/routerData.ts
@@ -44,8 +44,8 @@ export const routerData: IRouterDataItem[] = [
},
{
name: "互动数据",
- translationKey: "engagement",
- path: "/engagement",
+ translationKey: "interactive",
+ path: "/interactive",
},
{
name: "数据统计",