mirror of
https://github.com/PlayEdu/backend
synced 2026-01-01 20:19:46 +08:00
数据结构添加interface
This commit is contained in:
@@ -9,11 +9,9 @@ import {
|
||||
Select,
|
||||
Button,
|
||||
} from "antd";
|
||||
import type { MenuProps } from "antd";
|
||||
import { resource } from "../../../api";
|
||||
// import styles from "./index.module.less";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { DownOutlined, ExclamationCircleFilled } from "@ant-design/icons";
|
||||
import { ExclamationCircleFilled } from "@ant-design/icons";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
import { dateFormat } from "../../../utils/index";
|
||||
import { TreeCategory, UploadCoursewareButton } from "../../../compenents";
|
||||
@@ -22,34 +20,45 @@ import { CoursewareUpdateDialog } from "./compenents/update-dialog";
|
||||
const { confirm } = Modal;
|
||||
|
||||
interface DataType {
|
||||
admin_id: number;
|
||||
created_at: string;
|
||||
disk: string;
|
||||
extension: string;
|
||||
file_id: string;
|
||||
id: React.Key;
|
||||
name: string;
|
||||
created_at: string;
|
||||
parent_id: number;
|
||||
path: string;
|
||||
size: number;
|
||||
type: string;
|
||||
number: number;
|
||||
url: string;
|
||||
}
|
||||
|
||||
type AdminUsersModel = {
|
||||
[key: number]: string;
|
||||
};
|
||||
|
||||
const ResourceCoursewarePage = () => {
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
const [list, setList] = useState<any>([]);
|
||||
const [adminUsers, setAdminUsers] = useState<any>({});
|
||||
const [existingTypes, setExistingTypes] = useState<any>([]);
|
||||
const [list, setList] = useState<DataType[]>([]);
|
||||
const [adminUsers, setAdminUsers] = useState<AdminUsersModel>({});
|
||||
const [existingTypes, setExistingTypes] = useState<string[]>([]);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(10);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [category_ids, setCategoryIds] = useState<number[]>([]);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]);
|
||||
const [type, setType] = useState("WORD,EXCEL,PPT,PDF,TXT,RAR,ZIP");
|
||||
const [title, setTitle] = useState<string>("");
|
||||
const [multiConfig, setMultiConfig] = useState<boolean>(false);
|
||||
const [title, setTitle] = useState("");
|
||||
const [multiConfig, setMultiConfig] = useState(false);
|
||||
const [selLabel, setLabel] = useState<string>(
|
||||
result.get("label") ? String(result.get("label")) : "全部课件"
|
||||
);
|
||||
const [cateId, setCateId] = useState(Number(result.get("cid")));
|
||||
const [updateId, setUpdateId] = useState(0);
|
||||
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||
const [updateVisible, setUpdateVisible] = useState(false);
|
||||
const types = [
|
||||
{ label: "全部", value: "WORD,EXCEL,PPT,PDF,TXT,RAR,ZIP" },
|
||||
{ label: "WORD", value: "WORD" },
|
||||
|
||||
@@ -14,7 +14,7 @@ import { resource } from "../../../api";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import styles from "./index.module.less";
|
||||
import { UploadImageSub } from "../../../compenents/upload-image-button/upload-image-sub";
|
||||
import { TreeCategory, PerButton } from "../../../compenents";
|
||||
import { TreeCategory } from "../../../compenents";
|
||||
import { ExclamationCircleFilled, CheckOutlined } from "@ant-design/icons";
|
||||
|
||||
const { confirm } = Modal;
|
||||
@@ -39,14 +39,14 @@ const ResourceImagesPage = () => {
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(32);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||
const [selectKey, setSelectKey] = useState<any>([]);
|
||||
const [visibleArr, setVisibleArr] = useState<any>([]);
|
||||
const [hoverArr, setHoverArr] = useState<any>([]);
|
||||
const [category_ids, setCategoryIds] = useState<number[]>([]);
|
||||
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||
const [visibleArr, setVisibleArr] = useState<boolean[]>([]);
|
||||
const [hoverArr, setHoverArr] = useState<boolean[]>([]);
|
||||
const [selLabel, setLabel] = useState<string>(
|
||||
result.get("label") ? String(result.get("label")) : "全部图片"
|
||||
);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [cateId, setCateId] = useState(Number(result.get("cid")));
|
||||
|
||||
useEffect(() => {
|
||||
@@ -96,7 +96,7 @@ const ResourceImagesPage = () => {
|
||||
.then((res: any) => {
|
||||
setTotal(res.data.result.total);
|
||||
setImageList(res.data.result.data);
|
||||
let data = res.data.result.data;
|
||||
let data: ImageItem[] = res.data.result.data;
|
||||
let arr = [];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
arr.push(false);
|
||||
|
||||
@@ -25,8 +25,8 @@ const ResourceCategoryPage = () => {
|
||||
);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [selectKey, setSelectKey] = useState<any>([]);
|
||||
const [treeData, setTreeData] = useState<Option[]>([]);
|
||||
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||
const [createVisible, setCreateVisible] = useState<boolean>(false);
|
||||
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||
const [cid, setCid] = useState<number>(0);
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
|
||||
import { Modal, Table, message, Space, Dropdown, Button } from "antd";
|
||||
import type { MenuProps } from "antd";
|
||||
import { resource } from "../../../api";
|
||||
// import styles from "./index.module.less";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { DownOutlined, ExclamationCircleFilled } from "@ant-design/icons";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
@@ -16,32 +15,54 @@ const { confirm } = Modal;
|
||||
|
||||
interface DataType {
|
||||
id: React.Key;
|
||||
name: string;
|
||||
admin_id: number;
|
||||
created_at: string;
|
||||
disk: string;
|
||||
extension: string;
|
||||
file_id: string;
|
||||
name: string;
|
||||
parent_id: number;
|
||||
path: string;
|
||||
size: number;
|
||||
type: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
type VideosExtraModel = {
|
||||
[key: number]: VideoModel;
|
||||
};
|
||||
|
||||
type VideoModel = {
|
||||
duration: number;
|
||||
poster: string;
|
||||
rid: number;
|
||||
};
|
||||
|
||||
type AdminUsersModel = {
|
||||
[key: number]: string;
|
||||
};
|
||||
|
||||
const ResourceVideosPage = () => {
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
const [videoList, setVideoList] = useState<any>([]);
|
||||
const [videosExtra, setVideoExtra] = useState<any>([]);
|
||||
const [adminUsers, setAdminUsers] = useState<any>({});
|
||||
const [videoList, setVideoList] = useState<DataType[]>([]);
|
||||
const [videosExtra, setVideoExtra] = useState<VideosExtraModel>({});
|
||||
const [adminUsers, setAdminUsers] = useState<AdminUsersModel>({});
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(10);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [category_ids, setCategoryIds] = useState<number[]>([]);
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]);
|
||||
const [selLabel, setLabel] = useState<string>(
|
||||
result.get("label") ? String(result.get("label")) : "全部视频"
|
||||
);
|
||||
const [cateId, setCateId] = useState(Number(result.get("cid")));
|
||||
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||
const [playVisible, setPlayeVisible] = useState<boolean>(false);
|
||||
const [multiConfig, setMultiConfig] = useState<boolean>(false);
|
||||
const [updateVisible, setUpdateVisible] = useState(false);
|
||||
const [playVisible, setPlayeVisible] = useState(false);
|
||||
const [multiConfig, setMultiConfig] = useState(false);
|
||||
const [updateId, setUpdateId] = useState(0);
|
||||
const [playUrl, setPlayUrl] = useState<string>("");
|
||||
const [playUrl, setPlayUrl] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
setCateId(Number(result.get("cid")));
|
||||
@@ -72,20 +93,22 @@ const ResourceVideosPage = () => {
|
||||
{
|
||||
title: "视频时长",
|
||||
dataIndex: "id",
|
||||
render: (id: string) => (
|
||||
render: (id: number) => (
|
||||
<DurationText duration={videosExtra[id].duration}></DurationText>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "创建人",
|
||||
dataIndex: "admin_id",
|
||||
render: (text: number) =>
|
||||
JSON.stringify(adminUsers) !== "{}" && <span>{adminUsers[text]}</span>,
|
||||
render: (admin_id: number) =>
|
||||
JSON.stringify(adminUsers) !== "{}" && (
|
||||
<span>{adminUsers[admin_id]}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
dataIndex: "created_at",
|
||||
render: (text: string) => <span>{dateFormat(text)}</span>,
|
||||
render: (created_at: string) => <span>{dateFormat(created_at)}</span>,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
|
||||
Reference in New Issue
Block a user