shaogen1995 2 jaren geleden
bovenliggende
commit
d5ed203dc0

+ 11 - 6
houtai/src/pages/B2Goods/GoodsAdd/index.tsx

@@ -336,12 +336,17 @@ function GoodsAdd({ id, closeMoalFu, addListFu, editListFu }: Props) {
         return MessageFu.warning("有表单不符号规则!");
 
       const fileIds = [];
-      if (fileList.model.id) fileIds.push(fileList.model.id);
-      if (fileList.audio.id) fileIds.push(fileList.audio.id);
-      if (fileList.video.id) fileIds.push(fileList.video.id);
-      fileList.img.forEach((v) => {
-        if (v.id) fileIds.push(v.id);
-      });
+      if (fileList.model.id && typeCheck.includes("model"))
+        fileIds.push(fileList.model.id);
+      if (fileList.audio.id && typeCheck.includes("audio"))
+        fileIds.push(fileList.audio.id);
+      if (fileList.video.id && typeCheck.includes("video"))
+        fileIds.push(fileList.video.id);
+      if (typeCheck.includes("img")) {
+        fileList.img.forEach((v) => {
+          if (v.id) fileIds.push(v.id);
+        });
+      }
 
       const obj = {
         ...value,

+ 11 - 6
houtai/src/pages/B4Barrage/BarrageSet/index.tsx

@@ -6,11 +6,11 @@ import "./index.css";
 
 type Props = {
   closeMoalFu: () => void;
-  upBarrageFu:()=>void
+  upBarrageFu: () => void;
   barrageValue: boolean;
 };
 
-function BarrageSet({ closeMoalFu, barrageValue,upBarrageFu }: Props) {
+function BarrageSet({ closeMoalFu, barrageValue, upBarrageFu }: Props) {
   const [value, setValue] = useState(false);
 
   useEffect(() => {
@@ -20,14 +20,14 @@ function BarrageSet({ closeMoalFu, barrageValue,upBarrageFu }: Props) {
   const isEnabledClickFu = useCallback(
     async (val: boolean) => {
       const obj = {
-        content: JSON.stringify({ value:val }),
+        content: JSON.stringify({ value: val }),
       };
       const res = await barrageSetConfigAPI(obj);
 
       if (res.code === 0) {
         MessageFu.success("操作成功!");
-        setValue(val)
-        upBarrageFu()
+        setValue(val);
+        upBarrageFu();
       }
     },
     [upBarrageFu]
@@ -46,7 +46,12 @@ function BarrageSet({ closeMoalFu, barrageValue,upBarrageFu }: Props) {
       <div className="main">
         <div className="row">
           <div className="tit">开关:</div>
-          <Switch checked={value} onChange={(val) => isEnabledClickFu(val)} />
+          <Switch
+            checkedChildren="开启"
+            unCheckedChildren="关闭"
+            checked={value}
+            onChange={(val) => isEnabledClickFu(val)}
+          />
           <div className="txtTit">
             关闭后,将屏蔽场馆所有弹幕,并禁止发布弹幕留言
           </div>

+ 37 - 0
houtai/src/pages/B5Topic/TopicAdd/index.module.scss

@@ -0,0 +1,37 @@
+.TopicAdd {
+  width: 100%;
+  height: 100%;
+  overflow-y: auto;
+  overflow-y: overlay;
+  border-radius: 10px;
+  background-color: #fff;
+  padding: 20px 0;
+
+  :global {
+    .main {
+      position: relative;
+      width: 800px;
+      padding-left: 5px;
+
+      .addAnswer {
+        z-index: 10;
+        position: absolute;
+        right: 0;
+        top: 110px;
+      }
+      .btnXBox{
+        position: absolute;
+        z-index: 11;
+        top: 280px;
+        left: 810px;
+        .btnX{
+          cursor: pointer;
+          height: 32px;
+          font-size: 18px;
+          line-height: 32px;
+          margin-bottom: 24px;
+        }
+      }
+    }
+  }
+}

+ 323 - 0
houtai/src/pages/B5Topic/TopicAdd/index.tsx

@@ -0,0 +1,323 @@
+import {
+  getTopicDetailAPI,
+  topicGetBindingAPI,
+  topicGoodsSearchAPI,
+  topicSaveAPI,
+} from "@/store/action/B5Topic";
+import {
+  Button,
+  Form,
+  Input,
+  Popconfirm,
+  Radio,
+  Select,
+  SelectProps,
+} from "antd";
+import { CloseCircleOutlined } from "@ant-design/icons";
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import TextArea from "antd/es/input/TextArea";
+import styles from "./index.module.scss";
+import { TopicAddType } from "@/types";
+import { MessageFu } from "@/utils/message";
+import encodeStr from "@/utils/pass";
+import { Base64 } from "js-base64";
+import { topicItoAObj } from "@/utils/changeData";
+
+type Props = {
+  id: number;
+  closeMoalFu: () => void;
+  addTableFu: () => void;
+  editTableFu: () => void;
+};
+
+function TopicAdd({ id, closeMoalFu, addTableFu, editTableFu }: Props) {
+  // 把下拉列表的id存起来,用来对比
+  const [editGoodsId, setEditGoodsId] = useState(0);
+
+  // 通过id获取详情
+  const getTopicDetailFu = useCallback(async (id: number) => {
+    const res = await getTopicDetailAPI(id);
+    const arrTit = JSON.parse(res.data.answer);
+    // 把下拉列表的id存起来,用来对比
+    setEditGoodsId(res.data.goodsId);
+
+    const arrTemp: any = [];
+
+    const obj = {
+      ...res.data,
+      correct: arrTit.correct,
+    };
+
+    arrTit.answer.forEach((v: any, i: number) => {
+      arrTemp.push({ label: topicItoAObj[i], value: v.val });
+      obj[v.val] = v.name;
+    });
+
+    FormBoxRef.current.setFieldsValue(obj);
+
+    setAnswerArr(arrTemp);
+
+    // 回显文物下拉列表
+    const res2 = await topicGoodsSearchAPI(res.data.goodsName);
+    setData(res2.data);
+  }, []);
+
+  // 答案的数组
+  const [answerArr, setAnswerArr] = useState([
+    { label: "A", value: encodeStr(Base64.encode("A")) },
+    { label: "B", value: encodeStr(Base64.encode("B")) },
+  ]);
+
+  // 点击新增选项
+  const addAnswerFu = useCallback(
+    (i: number) => {
+      const label = topicItoAObj[i];
+      const newData = [
+        ...answerArr,
+        { label, value: encodeStr(Base64.encode(label)) },
+      ];
+      setAnswerArr(newData);
+    },
+    [answerArr]
+  );
+
+  // 删除选项
+  const delImgListFu = useCallback(
+    (label: string, ind: number) => {
+      const arr = answerArr.map((v, i) => {
+        return {
+          label: i > ind ? answerArr[i - 1].label : v.label,
+          value: v.value,
+        };
+      });
+      const newData = arr.filter((v, i) => i !== ind);
+      setAnswerArr(newData);
+    },
+    [answerArr]
+  );
+
+  useEffect(() => {
+    if (id > 0) getTopicDetailFu(id);
+  }, [getTopicDetailFu, id]);
+
+  // 表单的ref
+  const FormBoxRef = useRef<any>({});
+  // 没有通过校验
+  const onFinishFailed = useCallback(() => {}, []);
+  // 通过校验点击确定
+  const onFinish = useCallback(
+    async (value: any) => {
+      const arrTemp = [];
+
+      // 过滤掉除了答案的其他字段
+      const arrFilter = ["question", "goodsId", "correct", "description"];
+
+      for (const k in value) {
+        if (!arrFilter.includes(k)) {
+          arrTemp.push({ val: k, name: value[k] });
+        }
+      }
+
+      const answer = {
+        answer: arrTemp,
+        correct: value.correct,
+      };
+
+      const obj: TopicAddType = {
+        answer: JSON.stringify(answer),
+        description: value.description ? value.description : "",
+        goodsId: value.goodsId,
+        id: id > 0 ? id : null,
+        question: value.question,
+      };
+
+      const res = await topicSaveAPI(obj);
+      if (res.code === 0) {
+        MessageFu.success(id > 0 ? "编辑成功!" : "新增成功!");
+        if (id < 0) addTableFu();
+        else editTableFu();
+        closeMoalFu();
+      }
+
+      // console.log("通过校验,点击确定", value);
+    },
+    [addTableFu, closeMoalFu, editTableFu, id]
+  );
+
+  // 关于文物名称的下拉搜索
+  const [value, setValue] = useState(0);
+  const [data, setData] = useState<SelectProps["options"]>([]);
+
+  const timeRef = useRef(0);
+
+  const handleSearch = useCallback((newValue: string) => {
+    if (newValue) {
+      clearTimeout(timeRef.current);
+      timeRef.current = window.setTimeout(async () => {
+        const res = await topicGoodsSearchAPI(newValue);
+        setData(res.data);
+      }, 500);
+    } else setData([]);
+  }, []);
+
+  const handleChange = useCallback(async (newValue: number) => {
+    setValue(newValue);
+  }, []);
+
+  return (
+    <div className={styles.TopicAdd}>
+      <div className="main">
+        {/* 新增答案选项按钮 */}
+        <div className="addAnswer">
+          <Button
+            type="primary"
+            disabled={answerArr.length >= 5}
+            onClick={() => addAnswerFu(answerArr.length)}
+          >
+            新增选项
+          </Button>
+        </div>
+
+        <Form
+          ref={FormBoxRef}
+          name="basic"
+          labelCol={{ span: 3 }}
+          onFinish={onFinish}
+          onFinishFailed={onFinishFailed}
+          autoComplete="off"
+        >
+          <Form.Item
+            label="题目"
+            name="question"
+            rules={[{ required: true, message: "请输入题目!" }]}
+            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
+          >
+            <Input maxLength={100} showCount placeholder="请输入内容" />
+          </Form.Item>
+
+          <Form.Item
+            label="文物"
+            name="goodsId"
+            rules={[
+              { required: true, message: "请选择文物名称!" },
+              {
+                validator: async (rule, value) => {
+                  if (value) {
+                    const res = await topicGetBindingAPI(value);
+                    if (res.data >= 3 && editGoodsId !== value)
+                      return Promise.reject("每个文物最多关联三个问题!");
+                    else return Promise.resolve();
+                  }
+                },
+              },
+            ]}
+          >
+            <Select
+              showSearch
+              value={value}
+              placeholder="请搜索文物名称"
+              style={{ width: 695.63 }}
+              defaultActiveFirstOption={false}
+              showArrow={false}
+              filterOption={false}
+              onSearch={handleSearch}
+              onChange={handleChange}
+              notFoundContent={null}
+              options={(data || []).map((d) => ({
+                value: d.id,
+                label: d.name,
+              }))}
+            />
+          </Form.Item>
+          <Form.Item
+            label="正确答案"
+            name="correct"
+            rules={[
+              { required: true, message: "请选择正确答案!" },
+              {
+                validator: async (rule, value) => {
+                  if (value && answerArr.every((v) => v.value !== value)) {
+                    return Promise.reject("请选择正确答案!");
+                  } else return Promise.resolve();
+                },
+              },
+            ]}
+          >
+            <Radio.Group>
+              {answerArr.map((v) => (
+                <Radio key={v.label} value={v.value}>
+                  {v.label}
+                </Radio>
+              ))}
+            </Radio.Group>
+          </Form.Item>
+
+          {answerArr.map((v, i) => (
+            <Form.Item
+              key={v.label}
+              label={v.label}
+              name={v.value}
+              rules={[{ required: true, message: "请输入答案!" }]}
+              getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
+            >
+              <Input maxLength={100} showCount placeholder="请输入内容" />
+            </Form.Item>
+          ))}
+
+          {/* 删除按钮X */}
+          <div className="btnXBox">
+            {answerArr.map((v, i) =>
+              i > 1 ? (
+                <div className="btnX" key={v.label}>
+                  <Popconfirm
+                    title="删除后无法恢复,是否删除?"
+                    okText="删除"
+                    cancelText="取消"
+                    onConfirm={() => delImgListFu(v.label, i)}
+                  >
+                    <div className="clearCover">
+                      <CloseCircleOutlined />
+                    </div>
+                  </Popconfirm>
+                </div>
+              ) : null
+            )}
+          </div>
+
+          <Form.Item
+            label="解释"
+            name="description"
+            getValueFromEvent={(e) => e.target.value.trim()}
+          >
+            <TextArea
+              rows={4}
+              placeholder="请输入内容"
+              showCount
+              maxLength={200}
+            />
+          </Form.Item>
+          {/* 确定和取消按钮 */}
+          <br />
+          <Form.Item wrapperCol={{ offset: 10, span: 20 }}>
+            <Button type="primary" htmlType="submit">
+              提交
+            </Button>
+            &emsp; &emsp;
+            <Popconfirm
+              title="放弃编辑后,信息将不会保存!"
+              okText="放弃"
+              cancelText="取消"
+              onConfirm={closeMoalFu}
+            >
+              <Button>取消</Button>
+            </Popconfirm>
+          </Form.Item>
+        </Form>
+      </div>
+    </div>
+  );
+}
+
+const MemoTopicAdd = React.memo(TopicAdd);
+
+export default MemoTopicAdd;

+ 32 - 3
houtai/src/pages/B5Topic/index.module.scss

@@ -1,5 +1,34 @@
-.Topic{
-  :global{
-    
+.Topic {
+  :global {
+    .searchTopBox {
+      border-radius: 10px;
+      padding: 20px 15px;
+      background-color: #fff;
+      display: flex;
+
+      .searchTopBoxRow {
+        margin-right: 30px;
+      }
+    }
+
+    .tableBox {
+      border-radius: 10px;
+      overflow: hidden;
+      margin-top: 20px;
+      height: calc(100% - 94px);
+      background-color: #fff;
+
+      .ant-table-body {
+        height: 620px;
+        overflow-y: auto !important;
+        overflow-y: overlay !important;
+
+        .ant-table-row {
+          .ant-table-cell {
+            padding: 10px;
+          }
+        }
+      }
+    }
   }
 }

+ 285 - 5
houtai/src/pages/B5Topic/index.tsx

@@ -1,12 +1,292 @@
-import React from "react";
+import { RootState } from "@/store";
+import {
+  getTopicListAPI,
+  topicDisplayAPI,
+  topicRemoveAPI,
+} from "@/store/action/B5Topic";
+import { TopicTableType } from "@/types";
+import { MessageFu } from "@/utils/message";
+import { Button, Input, Popconfirm, Select, Switch, Table } from "antd";
+import React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+} from "react";
+import { useDispatch, useSelector } from "react-redux";
 import styles from "./index.module.scss";
- function Topic() {
-  
+import TopicAdd from "./TopicAdd";
+function Topic() {
+  const dispatch = useDispatch();
+  const pageNumRef = useRef(1);
+  const pagePageRef = useRef(10);
+
+  // 顶部筛选
+  const [tableSelect, setTableSelect] = useState({
+    searchKey: "",
+    goodsName: "",
+    type: -1,
+    pageSize: 10,
+    pageNum: 1,
+  });
+
+  // 封装发送请求的函数
+
+  const getList = useCallback(async () => {
+    const data = {
+      ...tableSelect,
+      type: tableSelect.type === -1 ? null : tableSelect.type,
+      pageNum: pageNumRef.current,
+    };
+    dispatch(getTopicListAPI(data));
+  }, [dispatch, tableSelect]);
+
+  // 当前页码统一
+  useEffect(() => {
+    pageNumRef.current = tableSelect.pageNum;
+    pagePageRef.current = tableSelect.pageSize;
+  }, [tableSelect.pageNum, tableSelect.pageSize]);
+
+  useEffect(() => {
+    getList();
+  }, [getList]);
+
+  // 题目标题的输入
+  const nameTime = useRef(-1);
+  const nameChange = useCallback(
+    (e: React.ChangeEvent<HTMLInputElement>) => {
+      clearTimeout(nameTime.current);
+      nameTime.current = window.setTimeout(() => {
+        setTableSelect({
+          ...tableSelect,
+          searchKey: e.target.value,
+          pageNum: 1,
+        });
+      }, 500);
+    },
+    [tableSelect]
+  );
+
+  // 关联文物的输入
+  const nameTime2 = useRef(-1);
+  const nameChange2 = useCallback(
+    (e: React.ChangeEvent<HTMLInputElement>) => {
+      clearTimeout(nameTime2.current);
+      nameTime2.current = window.setTimeout(() => {
+        setTableSelect({
+          ...tableSelect,
+          goodsName: e.target.value,
+          pageNum: 1,
+        });
+      }, 500);
+    },
+    [tableSelect]
+  );
+
+  // 从仓库获取表格列表信息
+  const tableInfo = useSelector(
+    (state: RootState) => state.topicReducer.tableInfo
+  );
+
+  // 点击重置
+  const [inputKey, setInputKey] = useState(1);
+  const resetSelectFu = useCallback(() => {
+    // 把2个输入框和时间选择器清空
+    setInputKey(Date.now());
+    setTableSelect({
+      searchKey: "",
+      goodsName: "",
+      type: -1,
+      pageSize: 10,
+      pageNum: 1,
+    });
+  }, []);
+
+  // 切换表格中的启用停用状态
+  const isEnabledClickFu = useCallback(
+    async (val: boolean, id: number) => {
+      const isDisable = val ? 1 : 0;
+      const res = await topicDisplayAPI(id, isDisable);
+      if (res.code === 0) getList();
+    },
+    [getList]
+  );
+
+  // 点击删除
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await topicRemoveAPI(id);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        getList();
+      }
+    },
+    [getList]
+  );
+
+  const columns = useMemo(() => {
+    return [
+      {
+        title: "题目",
+        render: (item: TopicTableType) =>
+          item.question.length >= 50 ? (
+            <span style={{ cursor: "pointer" }} title={item.question}>
+              {item.question.substring(0, 50) + "..."}
+            </span>
+          ) : (
+            item.question
+          ),
+      },
+      {
+        title: "文物",
+        dataIndex: "goodsName",
+      },
+      {
+        title: "回答数",
+        dataIndex: "pcsAnswer",
+      },
+      {
+        title: "正确率",
+        render: (item: TopicTableType) =>
+          item.pcsAnswer ? item.pcsAccuracy + "%" : "(空)",
+      },
+      {
+        title: "最后编辑时间",
+        dataIndex: "updateTime",
+      },
+      {
+        title: "编辑人",
+        dataIndex: "creatorName",
+      },
+      {
+        title: "展示状态",
+        render: (item: TopicTableType) => (
+          <Switch
+            checkedChildren="启用"
+            unCheckedChildren="停用"
+            checked={item.display === 1}
+            onChange={(val) => isEnabledClickFu(val, item.id!)}
+          />
+        ),
+      },
+      {
+        title: "操作",
+        render: (item: TopicTableType) => (
+          <>
+            <Button size="small" type="text" onClick={() => setAddId(item.id)}>
+              编辑
+            </Button>
+            <Popconfirm
+              title="删除后无法恢复,是否删除?"
+              okText="删除"
+              cancelText="取消"
+              onConfirm={() => delTableFu(item.id)}
+            >
+              <Button size="small" type="text" danger>
+                删除
+              </Button>
+            </Popconfirm>
+          </>
+        ),
+      },
+    ];
+  }, [delTableFu, isEnabledClickFu]);
+
+  // 页码变化
+  const paginationChange = useCallback(
+    () => (pageNum: number, pageSize: number) => {
+      pageNumRef.current = pageNum;
+      pagePageRef.current = pageSize;
+      setTableSelect({ ...tableSelect, pageNum, pageSize });
+    },
+    [tableSelect]
+  );
+
+  // 新增或者编辑的弹窗
+  const [addId, setAddId] = useState(0);
+
   return (
     <div className={styles.Topic}>
-      <h1>Topic</h1>
+      <div className="pageTitlt">
+        {addId === 0 ? "题库管理" : addId > 0 ? "编辑题目" : "新增题目"}
+      </div>
+      {/* 上面的搜索盒子 */}
+      <div className="searchTopBox" hidden={addId !== 0}>
+        <div className="searchTopBoxRow">
+          <span>题目标题:</span>
+          <Input
+            key={inputKey}
+            maxLength={25}
+            style={{ width: 200 }}
+            placeholder="请输入关键字"
+            allowClear
+            onChange={(e) => nameChange(e)}
+          />
+        </div>
+        <div className="searchTopBoxRow">
+          <span>关联文物:</span>
+          <Input
+            key={inputKey}
+            maxLength={10}
+            style={{ width: 200 }}
+            placeholder="请输入关键字"
+            allowClear
+            onChange={(e) => nameChange2(e)}
+          />
+        </div>
+        <div className="searchTopBoxRow">
+          <span>回答情况:</span>
+          <Select
+            placeholder="请选择"
+            style={{ width: 120 }}
+            value={tableSelect.type}
+            onChange={(e) =>
+              setTableSelect({ ...tableSelect, type: e, pageNum: 1 })
+            }
+            options={[
+              { value: -1, label: "全部" },
+              { value: 0, label: "无人回答" },
+              { value: 1, label: "有人回答" },
+            ]}
+          />
+        </div>
+        <div className="searchTopBoxRow">
+          &emsp;&emsp;<Button onClick={resetSelectFu}>重置</Button>&emsp;&emsp;
+          <Button type="primary" onClick={() => setAddId(-1)}>
+            新增
+          </Button>
+        </div>
+      </div>
+      {/* 表格主体 */}
+      <div className="tableBox" hidden={addId !== 0}>
+        <Table
+          scroll={{ y: 620 }}
+          dataSource={tableInfo.list}
+          columns={columns}
+          rowKey="id"
+          pagination={{
+            showQuickJumper: true,
+            position: ["bottomCenter"],
+            showSizeChanger: true,
+            current: tableSelect.pageNum,
+            pageSize: tableSelect.pageSize,
+            total: tableInfo.total,
+            onChange: paginationChange(),
+          }}
+        />
+      </div>
+      {/* 新增和编辑的弹窗 */}
+      {addId ? (
+        <TopicAdd
+          id={addId}
+          closeMoalFu={() => setAddId(0)}
+          addTableFu={resetSelectFu}
+          editTableFu={getList}
+        />
+      ) : null}
     </div>
-  )
+  );
 }
 
 const MemoTopic = React.memo(Topic);

+ 6 - 1
houtai/src/pages/C3Log/index.tsx

@@ -78,9 +78,14 @@ function Log() {
         dataIndex: "ip",
       },
       {
-        title: "操作记录",
+        title: "操作模块",
         dataIndex: "type",
       },
+      {
+        title: "操作事件",
+        dataIndex: "description",
+      },
+
     ];
   }, []);
 

+ 59 - 0
houtai/src/store/action/B5Topic.ts

@@ -0,0 +1,59 @@
+import { TopicAddType } from "@/types";
+import http from "@/utils/http";
+import { AppDispatch } from "..";
+
+/**
+ * 获取列表数据
+ */
+export const getTopicListAPI = (data: any) => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post("cms/question/pageList", data);
+
+    dispatch({
+      type: "topic/getList",
+      payload: { list: res.data.records, total: res.data.total },
+    });
+  };
+};
+
+/**
+ * 内容-是否显示
+ */
+export const topicDisplayAPI = (id: number, display: number) => {
+  return http.get(`cms/question/display/${id}/${display}`);
+};
+
+/**
+ * 删除表格
+ */
+export const topicRemoveAPI = (id: number) => {
+  return http.get(`cms/question/remove/${id}`);
+};
+
+/**
+ * 搜索文物列表
+ */
+export const topicGoodsSearchAPI = (name: string) => {
+  return http.get(`cms/question/goods/search/${name}`);
+};
+
+/**
+ * 新增和编辑题目
+ */
+export const topicSaveAPI = (data: TopicAddType) => {
+  return http.post("cms/question/save", data);
+};
+
+/**
+ * 通过id获取详情
+ */
+export const getTopicDetailAPI = (id: number) => {
+  return http.get(`cms/question/detail/${id}`);
+};
+
+/**
+ * 通过id获取详情
+ */
+export const topicGetBindingAPI = (goodsId: number) => {
+  return http.get(`cms/question/getBinding/${goodsId}`);
+};

+ 31 - 0
houtai/src/store/reducer/B5Topic.ts

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

+ 3 - 1
houtai/src/store/reducer/index.ts

@@ -3,6 +3,7 @@ import { combineReducers } from 'redux'
 import goodsReducer from './B2Goods'
 import wallReducer from './B3Wall'
 import barrageReducer from './B4Barrage'
+import topicReducer from './B5Topic'
 import smartReducer from './B6Smart'
 import logReducer from './C3log'
 
@@ -16,7 +17,8 @@ const rootReducer = combineReducers({
   goodsReducer:goodsReducer,
   wallReducer:wallReducer,
   barrageReducer:barrageReducer,
-  smartReducer:smartReducer
+  smartReducer:smartReducer,
+  topicReducer:topicReducer
 })
 
 // 默认导出

houtai/src/types/api/barrage.ts → houtai/src/types/api/barrage.d.ts


houtai/src/types/api/smart.ts → houtai/src/types/api/smart.d.ts


+ 28 - 0
houtai/src/types/api/topic.d.ts

@@ -0,0 +1,28 @@
+export type TopicAddType ={
+  answer:string
+  description:string
+  goodsId:number
+  id:number|null
+  question:string
+  A?:string
+  B?:string
+  C?:string
+  D?:string
+  correct?:string
+}
+
+export type TopicTableType ={
+  answer: string;
+  createTime: string;
+  creatorId: number;
+  creatorName: string;
+  description: string;
+  display: number;
+  goodsId: number;
+  id: number;
+  pcsAccuracy: number;
+  pcsAnswer: number;
+  pcsTrue: number;
+  question: string;
+  updateTime: string;
+}

+ 2 - 1
houtai/src/types/index.d.ts

@@ -4,4 +4,5 @@ export * from './api/wall'
 export * from './api/hot'
 export * from './api/goods'
 export * from './api/barrage'
-export * from './api/smart'
+export * from './api/smart'
+export * from './api/topic'

+ 13 - 5
houtai/src/utils/changeData.ts

@@ -5,8 +5,16 @@ export const typeChangeObj = {
   video: "视频",
 };
 
-export const hotChangeObj ={
-  goods:'馆藏',
-  scene:'VR场景',
-  video:'视频'
-}
+export const hotChangeObj = {
+  goods: "馆藏",
+  scene: "VR场景",
+  video: "视频",
+};
+
+export const topicItoAObj: { [x: number]: string } = {
+  0: "A",
+  1: "B",
+  2: "C",
+  3: "D",
+  4: "E",
+};