shaogen1995 2 年之前
父節點
當前提交
2d2ea03e44

+ 92 - 0
后台/src/components/Z_upFileMore/index.module.scss

@@ -0,0 +1,92 @@
+.Z_upFileMore {
+  position: relative;
+  width: 100%;
+  height: 100%;
+
+  :global {
+    .fileBoxRow_up {
+      color: #a6a6a6;
+      border-radius: 3px;
+      cursor: pointer;
+      font-size: 30px;
+      width: 100px;
+      height: 100px;
+      border: 1px dashed #797979;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+    }
+
+    .fileImgListBox {
+      display: flex;
+      flex-wrap: wrap;
+      margin-bottom: 10px;
+
+      &>div {
+        cursor: move;
+        margin: 15px 20px 0px 0;
+      }
+    }
+
+    .fileImgListBoxNo {
+      &>div {
+        cursor: default;
+      }
+    }
+
+    .fileBoxRow_r_img {
+      position: relative;
+
+      .fileImgListLDBox {
+        height: 26px;
+        background-color: rgba(0, 0, 0, .6);
+        color: #fff;
+        display: flex;
+        justify-content: space-around;
+        font-size: 16px;
+
+        &>a {
+          color: #fff;
+        }
+      }
+
+      .clearCover {
+        cursor: pointer;
+        position: absolute;
+        z-index: 99;
+        right: -10px;
+        top: -10px;
+        background-color: rgba(0, 0, 0, .8);
+        width: 20px;
+        height: 20px;
+        border-radius: 50%;
+        font-size: 16px;
+        color: #fff;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+      }
+    }
+
+    .fileTit {
+      font-size: 14px;
+      color: rgb(126, 124, 124);
+
+      .noUpThumb {
+        position: relative;
+        overflow: hidden;
+        opacity: 0;
+        transition: top .2s;
+        color: #ff4d4f;
+        top: -10px;
+      }
+
+
+
+      .noUpThumbAc {
+        top: 0;
+        opacity: 1;
+      }
+    }
+  }
+}

+ 192 - 0
后台/src/components/Z_upFileMore/index.tsx

@@ -0,0 +1,192 @@
+import React, { useCallback, useRef } from "react";
+import styles from "./index.module.scss";
+import {
+  PlusOutlined,
+  EyeOutlined,
+  CloseOutlined,
+  DownloadOutlined,
+} from "@ant-design/icons";
+import { ReactSortable } from "react-sortablejs";
+import ImageLazy from "@/components/ImageLazy";
+
+import { FileImgListType } from "@/types";
+import { Popconfirm } from "antd";
+import store from "@/store";
+import { baseURL } from "@/utils/http";
+import { MessageFu } from "@/utils/message";
+import { A1_APIupFile } from "@/store/action/A1Plate";
+import { fileDomInitialFu } from "@/utils/domShow";
+import classNames from "classnames";
+
+type Props = {
+  max: number; //最多传多少张图片
+  fileList: FileImgListType[]; //图片数组
+  setFileList: (data: FileImgListType[]) => void; //设置图片数组
+  isLook: boolean; //是否是查看
+  fileCheck: boolean;
+  size: number; //上传图片大小(M)
+  dirCode: string; //文件的code码
+  format?: string[]; //上传图片格式
+  formatTxt?: string; //上传图片提示
+  sizeTxt?: string; //后面的建议尺寸信息
+};
+
+function Z_upFileMore({
+  max,
+  fileList,
+  setFileList,
+  isLook,
+  fileCheck,
+  size,
+  dirCode,
+  format = ["image/jpeg", "image/png"],
+  formatTxt = "png、jpg和jpeg",
+  sizeTxt,
+}: Props) {
+  const myInput = useRef<HTMLInputElement>(null);
+
+  // 上传图片
+  const handeUpPhoto = useCallback(
+    async (e: React.ChangeEvent<HTMLInputElement>) => {
+      if (e.target.files) {
+        // 拿到files信息
+        const filesInfo = e.target.files[0];
+        // 校验格式
+        const type = format;
+        if (!type.includes(filesInfo.type)) {
+          e.target.value = "";
+          return MessageFu.warning(`只支持${formatTxt}格式!`);
+        }
+        // 校验大小
+        if (filesInfo.size > size * 1024 * 1024) {
+          e.target.value = "";
+          return MessageFu.warning(`最大支持${size}M!`);
+        }
+        // 创建FormData对象
+        const fd = new FormData();
+        // 把files添加进FormData对象(‘photo’为后端需要的字段)
+        fd.append("type", "img");
+        fd.append("dirCode", dirCode);
+        fd.append("typePath", "1");
+        fd.append("file", filesInfo);
+
+        e.target.value = "";
+
+        try {
+          const res = await A1_APIupFile(fd);
+          if (res.code === 0) {
+            MessageFu.success("上传成功!");
+            setFileList([...fileList, res.data]);
+          }
+          fileDomInitialFu();
+        } catch (error) {
+          fileDomInitialFu();
+        }
+      }
+    },
+    [dirCode, fileList, format, formatTxt, setFileList, size]
+  );
+
+  // 列表删除某一张图片
+  const delImgListFu = useCallback(
+    (id: number) => {
+      const newItems = fileList.filter((v) => v.id !== id);
+      setFileList(newItems);
+    },
+    [fileList, setFileList]
+  );
+
+  return (
+    <div className={styles.Z_upFileMore}>
+      <input
+        id="upInput"
+        type="file"
+        accept=".png,.jpg,.jpeg"
+        ref={myInput}
+        onChange={(e) => handeUpPhoto(e)}
+      />
+
+      <div
+        hidden={(fileList.length && fileList.length >= max) || isLook}
+        className="fileBoxRow_up"
+        onClick={() => myInput.current?.click()}
+      >
+        <PlusOutlined />
+      </div>
+
+      <ReactSortable
+        disabled={isLook}
+        className={classNames(
+          "fileImgListBox",
+          isLook ? "fileImgListBoxNo" : ""
+        )}
+        list={fileList}
+        setList={setFileList}
+      >
+        {fileList.map((v, i) => (
+          <div className="fileBoxRow_r_img" key={v.id}>
+            {v.filePath ? (
+              <ImageLazy noLook width={100} height={100} src={v.filePath} />
+            ) : null}
+
+            <Popconfirm
+              title="删除后无法恢复,是否删除?"
+              okText="删除"
+              cancelText="取消"
+              onConfirm={() => delImgListFu(v.id!)}
+            >
+              <div className="clearCover" hidden={isLook}>
+                <CloseOutlined />
+              </div>
+            </Popconfirm>
+            {/* 下面的预览和下载 */}
+            <div className="fileImgListLDBox">
+              <EyeOutlined
+                onClick={() =>
+                  store.dispatch({
+                    type: "layout/lookBigImg",
+                    payload: {
+                      url: baseURL + v.filePath,
+                      show: true,
+                    },
+                  })
+                }
+              />
+              <a
+                href={baseURL + v.filePath}
+                download
+                target="_blank"
+                rel="noreferrer"
+              >
+                <DownloadOutlined />
+              </a>
+            </div>
+          </div>
+        ))}
+      </ReactSortable>
+      <div className="fileTit" hidden={isLook}>
+        {fileList.length && fileList.length >= 2 ? (
+          <>
+            按住鼠标可拖动图片调整顺序。
+            <br />
+          </>
+        ) : null}
+        支持{formatTxt}的图片格式;最大支持{size}M;最多支持{max}张。
+        {sizeTxt ? `建议尺寸${sizeTxt}` : null}
+        <br />
+        <div
+          className={classNames(
+            "noUpThumb",
+            fileList.length <= 0 && fileCheck ? "noUpThumbAc" : ""
+          )}
+        >
+          请上传图片!
+        </div>
+      </div>
+    </div>
+  );
+}
+
+const MemoZ_upFileMore = React.memo(Z_upFileMore);
+
+export default MemoZ_upFileMore;

+ 84 - 0
后台/src/components/Z_upFileOne/index.module.scss

@@ -0,0 +1,84 @@
+.Z_upFileOne {
+  width: 100%;
+  height: 100%;
+  position: relative;
+
+  :global {
+
+    .file_upIcon {
+      color: #a6a6a6;
+      border-radius: 3px;
+      cursor: pointer;
+      font-size: 30px;
+      width: 100px;
+      height: 100px;
+      border: 1px dashed #797979;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+
+
+    }
+
+    .file_img {
+      width: 100px;
+      height: 126px;
+      position: relative;
+
+      .file_closeBox {
+        position: absolute;
+        right: -10px;
+        top: -10px;
+        z-index: 99;
+        background-color: rgba(0, 0, 0, 0.8);
+        width: 20px;
+        height: 20px;
+        border-radius: 50%;
+        font-size: 16px;
+        color: #fff;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+      }
+
+
+
+      .file_lookBox {
+        width: 100%;
+        background-color: rgba(0, 0, 0, .6);
+        color: #fff;
+        display: flex;
+        justify-content: space-around;
+
+        &>a {
+          color: #fff;
+        }
+
+        font-size: 16px;
+      }
+    }
+
+    .fileBoxRow_r_tit {
+      height: 46px;
+      margin-top: 5px;
+      font-size: 14px;
+      color: rgb(126, 124, 124);
+
+
+    }
+
+    .noUpThumb {
+      position: relative;
+      overflow: hidden;
+      opacity: 0;
+      transition: top .2s;
+      color: #ff4d4f;
+      top: -10px;
+    }
+
+    .noUpThumbAc {
+      top: 0;
+      opacity: 1;
+    }
+  }
+}

+ 152 - 0
后台/src/components/Z_upFileOne/index.tsx

@@ -0,0 +1,152 @@
+import React, { useCallback, useRef } from "react";
+import styles from "./index.module.scss";
+import ImageLazy from "@/components/ImageLazy";
+import {
+  PlusOutlined,
+  EyeOutlined,
+  CloseOutlined,
+  DownloadOutlined,
+} from "@ant-design/icons";
+import store from "@/store";
+import { baseURL } from "@/utils/http";
+import classNames from "classnames";
+import { Popconfirm } from "antd";
+import { MessageFu } from "@/utils/message";
+import { A1_APIupFile } from "@/store/action/A1Plate";
+import { fileDomInitialFu } from "@/utils/domShow";
+
+type Props = {
+  cover: string; //封面图
+  setCover: (val: string) => void; //设置封面图
+  isLook: boolean; //是不是查看
+  coverCheck: boolean; //有没有点击过确定
+  size: number; //上传图片大小(M)
+  dirCode: string; //文件的code码
+  format?: string[]; //上传图片格式
+  formatTxt?: string; //上传图片提示
+  sizeTxt?:string //后面的建议尺寸信息
+};
+
+function Z_upFileOne({
+  cover,
+  setCover,
+  isLook,
+  coverCheck,
+  size,
+  dirCode,
+  format = ["image/jpeg", "image/png"],
+  formatTxt = "png、jpg和jpeg",
+  sizeTxt
+}: Props) {
+  const myInput = useRef<HTMLInputElement>(null);
+
+  // 上传封面图
+  const handeUpPhoto = useCallback(
+    async (e: React.ChangeEvent<HTMLInputElement>) => {
+      if (e.target.files) {
+        // 拿到files信息
+        const filesInfo = e.target.files[0];
+        // 校验格式
+        const type = format;
+        if (!type.includes(filesInfo.type)) {
+          e.target.value = "";
+          return MessageFu.warning(`只支持${formatTxt}格式!`);
+        }
+        // 校验大小
+        if (filesInfo.size > size * 1024 * 1024) {
+          e.target.value = "";
+          return MessageFu.warning(`最大支持${size}M!`);
+        }
+        // 创建FormData对象
+        const fd = new FormData();
+        // 把files添加进FormData对象(‘photo’为后端需要的字段)
+        fd.append("type", "thumb");
+        fd.append("dirCode", dirCode);
+        fd.append("file", filesInfo);
+
+        e.target.value = "";
+
+        try {
+          const res = await A1_APIupFile(fd);
+          if (res.code === 0) {
+            MessageFu.success("上传成功!");
+            setCover(res.data.filePath);
+          }
+          fileDomInitialFu();
+        } catch (error) {
+          fileDomInitialFu();
+        }
+      }
+    },
+    [dirCode, format, formatTxt, setCover, size]
+  );
+
+  return (
+    <div className={styles.Z_upFileOne}>
+      <input
+        id="upInput"
+        type="file"
+        accept=".png,.jpg,.jpeg"
+        ref={myInput}
+        onChange={(e) => handeUpPhoto(e)}
+      />
+
+      <div
+        hidden={cover !== ""}
+        className="file_upIcon"
+        onClick={() => myInput.current?.click()}
+      >
+        <PlusOutlined />
+      </div>
+
+      <div className="file_img" hidden={cover === ""}>
+        {cover ? (
+          <ImageLazy width={100} height={100} src={cover} noLook />
+        ) : null}
+
+        {/* 删除 */}
+        <div className="file_closeBox" hidden={isLook}>
+          <Popconfirm
+            title="删除后无法恢复,是否删除?"
+            okText="删除"
+            cancelText="取消"
+            onConfirm={() => setCover("")}
+          >
+            <CloseOutlined />
+          </Popconfirm>
+        </div>
+
+        {/* 预览 下载 */}
+        <div className="file_lookBox">
+          <EyeOutlined
+            onClick={() =>
+              store.dispatch({
+                type: "layout/lookBigImg",
+                payload: { url: baseURL + cover, show: true },
+              })
+            }
+          />
+          <a href={baseURL + cover} download target="_blank" rel="noreferrer">
+            <DownloadOutlined />
+          </a>
+        </div>
+      </div>
+      <div className="fileBoxRow_r_tit" hidden={isLook}>
+        支持{formatTxt}的图片格式;最大支持{size}M。{sizeTxt?`建议尺寸${sizeTxt}`:null}
+        <br />
+        <div
+          className={classNames(
+            "noUpThumb",
+            !cover && coverCheck ? "noUpThumbAc" : ""
+          )}
+        >
+          请上传封面图!
+        </div>
+      </div>
+    </div>
+  );
+}
+
+const MemoZ_upFileOne = React.memo(Z_upFileOne);
+
+export default MemoZ_upFileOne;

+ 46 - 0
后台/src/pages/A1Plate/PlateEdit/index.module.scss

@@ -0,0 +1,46 @@
+.PlateEdit {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  z-index: 9;
+  background-color: #fff;
+  border-radius: 10px;
+  padding: 30px 20px;
+
+  :global {
+    .e_main {
+      height: 100%;
+      overflow-y: auto;
+
+      .e_row {
+        padding-right: 50px;
+        display: flex;
+        font-size: 16px;
+        margin-bottom: 30px;
+
+        .e_rowL {
+          width: 100px;
+          text-align: right;
+
+          &>span {
+            color: #ff4d4f;
+            position: relative;
+            top: 3px;
+          }
+        }
+
+        .e_rowR {
+          margin-left: 20px;
+          width: calc(100% - 140px);
+        }
+
+      }
+
+      .e_rowBtn {
+        padding-left: 120px;
+      }
+    }
+  }
+}

+ 159 - 0
后台/src/pages/A1Plate/PlateEdit/index.tsx

@@ -0,0 +1,159 @@
+import React, { useCallback, useEffect, useState } from "react";
+import styles from "./index.module.scss";
+import { A1_APIgetInfo, A1_APIsave } from "@/store/action/A1Plate";
+import { A1ListType, FileImgListType } from "@/types";
+
+import { Button, Popconfirm } from "antd";
+import UpFileOne from "@/components/Z_upFileOne";
+import UpFileMore from "@/components/Z_upFileMore";
+import { MessageFu } from "@/utils/message";
+
+type Props = {
+  editId: number;
+  isLook: boolean;
+  closeFu: () => void;
+  editFu: () => void;
+};
+
+function PlateEdit({ editId, isLook, closeFu, editFu }: Props) {
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await A1_APIgetInfo(id);
+    if (res.code === 0) {
+      const info = res.data.entity;
+      setInfo(info);
+
+      if (res.data.file) setFileList(res.data.file);
+
+      setCover(info.thumb);
+
+      if (info.dirCode) setDirCode(info.dirCode);
+      else setDirCode(Date.now() + "");
+    }
+  }, []);
+
+  useEffect(() => {
+    getInfoFu(editId);
+  }, [editId, getInfoFu]);
+
+  const [info, setInfo] = useState({} as A1ListType);
+
+  // 封面图
+  const [cover, setCover] = useState("");
+
+  // 校验
+  const [fromCheck, setFromCheck] = useState(false);
+
+  // code码
+  const [dirCode, setDirCode] = useState("");
+
+  // 多张  BANNER 图
+  const [fileList, setFileList] = useState([] as FileImgListType[]);
+
+  // 点击提交
+  const onFinish = useCallback(async () => {
+    setFromCheck(true);
+    if (!cover) return;
+    if (editId !== 1 && fileList.length <= 0) return;
+
+    const obj = {
+      id: editId,
+      img: fileList.map((v) => v.id).join(","),
+      thumb: cover,
+      type: "explore",
+      dirCode,
+    };
+
+    const res = await A1_APIsave(obj);
+
+    if (res.code === 0) {
+      MessageFu.success(editId ? "编辑成功!" : "新增成功!");
+      editFu();
+      closeFu();
+    }
+  }, [closeFu, cover, dirCode, editFu, editId, fileList]);
+
+  return (
+    <div className={styles.PlateEdit}>
+      <div className="e_main mySorrl">
+        {/* 标题 */}
+        <div className="e_row">
+          <div className="e_rowL">
+            <span>* </span>标题:
+          </div>
+          <div className="e_rowR">{info.name}</div>
+        </div>
+
+        {/* 封面图 */}
+        <div className="e_row">
+          <div className="e_rowL">
+            <span>* </span>封面:
+          </div>
+          <div className="e_rowR">
+            <UpFileOne
+              cover={cover}
+              setCover={(val) => setCover(val)}
+              isLook={isLook}
+              coverCheck={fromCheck}
+              size={5}
+              dirCode={dirCode}
+              sizeTxt={
+                editId === 1
+                  ? "350 x 670"
+                  : editId === 2 || editId === 7
+                  ? "780 x 376"
+                  : "335 x 350"
+              }
+            />
+          </div>
+        </div>
+
+        {/* BANNER图 */}
+        {editId !== 1 ? (
+          <div className="e_row">
+            <div className="e_rowL">
+              <span>* </span>BANNER:
+            </div>
+            <div className="e_rowR">
+              <UpFileMore
+                max={15}
+                fileList={fileList}
+                setFileList={(data) => setFileList(data)}
+                isLook={isLook}
+                fileCheck={fromCheck}
+                size={5}
+                dirCode={dirCode}
+                sizeTxt="430 x 280"
+              />
+            </div>
+          </div>
+        ) : null}
+
+        {/* 底部按钮 */}
+        <div className="e_row e_rowBtn">
+          {isLook ? (
+            <Button onClick={closeFu}>关 闭</Button>
+          ) : (
+            <>
+              <Button type="primary" onClick={onFinish}>
+                提交
+              </Button>
+              &emsp;
+              <Popconfirm
+                title="放弃编辑后,信息将不会保存!"
+                okText="放弃"
+                cancelText="取消"
+                onConfirm={closeFu}
+              >
+                <Button>取消</Button>
+              </Popconfirm>
+            </>
+          )}
+        </div>
+      </div>
+    </div>
+  );
+}
+
+const MemoPlateEdit = React.memo(PlateEdit);
+
+export default MemoPlateEdit;

+ 29 - 3
后台/src/pages/A1Plate/index.module.scss

@@ -1,5 +1,31 @@
-.A1Plate{
-  :global{
-    
+.A1Plate {
+  position: relative;
+  :global {
+    .top {
+      display: flex;
+      align-items: center;
+      background-color: #fff;
+      border-radius: 10px;
+      padding: 20px 15px;
+    }
+
+    .tableBox {
+      border-radius: 10px;
+      overflow: hidden;
+      margin-top: 15px;
+      height: calc(100% - 80px);
+      background-color: #fff;
+
+      .ant-table-body {
+        height: 617px;
+        overflow-y: auto !important;
+
+        .ant-table-row {
+          .ant-table-cell {
+            padding: 10px;
+          }
+        }
+      }
+    }
   }
 }

+ 133 - 5
后台/src/pages/A1Plate/index.tsx

@@ -1,12 +1,140 @@
-import React from "react";
+import React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+} from "react";
 import styles from "./index.module.scss";
- function A1Plate() {
-  
+import { useDispatch, useSelector } from "react-redux";
+import { A1_APIgetList } from "@/store/action/A1Plate";
+import { Button, Input, Table } from "antd";
+import { RootState } from "@/store";
+import { A1ListType } from "@/types";
+import ImageLazy from "@/components/ImageLazy";
+import PlateEdit from "./PlateEdit";
+function A1Plate() {
+  const dispatch = useDispatch();
+
+  const [name, setName] = useState("");
+  const [inputKey, setInputKey] = useState(1);
+
+  useEffect(() => {
+    dispatch(A1_APIgetList(name));
+  }, [dispatch, name]);
+
+  // 标题的输入
+  const nameTime = useRef(-1);
+  const nameChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
+    clearTimeout(nameTime.current);
+    nameTime.current = window.setTimeout(() => {
+      setName(e.target.value);
+    }, 500);
+  }, []);
+
+  // 点击重置
+  const resetSelectFu = useCallback(() => {
+    setInputKey(Date.now());
+    setName("");
+  }, []);
+
+  // 从仓库获取表格数据
+  const { list } = useSelector((state: RootState) => state.A1Plate);
+
+  // 点击编辑
+  const openPageFu = useCallback((id: number, flag: boolean) => {
+    setIsLook(flag);
+    setEditId(id);
+  }, []);
+
+  const columns = useMemo(() => {
+    return [
+      {
+        title: "标题",
+        dataIndex: "name",
+      },
+      {
+        title: "封面图",
+        render: (item: A1ListType) => (
+          <div className="tableImgAuto">
+            <ImageLazy width={60} height={60} src={item.thumb} />
+          </div>
+        ),
+      },
+
+      {
+        title: "BANNER图",
+        render: (item: A1ListType) =>
+          item.img ? item.img.split(",").length : "/",
+      },
+
+      {
+        title: "操作",
+        render: (item: A1ListType) => (
+          <>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => openPageFu(item.id, true)}
+            >
+              查看
+            </Button>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => openPageFu(item.id, false)}
+            >
+              编辑
+            </Button>
+          </>
+        ),
+      },
+    ];
+  }, [openPageFu]);
+
+  // 编辑/查看 页面的打开和关闭
+  const [editId, setEditId] = useState(0);
+  const [isLook, setIsLook] = useState(false);
+
   return (
     <div className={styles.A1Plate}>
-      <div className="pageTitle">板块</div>
+      <div className="pageTitle">
+        {editId ? (isLook ? "查看" : "编辑") : "板块"}
+      </div>
+      {/* 顶部搜索 */}
+      <div className="top">
+        <span>用户昵称:</span>
+        <Input
+          key={inputKey}
+          maxLength={50}
+          style={{ width: 300 }}
+          placeholder="请输入关键字"
+          allowClear
+          onChange={(e) => nameChange(e)}
+        />
+        &emsp;&emsp;
+        <Button onClick={resetSelectFu}>重置</Button>
+      </div>
+      {/* 表格主体 */}
+      <div className="tableBox">
+        <Table
+          scroll={{ y: 617 }}
+          dataSource={list}
+          columns={columns}
+          rowKey="id"
+          pagination={false}
+        />
+      </div>
+      {editId ? (
+        <PlateEdit
+          editId={editId}
+          isLook={isLook}
+          closeFu={() => setEditId(0)}
+          editFu={() => dispatch(A1_APIgetList(name))}
+        />
+      ) : null}
     </div>
-  )
+  );
 }
 
 const MemoA1Plate = React.memo(A1Plate);

+ 0 - 1
后台/src/pages/Layout/index.tsx

@@ -127,7 +127,6 @@ function Layout() {
             path: "/log",
             Com: React.lazy(() => import("../D2Log")),
           },
-
         ],
       });
     }

+ 56 - 0
后台/src/store/action/A1Plate.ts

@@ -0,0 +1,56 @@
+import http from "@/utils/http";
+import store, { AppDispatch } from "..";
+import { domShowFu, progressDomFu } from "@/utils/domShow";
+import axios from "axios";
+/**
+ * 获取探索-板块列表
+ */
+export const A1_APIgetList = (searchKey: string) => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post("cms/config/getList", {
+      searchKey,
+      type: "explore",
+    });
+    if (res.code === 0) {
+      dispatch({ type: "A1Plate/getList", payload: res.data });
+    }
+  };
+};
+
+/**
+ * 获取探索-板块-详情
+ */
+export const A1_APIgetInfo = (id: number) => {
+  return http.get(`cms/config/detail/${id}`);
+};
+
+const CancelToken = axios.CancelToken;
+/**
+ * 上传封面图和附件
+ */
+export const A1_APIupFile = (data: any) => {
+  domShowFu("#UpAsyncLoding", true);
+
+  return http.post("cms/config/upload", data, {
+    timeout: 0,
+    // 显示进度条
+    onUploadProgress: (e: any) => {
+      const complete = (e.loaded / e.total) * 100 || 0;
+      progressDomFu(complete + "%");
+    },
+    // 取消上传
+    cancelToken: new CancelToken(function executor(c) {
+      store.dispatch({
+        type: "layout/closeUpFile",
+        payload: { fu: c, state: true },
+      });
+    }),
+  });
+};
+
+/**
+ * 获取探索-板块-新增、修改
+ */
+export const A1_APIsave = (data: any) => {
+  return http.post("cms/config/save", data);
+};

+ 25 - 0
后台/src/store/reducer/A1Plate.ts

@@ -0,0 +1,25 @@
+import { A1ListType } from "@/types";
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  list: [] as A1ListType[],
+};
+
+// 定义 action 类型
+type Props = {
+  type: "A1Plate/getList";
+  payload: A1ListType[];
+};
+
+// 频道 reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case "A1Plate/getList":
+      return { ...state, list: action.payload };
+
+    default:
+      return state;
+  }
+}

+ 3 - 1
后台/src/store/reducer/index.ts

@@ -3,14 +3,16 @@ import { combineReducers } from "redux";
 
 // 导入 登录 模块的 reducer
 import A0Layout from "./layout";
+import A1Plate from "./A1Plate";
 import D1User from "./D1User";
 import D2Log from "./D2Log";
 
 // 合并 reducer
 const rootReducer = combineReducers({
   A0Layout,
+  A1Plate,
   D1User,
-  D2Log
+  D2Log,
 });
 
 // 默认导出

+ 17 - 0
后台/src/types/api/A1Plate.d.ts

@@ -0,0 +1,17 @@
+export type A1ListType = {
+  content: string;
+  createTime: string;
+  creatorName: string;
+  id: number;
+  img: string;
+  name: string;
+  thumb: string;
+  type: string;
+  updateTime: string;
+};
+
+export type FileImgListType = {
+  id: number;
+  fileName: string;
+  filePath: string;
+};

+ 1 - 0
后台/src/types/index.d.ts

@@ -1,3 +1,4 @@
 export * from './api/layot'
+export * from './api/A1Plate'
 export * from './api/D1User'
 export * from './api/D2Log'

+ 6 - 6
后台/src/utils/http.ts

@@ -7,10 +7,10 @@ import { domShowFu } from "./domShow";
 // 请求基地址
 export const baseURL =
   // 线下的图片地址需要加上/api/
-  // process.env.NODE_ENV === "development"
-  //   ? "http://192.168.20.55:8044/api/"
-  //   : "";
-  process.env.NODE_ENV === "development" ? "https://ytxbwg.4dage.com" : "";
+  process.env.NODE_ENV === "development"
+    ? "http://192.168.20.55:8050/api/"
+    : "";
+// process.env.NODE_ENV === "development" ? "https://ytxbwg.4dage.com" : "";
 
 // 处理  类型“AxiosResponse<any, any>”上不存在属性“code”
 declare module "axios" {
@@ -23,10 +23,10 @@ declare module "axios" {
 // 创建 axios 实例
 const http = axios.create({
   // --------线下的地址不用加/api/
-  // baseURL: baseURL,
+  baseURL: baseURL,
 
   // --------打包或线上环境接口需要加上api/
-  baseURL: baseURL + "/api/",
+  // baseURL: baseURL + "/api/",
   timeout: 5000,
 });