Skip to content

Let's use AI to Earn!

增加进行中互动

zhang767653317acc96c5193f7
diff --git a/src/views/interaction/index.tsx b/src/views/interaction/index.tsx
index cf34dc0f..4d442b50 100644
--- a/src/views/interaction/index.tsx
+++ b/src/views/interaction/index.tsx
@@ -33,7 +33,7 @@ export default function Page() {
const Ref_InteractionOneKey = useRef<InteractionOneKeyRef>(null);
async function getCreatorList(accountId: number) {
- const res = await getCommentSearchNotes(accountId, '英雄杀道一', {
+ const res = await getCommentSearchNotes(accountId, '爱团团', {
...pageInfo,
postFirstId: '',
});
diff --git a/src/views/replyother/replyother.tsx b/src/views/replyother/replyother.tsx
index 278962cf..ca4a6362 100644
--- a/src/views/replyother/replyother.tsx
+++ b/src/views/replyother/replyother.tsx
@@ -4,6 +4,9 @@ import {
WorkData,
CommentData,
getCommentSearchNotes,
+ ipcGetInteractionRecordList,
+ ipcGetAutoRunOfInteractionInfo,
+ icpDianzanDyOther, icpShoucangDyOther
} from '@/icp/replyother';
import {
Avatar,
@@ -26,6 +29,8 @@ import {
Tooltip,
Spin,
Checkbox,
+ Tabs,
+ Table,
} from 'antd';
import { useCallback, useRef, useState, useEffect } from 'react';
import AccountSidebar from '../account/components/AccountSidebar/AccountSidebar';
@@ -33,7 +38,6 @@ import styles from './reply.module.scss';
import ReplyWorks, { ReplyWorksRef } from './components/replyWorks';
import ReplyComment, { ReplyCommentRef } from './components/replyComment';
import AddAutoRun, { AddAutoRunRef } from './components/addAutoRun';
-import { icpDianzanDyOther, icpShoucangDyOther } from '@/icp/replyother';
import {
LikeOutlined,
StarOutlined,
@@ -47,6 +51,7 @@ import {
SendOutlined,
DownOutlined,
QuestionCircleOutlined,
+ SyncOutlined,
} from '@ant-design/icons';
import Masonry from 'react-masonry-css';
import { AccountModel } from '../../../electron/db/models/account';
@@ -113,6 +118,75 @@ export default function Page() {
{},
);
+ // 添加互动记录相关状态
+ const [interactionRecords, setInteractionRecords] = useState<any[]>([]);
+ const [interactionPageInfo, setInteractionPageInfo] = useState({
+ page_size: 10,
+ page_no: 1,
+ total: 0,
+ });
+
+ // 添加进程中互动相关状态
+ const [runningInteractions, setRunningInteractions] = useState<any[]>([]);
+
+ // 获取进程中互动信息
+ const getRunningInteractions = async () => {
+ try {
+ console.log('------ 开始获取进程中互动信息');
+ const res = await ipcGetAutoRunOfInteractionInfo();
+ console.log('------ 获取进程中互动信息结果:', res);
+ setRunningInteractions(res || []);
+ } catch (error) {
+ console.error('------ 获取进程中互动信息失败:', error);
+ message.error('获取进程中互动信息失败');
+ }
+ };
+
+ // 定期获取进程中互动信息
+ useEffect(() => {
+ if (activeAccountId !== -1) {
+ getRunningInteractions();
+ const timer = setInterval(() => {
+ getRunningInteractions();
+ }, 5000); // 每5秒更新一次
+ return () => clearInterval(timer);
+ }
+ }, [activeAccountId]);
+
+ // 获取互动记录
+ const getInteractionRecords = async () => {
+ try {
+ console.log('------ 开始获取互动记录', activeAccountId, 'activeAccountType:', activeAccountType);
+ const res = await ipcGetInteractionRecordList(
+ {
+ page_size: interactionPageInfo.page_size,
+ page_no: interactionPageInfo.page_no,
+ },
+ {
+ accountId: activeAccountId,
+ type: activeAccountType as any,
+ }
+ );
+ console.log('------ 获取互动记录结果:', res);
+ const data:any = res;
+ setInteractionRecords(data.list || []);
+ setInteractionPageInfo(prev => ({
+ ...prev,
+ total: data.total || 0
+ }));
+ } catch (error) {
+ console.error('------ 获取互动记录失败:', error);
+ message.error('获取互动记录失败');
+ }
+ };
+
+ // 监听账户变化,重新获取记录
+ useEffect(() => {
+ if (activeAccountId !== -1) {
+ getInteractionRecords();
+ }
+ }, [activeAccountId, activeAccountType]);
+
// 添加任务表单相关状态
const [taskForm] = Form.useForm();
const [commentType, setCommentType] = useState<'ai' | 'custom'>('ai');
@@ -288,7 +362,7 @@ export default function Page() {
>({});
// 添加搜索关键词状态
- const [searchKeyword, setSearchKeyword] = useState('英雄杀道一');
+ const [searchKeyword, setSearchKeyword] = useState('爱团团');
async function getCreatorList(thisid: any) {
setWordList([]);
@@ -633,7 +707,6 @@ export default function Page() {
return (
<div className={styles.reply} style={{ alignItems: 'flex-start' }}>
<div style={{ display: 'flex', flexDirection: 'row', height: '100%' }}>
- {/* <Col span={3}> */}
<AccountSidebar
activeAccountId={activeAccountId}
onAccountChange={useCallback(
@@ -657,9 +730,7 @@ export default function Page() {
[getCreatorList],
)}
/>
- {/* </Col> */}
- {/* <Col span={21} > */}
<div className={styles.postList} style={{ flex: 1, padding: '20px' }}>
{activeAccountId === -1 ? (
<div className={styles.account}>
@@ -670,175 +741,323 @@ export default function Page() {
</div>
) : (
<>
- <Row
- justify="space-between"
- align="middle"
- style={{ marginBottom: 20 }}
- >
- <Col>
- <Typography.Title level={4} style={{ margin: 0 }}>
- 任务:
- </Typography.Title>
- </Col>
- <Col flex="auto" style={{ margin: '0 20px' }}>
- <Input.Search
- placeholder="输入关键词搜索"
- value={searchKeyword}
- onChange={(e) => setSearchKeyword(e.target.value)}
- onSearch={handleSearch}
- style={{ width: '100%' }}
- enterButton
- />
- </Col>
- <Col>
- <Space>
- <Button
- type={isSelectMode ? "primary" : "default"}
- icon={<DownOutlined />}
- onClick={handleSelectModeToggle}
- size="large"
- >
- {isSelectMode ? '取消选择' : '选择作品'}
- </Button>
- {isSelectMode && (
- <Button
- type="primary"
- icon={<SendOutlined />}
- onClick={() => setTaskModalVisible(true)}
- size="large"
- disabled={selectedPosts.length === 0}
- >
- 下发任务 ({selectedPosts.length})
- </Button>
- )}
- {!isSelectMode && (
- <Button
- type="primary"
- icon={<DownOutlined />}
- onClick={() => setTaskModalVisible(true)}
- size="large"
- >
- 下发任务
- </Button>
- )}
- </Space>
- </Col>
- </Row>
-
- <Masonry
- breakpointCols={breakpointColumnsObj}
- className={styles.myMasonryGrid}
- columnClassName={styles.myMasonryGridColumn}
- >
- {postList.map((item: any, index: number) => (
- <div
- key={`${item.dataId || item.coverUrl}-${index}`}
- className={styles.masonryItem}
- >
- <Card
- hoverable
- cover={
- <div
- style={{ cursor: 'pointer', position: 'relative' }}
- onClick={() => !isSelectMode && handleImageClick(item)}
+ <Tabs
+ defaultActiveKey="1"
+ items={[
+ {
+ key: '1',
+ label: '作品列表',
+ children: (
+ <>
+ <Row
+ justify="space-between"
+ align="middle"
+ style={{ marginBottom: 20 }}
+ >
+ <Col>
+ <Typography.Title level={4} style={{ margin: 0 }}>
+ 任务:
+ </Typography.Title>
+ </Col>
+ <Col flex="auto" style={{ margin: '0 20px' }}>
+ <Input.Search
+ placeholder="输入关键词搜索"
+ value={searchKeyword}
+ onChange={(e) => setSearchKeyword(e.target.value)}
+ onSearch={handleSearch}
+ style={{ width: '100%' }}
+ enterButton
+ />
+ </Col>
+ <Col>
+ <Space>
+ <Button
+ type={isSelectMode ? "primary" : "default"}
+ icon={<DownOutlined />}
+ onClick={handleSelectModeToggle}
+ size="large"
+ >
+ {isSelectMode ? '取消选择' : '选择作品'}
+ </Button>
+ {isSelectMode && (
+ <Button
+ type="primary"
+ icon={<SendOutlined />}
+ onClick={() => setTaskModalVisible(true)}
+ size="large"
+ disabled={selectedPosts.length === 0}
+ >
+ 下发任务 ({selectedPosts.length})
+ </Button>
+ )}
+ {!isSelectMode && (
+ <Button
+ type="primary"
+ icon={<DownOutlined />}
+ onClick={() => setTaskModalVisible(true)}
+ size="large"
+ >
+ 下发任务
+ </Button>
+ )}
+ </Space>
+ </Col>
+ </Row>
+
+ <Masonry
+ breakpointCols={breakpointColumnsObj}
+ className={styles.myMasonryGrid}
+ columnClassName={styles.myMasonryGridColumn}
>
- {isSelectMode && (
- <div style={{ position: 'absolute', top: 10, left: 10, zIndex: 1 }}>
- <Checkbox
- checked={selectedPosts.includes(item.dataId)}
- onChange={() => handlePostSelect(item.dataId)}
- />
+ {postList.map((item: any, index: number) => (
+ <div
+ key={`${item.dataId || item.coverUrl}-${index}`}
+ className={styles.masonryItem}
+ >
+ <Card
+ hoverable
+ cover={
+ <div
+ style={{ cursor: 'pointer', position: 'relative' }}
+ onClick={() => !isSelectMode && handleImageClick(item)}
+ >
+ {isSelectMode && (
+ <div style={{ position: 'absolute', top: 10, left: 10, zIndex: 1 }}>
+ <Checkbox
+ checked={selectedPosts.includes(item.dataId)}
+ onChange={() => handlePostSelect(item.dataId)}
+ />
+ </div>
+ )}
+ <img
+ alt={item.title}
+ src={item.coverUrl}
+ style={{
+ width: '100%',
+ borderRadius: '10px 10px 0 0',
+ objectFit: 'cover',
+ }}
+ />
+ </div>
+ }
+ actions={[
+ <Space key="like" onClick={() => likePost(item)}>
+ <LikeOutlined
+ style={{
+ color: likedPosts[item.dataId]
+ ? '#ff4d4f'
+ : undefined,
+ fontSize: likedPosts[item.dataId]
+ ? '18px'
+ : undefined,
+ }}
+ />
+ <span>{item.likeCount || 0}</span>
+ </Space>,
+ <Space
+ key="comment-list"
+ onClick={() => showCommentModal(item)}
+ >
+ <UnorderedListOutlined />
+ <span>{item.commentCount || ''}</span>
+ </Space>,
+ <Space key="reply" onClick={() => openReplyWorks(item)}>
+ <CommentOutlined />
+ <span>评论</span>
+ </Space>,
+ <Space key="collect" onClick={() => collectPost(item)}>
+ <StarOutlined
+ style={{
+ color: collectedPosts[item.dataId]
+ ? '#faad14'
+ : undefined,
+ fontSize: collectedPosts[item.dataId]
+ ? '18px'
+ : undefined,
+ }}
+ />
+ <span>{item.collectCount || ''}</span>
+ </Space>,
+ ]}
+ >
+ <Card.Meta
+ avatar={<Avatar src={`${item.author?.avatar}`} />}
+ title={item.author?.name}
+ description={
+ <div>
+ <Text strong ellipsis style={{ display: 'block' }}>
+ {item.title}
+ </Text>
+ <Text type="secondary" ellipsis={{}}>
+ {item.content}
+ </Text>
+ </div>
+ }
+ />
+ </Card>
+ </div>
+ ))}
+ </Masonry>
+
+ {/* 加载更多区域 */}
+ <div ref={loadMoreRef} className={styles.loadMoreArea}>
+ {isLoadingMore && (
+ <div className={styles.loadingMore}>
+ <Spin size="small" />
+ <span style={{ marginLeft: 8 }}>加载中...</span>
</div>
)}
- <img
- alt={item.title}
- src={item.coverUrl}
- style={{
- width: '100%',
- borderRadius: '10px 10px 0 0',
- objectFit: 'cover',
- }}
- />
- </div>
- }
- actions={[
- <Space key="like" onClick={() => likePost(item)}>
- <LikeOutlined
- style={{
- color: likedPosts[item.dataId]
- ? '#ff4d4f'
- : undefined,
- fontSize: likedPosts[item.dataId]
- ? '18px'
- : undefined,
- }}
- />
- <span>{item.likeCount || 0}</span>
- </Space>,
- <Space
- key="comment-list"
- onClick={() => showCommentModal(item)}
- >
- <UnorderedListOutlined />
- <span>{item.commentCount || ''}</span>
- </Space>,
- <Space key="reply" onClick={() => openReplyWorks(item)}>
- <CommentOutlined />
- <span>评论</span>
- </Space>,
- <Space key="collect" onClick={() => collectPost(item)}>
- <StarOutlined
- style={{
- color: collectedPosts[item.dataId]
- ? '#faad14'
- : undefined,
- fontSize: collectedPosts[item.dataId]
- ? '18px'
- : undefined,
- }}
- />
- <span>{item.collectCount || ''}</span>
- </Space>,
- ]}
- >
- <Card.Meta
- avatar={<Avatar src={`${item.author?.avatar}`} />}
- title={item.author?.name}
- description={
- <div>
- <Text strong ellipsis style={{ display: 'block' }}>
- {item.title}
- </Text>
- <Text type="secondary" ellipsis={{}}>
- {item.content}
- </Text>
- </div>
- }
- />
- </Card>
- </div>
- ))}
- </Masonry>
-
- {/* 加载更多区域 */}
- <div ref={loadMoreRef} className={styles.loadMoreArea}>
- {isLoadingMore && (
- <div className={styles.loadingMore}>
- <Spin size="small" />
- <span style={{ marginLeft: 8 }}>加载中...</span>
- </div>
- )}
- {!pageInfo.hasMore && postList.length > 0 && (
- <div className={styles.noMoreData}>
- <Divider plain>没有更多数据了</Divider>
- </div>
- )}
- </div>
+ {!pageInfo.hasMore && postList.length > 0 && (
+ <div className={styles.noMoreData}>
+ <Divider plain>没有更多数据了</Divider>
+ </div>
+ )}
+ </div>
+ </>
+ ),
+ },
+ {
+ key: '2',
+ label: '互动记录',
+ children: (
+ <div style={{ marginTop: 0 }}>
+ <div style={{ marginBottom: 16, textAlign: 'right' }}>
+ <Button
+ type="primary"
+ icon={<SyncOutlined />}
+ onClick={getInteractionRecords}
+ >
+ 刷新
+ </Button>
+ </div>
+ <Table
+ columns={[
+ {
+ title: '作品ID',
+ dataIndex: 'worksId',
+ key: 'worksId',
+ },
+ {
+ title: '作品标题',
+ dataIndex: 'worksTitle',
+ key: 'worksTitle',
+ },
+ {
+ title: '评论内容',
+ dataIndex: 'commentContent',
+ key: 'commentContent',
+ },
+ {
+ title: '点赞状态',
+ dataIndex: 'isLike',
+ key: 'isLike',
+ render: (isLike) => (isLike ? '已点赞' : '未点赞'),
+ },
+ {
+ title: '收藏状态',
+ dataIndex: 'replyContent',
+ key: 'replyContent',
+ render: (isCollect) => (isCollect ? '已收藏' : '未收藏'),
+ },
+ {
+ title: '互动时间',
+ dataIndex: 'updateTime',
+ key: 'updateTime',
+ render: (updateTime: any) => {
+ const date = new Date(updateTime);
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+ const hours = date.getHours().toString().padStart(2, '0');
+ const minutes = date.getMinutes().toString().padStart(2, '0');
+ return `${month}-${day} ${hours}:${minutes}`;
+ },
+ },
+ ]}
+ dataSource={interactionRecords}
+ rowKey="id"
+ pagination={{
+ total: interactionPageInfo.total,
+ pageSize: interactionPageInfo.page_size,
+ current: interactionPageInfo.page_no,
+ onChange: (page, pageSize) => {
+ setInteractionPageInfo(prev => ({
+ ...prev,
+ page_no: page,
+ page_size: pageSize,
+ }));
+ getInteractionRecords();
+ },
+ }}
+ />
+ </div>
+ ),
+ },
+ {
+ key: '3',
+ label: '进程中互动',
+ children: (
+ <div style={{ marginTop: 20 }}>
+ <div style={{ marginBottom: 16, textAlign: 'right' }}>
+ <Button
+ type="primary"
+ icon={<SyncOutlined />}
+ onClick={getRunningInteractions}
+ >
+ 刷新
+ </Button>
+ </div>
+ <Table
+ columns={[
+ {
+ title: '作品ID',
+ dataIndex: 'worksId',
+ key: 'worksId',
+ },
+ {
+ title: '作品标题',
+ dataIndex: 'worksTitle',
+ key: 'worksTitle',
+ },
+ {
+ title: '状态',
+ dataIndex: 'status',
+ key: 'status',
+ render: (status: number) => {
+ const statusMap: Record<number | string, string> = {
+ 0: '进行中',
+ 1: '已完成',
+ '-1': '失败',
+ };
+ return statusMap[status] || '未知';
+ },
+ },
+ {
+ title: '开始时间',
+ dataIndex: 'startTime',
+ key: 'startTime',
+ render: (startTime: any) => {
+ const date = new Date(startTime);
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
+ const day = date.getDate().toString().padStart(2, '0');
+ const hours = date.getHours().toString().padStart(2, '0');
+ const minutes = date.getMinutes().toString().padStart(2, '0');
+ return `${month}-${day} ${hours}:${minutes}`;
+ },
+ },
+ ]}
+ dataSource={runningInteractions}
+ rowKey="id"
+ pagination={false}
+ />
+ </div>
+ ),
+ },
+ ]}
+ />
</>
)}
</div>
- {/* </Col> */}
</div>
{/* 任务下发弹窗 */}