feat(朋友圈同步): 新增朋友圈同步记录页面及功能

重构朋友圈同步模块结构,将原MomentsSync组件拆分为list和record两个子模块
添加朋友圈同步记录页面,包含搜索、分页和记录展示功能
优化样式文件组织,删除重复代码
新增api接口和数据模型定义
This commit is contained in:
超级老白兔
2025-09-08 16:41:16 +08:00
parent dba6ae164c
commit 527402425f
11 changed files with 779 additions and 20 deletions

View File

@@ -1,14 +1,14 @@
{
"_charts-B9_ggjgM.js": {
"file": "assets/charts-B9_ggjgM.js",
"_charts-DrYFgxF3.js": {
"file": "assets/charts-DrYFgxF3.js",
"name": "charts",
"imports": [
"_ui-CdpU1706.js",
"_ui-BCezweA9.js",
"_vendor-2vc8h_ct.js"
]
},
"_ui-CdpU1706.js": {
"file": "assets/ui-CdpU1706.js",
"_ui-BCezweA9.js": {
"file": "assets/ui-BCezweA9.js",
"name": "ui",
"imports": [
"_vendor-2vc8h_ct.js"
@@ -33,18 +33,18 @@
"name": "vendor"
},
"index.html": {
"file": "assets/index-BZQSHOtN.js",
"file": "assets/index-B7uWDiaN.js",
"name": "index",
"src": "index.html",
"isEntry": true,
"imports": [
"_vendor-2vc8h_ct.js",
"_utils-6WF66_dS.js",
"_ui-CdpU1706.js",
"_charts-B9_ggjgM.js"
"_ui-BCezweA9.js",
"_charts-DrYFgxF3.js"
],
"css": [
"assets/index-CciB7EKw.css"
"assets/index-DkU7m7k6.css"
]
}
}

View File

@@ -11,13 +11,13 @@
</style>
<!-- 引入 uni-app web-view SDK必须 -->
<script type="text/javascript" src="/websdk.js"></script>
<script type="module" crossorigin src="/assets/index-BZQSHOtN.js"></script>
<script type="module" crossorigin src="/assets/index-B7uWDiaN.js"></script>
<link rel="modulepreload" crossorigin href="/assets/vendor-2vc8h_ct.js">
<link rel="modulepreload" crossorigin href="/assets/utils-6WF66_dS.js">
<link rel="modulepreload" crossorigin href="/assets/ui-CdpU1706.js">
<link rel="modulepreload" crossorigin href="/assets/charts-B9_ggjgM.js">
<link rel="modulepreload" crossorigin href="/assets/ui-BCezweA9.js">
<link rel="modulepreload" crossorigin href="/assets/charts-DrYFgxF3.js">
<link rel="stylesheet" crossorigin href="/assets/ui-D0C0OGrH.css">
<link rel="stylesheet" crossorigin href="/assets/index-CciB7EKw.css">
<link rel="stylesheet" crossorigin href="/assets/index-DkU7m7k6.css">
</head>
<body>
<div id="root"></div>

View File

@@ -137,9 +137,6 @@ export default function AutoLikeRecord() {
onChange={handlePageChange}
showSizeChanger={false}
showQuickJumper
showTotal={(total, range) =>
`${range[0]}-${range[1]} 条,共 ${total}`
}
size="default"
className={styles.pagination}
/>

View File

@@ -3,7 +3,7 @@
display: flex;
align-items: center;
gap: 8px;
padding: 0 16px;
padding: 16px;
}
.headerSearchInputWrap {
position: relative;

View File

@@ -124,7 +124,7 @@ const MomentsSync: React.FC = () => {
<Menu.Item
key="view"
icon={<EyeOutlined />}
onClick={() => navigate(`/workspace/moments-sync/${task.id}`)}
onClick={() => navigate(`/workspace/moments-sync/record/${task.id}`)}
>
</Menu.Item>

View File

@@ -0,0 +1,63 @@
import request from "@/api/request";
import {
LikeTask,
CreateLikeTaskData,
UpdateLikeTaskData,
LikeRecord,
PaginatedResponse,
} from "@/pages/workspace/auto-like/record/data";
// 获取自动点赞任务列表
export function fetchAutoLikeTasks(
params = { type: 1, page: 1, limit: 100 },
): Promise<LikeTask[]> {
return request("/v1/workbench/list", params, "GET");
}
// 获取单个任务详情
export function fetchAutoLikeTaskDetail(id: string): Promise<LikeTask | null> {
return request("/v1/workbench/detail", { id }, "GET");
}
// 创建自动点赞任务
export function createAutoLikeTask(data: CreateLikeTaskData): Promise<any> {
return request("/v1/workbench/create", { ...data, type: 1 }, "POST");
}
// 更新自动点赞任务
export function updateAutoLikeTask(data: UpdateLikeTaskData): Promise<any> {
return request("/v1/workbench/update", { ...data, type: 1 }, "POST");
}
// 删除自动点赞任务
export function deleteAutoLikeTask(id: string): Promise<any> {
return request("/v1/workbench/delete", { id }, "DELETE");
}
// 切换任务状态
export function toggleAutoLikeTask(id: string, status: string): Promise<any> {
return request("/v1/workbench/update-status", { id, status }, "POST");
}
// 复制自动点赞任务
export function copyAutoLikeTask(id: string): Promise<any> {
return request("/v1/workbench/copy", { id }, "POST");
}
// 获取点赞记录
export function fetchLikeRecords(
workbenchId: string,
page: number = 1,
limit: number = 20,
keyword?: string,
): Promise<PaginatedResponse<LikeRecord>> {
const params: any = {
workbenchId,
page: page.toString(),
limit: limit.toString(),
};
if (keyword) {
params.keyword = keyword;
}
return request("/v1/workbench/like-records", params, "GET");
}

View File

@@ -0,0 +1,119 @@
// 自动点赞任务状态
export type LikeTaskStatus = 1 | 2; // 1: 开启, 2: 关闭
// 内容类型
export type ContentType = "text" | "image" | "video" | "link";
// 设备信息
export interface Device {
id: string;
name: string;
status: "online" | "offline";
lastActive: string;
}
// 好友信息
export interface Friend {
id: string;
nickname: string;
wechatId: string;
avatar: string;
tags: string[];
region: string;
source: string;
}
// 点赞记录
export interface LikeRecord {
id: string;
workbenchId: string;
momentsId: string;
snsId: string;
wechatAccountId: string;
wechatFriendId: string;
likeTime: string;
content: string;
resUrls: string[];
momentTime: string;
userName: string;
operatorName: string;
operatorAvatar: string;
friendName: string;
friendAvatar: string;
}
// 自动点赞任务
export interface LikeTask {
id: string;
name: string;
status: LikeTaskStatus;
deviceCount: number;
targetGroup: string;
likeCount: number;
lastLikeTime: string;
createTime: string;
creator: string;
likeInterval: number;
maxLikesPerDay: number;
timeRange: { start: string; end: string };
contentTypes: ContentType[];
targetTags: string[];
devices: string[];
friends: string[];
friendMaxLikes: number;
friendTags: string;
enableFriendTags: boolean;
todayLikeCount: number;
totalLikeCount: number;
updateTime: string;
}
// 创建任务数据
export interface CreateLikeTaskData {
name: string;
interval: number;
maxLikes: number;
startTime: string;
endTime: string;
contentTypes: ContentType[];
devices: string[];
friends?: string[];
friendMaxLikes: number;
friendTags?: string;
enableFriendTags: boolean;
targetTags: string[];
}
// 更新任务数据
export interface UpdateLikeTaskData extends CreateLikeTaskData {
id: string;
}
// 任务配置
export interface TaskConfig {
interval: number;
maxLikes: number;
startTime: string;
endTime: string;
contentTypes: ContentType[];
devices: string[];
friends: string[];
friendMaxLikes: number;
friendTags: string;
enableFriendTags: boolean;
}
// API响应类型
export interface ApiResponse<T = any> {
code: number;
msg: string;
data: T;
}
// 分页响应类型
export interface PaginatedResponse<T> {
list: T[];
total: number;
page: number;
limit: number;
}

View File

@@ -0,0 +1,306 @@
import React, { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import {
Button,
Input,
Card,
Badge,
Avatar,
Skeleton,
message,
Spin,
Divider,
Pagination,
} from "antd";
import {
LikeOutlined,
ReloadOutlined,
SearchOutlined,
UserOutlined,
} from "@ant-design/icons";
import styles from "./record.module.scss";
import NavCommon from "@/components/NavCommon";
import { fetchLikeRecords } from "./api";
import Layout from "@/components/Layout/Layout";
// 格式化日期
const formatDate = (dateString: string) => {
try {
const date = new Date(dateString);
return date.toLocaleString("zh-CN", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
});
} catch (error) {
return dateString;
}
};
export default function AutoLikeRecord() {
const { id } = useParams<{ id: string }>();
const [records, setRecords] = useState<any[]>([]);
const [recordsLoading, setRecordsLoading] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const [currentPage, setCurrentPage] = useState(1);
const [total, setTotal] = useState(0);
const pageSize = 10;
useEffect(() => {
if (!id) return;
setRecordsLoading(true);
fetchLikeRecords(id, 1, pageSize)
.then((response: any) => {
setRecords(response.list || []);
setTotal(response.total || 0);
setCurrentPage(1);
})
.catch(() => {
message.error("获取点赞记录失败,请稍后重试");
})
.finally(() => setRecordsLoading(false));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);
const handleSearch = () => {
setCurrentPage(1);
fetchLikeRecords(id!, 1, pageSize, searchTerm)
.then((response: any) => {
setRecords(response.list || []);
setTotal(response.total || 0);
setCurrentPage(1);
})
.catch(() => {
message.error("获取点赞记录失败,请稍后重试");
});
};
const handleRefresh = () => {
fetchLikeRecords(id!, currentPage, pageSize, searchTerm)
.then((response: any) => {
setRecords(response.list || []);
setTotal(response.total || 0);
})
.catch(() => {
message.error("获取点赞记录失败,请稍后重试");
});
};
const handlePageChange = (newPage: number) => {
fetchLikeRecords(id!, newPage, pageSize, searchTerm)
.then((response: any) => {
setRecords(response.list || []);
setTotal(response.total || 0);
setCurrentPage(newPage);
})
.catch(() => {
message.error("获取点赞记录失败,请稍后重试");
});
};
return (
<Layout
header={
<>
<NavCommon title="点赞记录" />
<div className={styles.headerSearchBar}>
<div className={styles.headerSearchInputWrap}>
<Input
prefix={<SearchOutlined className={styles.headerSearchIcon} />}
placeholder="搜索好友昵称或内容"
className={styles.headerSearchInput}
value={searchTerm}
onChange={e => setSearchTerm(e.target.value)}
onPressEnter={handleSearch}
allowClear
/>
</div>
<Button
icon={<ReloadOutlined spin={recordsLoading} />}
onClick={handleRefresh}
loading={recordsLoading}
type="default"
shape="circle"
/>
</div>
</>
}
footer={
<>
<div className={styles.footerPagination}>
<Pagination
current={currentPage}
total={total}
pageSize={pageSize}
onChange={handlePageChange}
showSizeChanger={false}
showQuickJumper
size="default"
className={styles.pagination}
/>
</div>
</>
}
>
<div className={styles.bgWrap}>
<div className={styles.contentWrap}>
{recordsLoading ? (
<div className={styles.skeletonWrap}>
{Array.from({ length: 3 }).map((_, index) => (
<div key={index} className={styles.skeletonCard}>
<div className={styles.skeletonCardHeader}>
<Skeleton.Avatar
active
size={40}
className={styles.skeletonAvatar}
/>
<div className={styles.skeletonNameWrap}>
<Skeleton.Input
active
size="small"
className={styles.skeletonName}
style={{ width: 96 }}
/>
<Skeleton.Input
active
size="small"
className={styles.skeletonSub}
style={{ width: 64 }}
/>
</div>
</div>
<Divider className={styles.skeletonSep} />
<div className={styles.skeletonContentWrap}>
<Skeleton.Input
active
size="small"
className={styles.skeletonContent1}
style={{ width: "100%" }}
/>
<Skeleton.Input
active
size="small"
className={styles.skeletonContent2}
style={{ width: "75%" }}
/>
<div className={styles.skeletonImgWrap}>
<Skeleton.Image
active
className={styles.skeletonImg}
style={{ width: 80, height: 80 }}
/>
<Skeleton.Image
active
className={styles.skeletonImg}
style={{ width: 80, height: 80 }}
/>
</div>
</div>
</div>
))}
</div>
) : records.length === 0 ? (
<div className={styles.emptyWrap}>
<LikeOutlined className={styles.emptyIcon} />
<p className={styles.emptyText}></p>
</div>
) : (
<>
{records.map(record => (
<div key={record.id} className={styles.recordCard}>
<div className={styles.recordCardHeader}>
<div className={styles.recordCardHeaderLeft}>
<Avatar
src={record.friendAvatar || undefined}
icon={<UserOutlined />}
size={40}
className={styles.avatarImg}
/>
<div className={styles.friendInfo}>
<div
className={styles.friendName}
title={record.friendName}
>
{record.friendName}
</div>
<div className={styles.friendSub}></div>
</div>
</div>
<Badge
className={styles.timeBadge}
count={formatDate(record.momentTime || record.likeTime)}
style={{
background: "#e8f0fe",
color: "#333",
fontWeight: 400,
}}
/>
</div>
<Divider className={styles.cardSep} />
<div className={styles.cardContent}>
{record.content && (
<p className={styles.contentText}>{record.content}</p>
)}
{Array.isArray(record.resUrls) &&
record.resUrls.length > 0 && (
<div
className={
`${styles.imgGrid} ` +
(record.resUrls.length === 1
? styles.grid1
: record.resUrls.length === 2
? styles.grid2
: record.resUrls.length <= 3
? styles.grid3
: record.resUrls.length <= 6
? styles.grid6
: styles.grid9)
}
>
{record.resUrls
.slice(0, 9)
.map((image: string, idx: number) => (
<div key={idx} className={styles.imgItem}>
<img
src={image}
alt={`内容图片 ${idx + 1}`}
className={styles.img}
/>
</div>
))}
</div>
)}
</div>
<div className={styles.operatorWrap}>
<Avatar
src={record.operatorAvatar || undefined}
icon={<UserOutlined />}
size={32}
className={styles.operatorAvatar}
/>
<div className={styles.operatorInfo}>
<span
className={styles.operatorName}
title={record.operatorName}
>
{record.operatorName}
</span>
<span className={styles.operatorAction}>
<LikeOutlined
style={{ color: "red", marginRight: 4 }}
/>
</span>
</div>
</div>
</div>
))}
</>
)}
</div>
</div>
</Layout>
);
}

View File

@@ -0,0 +1,268 @@
// 搜索栏
.headerSearchBar {
display: flex;
align-items: center;
gap: 8px;
padding: 16px;
}
.headerSearchInputWrap {
position: relative;
flex: 1;
}
.headerSearchIcon {
position: absolute;
left: 12px;
top: 10px;
width: 16px;
height: 16px;
color: #a3a3a3;
}
.headerSearchInput {
padding-left: 32px !important;
}
.spin {
animation: spin 1s linear infinite;
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
// 分页
.footerPagination {
display: flex;
justify-content: center;
align-items: center;
padding: 12px 0;
background: #fff;
}
.pagination {
:global(.ant-pagination-item) {
border-radius: 6px;
}
:global(.ant-pagination-item-active) {
background: #1890ff;
border-color: #1890ff;
}
:global(.ant-pagination-prev),
:global(.ant-pagination-next) {
border-radius: 6px;
}
:global(.ant-pagination-jump-prev),
:global(.ant-pagination-jump-next) {
border-radius: 6px;
}
}
// 背景和内容
.bgWrap {
background: #f7f7fa;
min-height: 100vh;
padding-bottom: 80px;
}
.contentWrap {
padding: 0 16px;
display: flex;
flex-direction: column;
gap: 16px;
}
// 骨架屏
.skeletonWrap {
display: flex;
flex-direction: column;
gap: 16px;
}
.skeletonCard {
padding: 0px;
}
.skeletonCardHeader {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
}
.skeletonAvatar {
width: 40px;
height: 40px;
border-radius: 50%;
}
.skeletonNameWrap {
display: flex;
flex-direction: column;
gap: 8px;
}
.skeletonName {
width: 96px;
height: 16px;
}
.skeletonSub {
width: 64px;
height: 12px;
}
.skeletonSep {
margin: 12px 0;
}
.skeletonContentWrap {
display: flex;
flex-direction: column;
gap: 8px;
}
.skeletonContent1 {
width: 100%;
height: 16px;
}
.skeletonContent2 {
width: 75%;
height: 16px;
}
.skeletonImgWrap {
display: flex;
gap: 8px;
margin-top: 12px;
}
.skeletonImg {
width: 80px;
height: 80px;
border-radius: 8px;
}
// 空状态
.emptyWrap {
text-align: center;
padding: 48px 0;
}
.emptyIcon {
width: 48px;
height: 48px;
color: #e5e7eb;
margin: 0 auto 12px auto;
}
.emptyText {
color: #888;
font-size: 16px;
}
// 记录卡片
.recordCard {
background: #fff;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
padding: 16px;
}
.recordCardHeader {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.recordCardHeaderLeft {
display: flex;
align-items: center;
gap: 12px;
max-width: 65%;
}
.avatarImg {
width: 40px;
height: 40px;
border-radius: 50%;
}
.friendInfo {
min-width: 0;
}
.friendName {
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.friendSub {
font-size: 13px;
color: #888;
}
.timeBadge {
background: #e8f0fe;
white-space: nowrap;
flex-shrink: 0;
}
.cardSep {
margin: 12px 0;
}
.cardContent {
margin-bottom: 12px;
}
.contentText {
color: #444;
margin-bottom: 12px;
white-space: pre-line;
}
.imgGrid {
display: grid;
gap: 8px;
}
.grid1 {
grid-template-columns: 1fr;
}
.grid2 {
grid-template-columns: 1fr 1fr;
}
.grid3 {
grid-template-columns: 1fr 1fr 1fr;
}
.grid6 {
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
}
.grid9 {
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
}
.imgItem {
position: relative;
aspect-ratio: 1/1;
border-radius: 8px;
overflow: hidden;
}
.img {
width: 100%;
height: 100%;
object-fit: cover;
}
// 操作人
.operatorWrap {
display: flex;
align-items: center;
margin-top: 16px;
padding: 8px;
background: #f3f4f6;
border-radius: 8px;
}
.operatorAvatar {
width: 32px !important;
height: 32px !important;
margin-right: 8px;
flex-shrink: 0;
}
.operatorInfo {
font-size: 14px;
position: relative;
flex: 1;
position: relative;
}
.operatorName {
font-weight: 500;
max-width: 100%;
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.operatorAction {
color: #888;
margin-left: 8px;
font-size: 12px;
position: absolute;
right: 0;
top: 2px;
}

View File

@@ -8,9 +8,10 @@ import AutoGroupForm from "@/pages/mobile/workspace/auto-group/form";
import GroupPush from "@/pages/mobile/workspace/group-push/list";
import FormGroupPush from "@/pages/mobile/workspace/group-push/form";
import DetailGroupPush from "@/pages/mobile/workspace/group-push/detail";
import MomentsSync from "@/pages/mobile/workspace/moments-sync/MomentsSync";
import MomentsSyncDetail from "@/pages/mobile/workspace/moments-sync/Detail";
import MomentsSync from "@/pages/mobile/workspace/moments-sync/list";
import NewMomentsSync from "@/pages/mobile/workspace/moments-sync/new/index";
import MomentsSyncDetail from "@/pages/mobile/workspace/moments-sync/Detail";
import MomentsSyncRecord from "@/pages/mobile/workspace/moments-sync/record";
import AIAssistant from "@/pages/mobile/workspace/ai-assistant/AIAssistant";
import TrafficDistribution from "@/pages/mobile/workspace/traffic-distribution/list/index";
import TrafficDistributionDetail from "@/pages/mobile/workspace/traffic-distribution/detail/index";
@@ -103,6 +104,11 @@ const workspaceRoutes = [
element: <MomentsSyncDetail />,
auth: true,
},
{
path: "/workspace/moments-sync/record/:id",
element: <MomentsSyncRecord />,
auth: true,
},
{
path: "/workspace/moments-sync/edit/:id",
element: <NewMomentsSync />,