diff --git a/src/pages/Op/index.jsx b/src/pages/Op/index.jsx
index 3cc2eb2..be50991 100644
--- a/src/pages/Op/index.jsx
+++ b/src/pages/Op/index.jsx
@@ -59,6 +59,7 @@ export default function Op() {
]),
getItem("动态管理", "postManagement", , [
getItem("发布与编辑", "createAndEditPost"),
+ getItem("置顶动态", "topPosts"),
]),
// getItem("用户管理", "userManagement", ),
// getItem("订单管理", "orderManagement", , [
diff --git a/src/pages/TopPosts/index.jsx b/src/pages/TopPosts/index.jsx
new file mode 100644
index 0000000..9eaf9c1
--- /dev/null
+++ b/src/pages/TopPosts/index.jsx
@@ -0,0 +1,234 @@
+import React, { useState, useEffect } from "react";
+import { Form, Input, Table, Image, Space, Button, Modal, message } from "antd";
+import baseRequest from "../../utils/baseRequest";
+import ImageUploader from "../../components/ImageUploader";
+import VideoUploader from "../../components/VideoUploader";
+
+const TopPostsContent = (props) => {
+ //表头
+ const columns = [
+ {
+ title: "动态信息",
+ dataIndex: "info",
+ key: "info",
+ render: (data) => (
+
+
+ 动态id:{data.id}
+
+
+ 点赞:{data.like}
+
+
+ 创建时间:{data.ct}
+
+
+ ),
+ },
+ {
+ title: "动态文案",
+ dataIndex: "content",
+ key: "content",
+ },
+ {
+ title: "媒体",
+ dataIndex: "media",
+ key: "media",
+ render: (data) => (
+
+ {data?.images?.map((item, index) => (
+
+ ))}
+ {data?.videos?.map((item, index) => (
+
+ ))}
+
+ ),
+ },
+ ];
+
+ //展示的数据
+ const [showData, setShowData] = useState([]);
+
+ //获取数据
+ const getData = async () => {
+ try {
+ const base = baseRequest();
+ //获取现有id
+ const response = await fetch("/op/app_config/list_by_key", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ config_key: "free_moment_ids",
+ ...base,
+ }),
+ });
+ const temData = await response.json();
+ console.log(temData);
+ if (temData.ret === -1) {
+ alert(temData.msg);
+ return;
+ }
+ //用id查动态
+ if (!temData.data.app_config.config_value) return;
+ const intIds = temData.data.app_config.config_value?.map((item) =>
+ parseInt(item, 10)
+ );
+ const response2 = await fetch("/op/moment/list_by_ids", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ ids: intIds,
+ ...base,
+ }),
+ });
+ const temData2 = await response2.json();
+ console.log(temData2);
+ if (temData2.ret === -1) {
+ alert(temData2.msg);
+ return;
+ }
+ //匹配表格格式
+ const structedData = temData2.data.list.map((item, index) => {
+ return {
+ key: index,
+ info: {
+ id: item.id,
+ like: item.thumbs_up_num,
+ ct: new Date(item.ct * 1000).toLocaleString(),
+ },
+ content: item.text,
+ media: item.media_component,
+ };
+ });
+ setShowData(structedData);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+ useEffect(() => {
+ getData();
+ }, []);
+
+ //控制modal是否出现
+ const [isModalOpen, setIsModalOpen] = useState(false);
+
+ //提交创建动态
+ const [form] = Form.useForm();
+ const handleSubmit = async (value) => {
+ try {
+ const base = baseRequest();
+ //获取现有id
+ const response = await fetch("/op/app_config/update", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ config_key: "free_moment_ids",
+ config_value: [value.post_id_1, value.post_id_2, value.post_id_3],
+ ...base,
+ }),
+ });
+ const temData = await response.json();
+ if (temData.ret === -1) {
+ alert(temData.msg);
+ return;
+ }
+ form.resetFields();
+ setIsModalOpen(false);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ //关闭弹窗
+ const handleCancelModal = () => {
+ form.resetFields();
+ setIsModalOpen(false);
+ };
+
+ return (
+
+ );
+};
+
+export default function TopPosts() {
+ return ;
+}
diff --git a/src/routes/index.js b/src/routes/index.js
index a4cd4af..8a3b93a 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -16,6 +16,7 @@ import ImageMachineReview from "../pages/ImageMachineReview";
import TextMachineReview from "../pages/TextMachineReview";
import ManualRechargeAndWithdrawal from "../pages/ManualRechargeAndWithdrawal";
import CreateAndEditPost from "../pages/CreateAndEditPost";
+import TopPosts from "../pages/TopPosts";
const routes = [
{
@@ -90,6 +91,10 @@ const routes = [
path: "createAndEditPost/*",
element: ,
},
+ {
+ path: "topPosts/*",
+ element: ,
+ },
],
},
];