12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { savePosts, getPostsDetail, updatePosts } from "@/services/posts";
  2. import { getStoreList } from "@/services/stock";
  3. import {
  4. PageContainer,
  5. ProForm,
  6. ProFormSelect,
  7. ProFormText,
  8. } from "@ant-design/pro-components";
  9. import { useNavigate, useSearchParams } from "react-router-dom";
  10. import { Card, Typography, message, Row, Button, Space } from "antd";
  11. import { useEffect, useRef, useState } from "react";
  12. import Wangeditor from "@/components/Wangeditor";
  13. const { Title } = Typography;
  14. export default (props) => {
  15. const [searchParams] = useSearchParams();
  16. const id = searchParams.get("id");
  17. const [data, setData] = useState({});
  18. const [url, setUrl] = useState("");
  19. const navigate = useNavigate();
  20. const formRef = useRef();
  21. useEffect(() => {
  22. if (id) {
  23. getPostsDetail(id).then((res) => {
  24. setData(res);
  25. setUrl(res.filesList[0]?.fileAddr);
  26. });
  27. }
  28. }, [id]);
  29. return (
  30. <Card extra={<Button onClick={() => navigate(-1)}> 返回</Button>}>
  31. <Title level={2} style={{ marginBottom: "2em" }}>
  32. {data.title}
  33. </Title>
  34. <div dangerouslySetInnerHTML={{ __html: data?.detail }}></div>
  35. {url && (
  36. <div style={{marginTop:"2em"}}>
  37. <a
  38. href={`${url}`}
  39. download
  40. // rel="noopener noreferrer"
  41. // key="link"
  42. >
  43. {url?.substring(url?.lastIndexOf("/") + 1)}
  44. </a>
  45. </div>
  46. )}
  47. </Card>
  48. );
  49. };