From 2a6e451417eaf1182aa52cab86426d8ee127875a Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Mon, 7 Aug 2023 10:41:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/create.tsx | 24 ++++++++++------ src/pages/course/compenents/update.tsx | 14 +++++++--- src/pages/department/index.tsx | 6 ++-- .../videos/compenents/update-dialog/index.tsx | 18 +++++++++--- .../compenents/video-play-dialog/index.tsx | 2 +- .../administrator/compenents/create.tsx | 11 ++++++-- .../administrator/compenents/update.tsx | 13 ++++++--- src/pages/system/administrator/index.tsx | 21 ++------------ .../adminlog/compenents/detail-dialog.tsx | 4 +-- src/pages/system/adminlog/index.tsx | 2 +- .../system/adminroles/compenents/create.tsx | 6 ++-- .../system/adminroles/compenents/update.tsx | 6 ++-- src/pages/system/config/index.tsx | 8 +++--- src/playedu.d.ts | 28 +++++++++++++++++++ 14 files changed, 103 insertions(+), 60 deletions(-) diff --git a/src/pages/course/compenents/create.tsx b/src/pages/course/compenents/create.tsx index ac9e37c..cb1d9b0 100644 --- a/src/pages/course/compenents/create.tsx +++ b/src/pages/course/compenents/create.tsx @@ -32,6 +32,12 @@ interface PropInterface { onCancel: () => void; } +interface Option { + value: string | number; + title: string; + children?: Option[]; +} + export const CourseCreate: React.FC = ({ cateIds, depIds, @@ -45,20 +51,20 @@ export const CourseCreate: React.FC = ({ const defaultThumb1 = courseDefaultThumbs[0]; const defaultThumb2 = courseDefaultThumbs[1]; const defaultThumb3 = courseDefaultThumbs[2]; - const [loading, setLoading] = useState(true); - const [departments, setDepartments] = useState([]); - const [categories, setCategories] = useState([]); - const [thumb, setThumb] = useState(""); - const [type, setType] = useState("open"); + const [loading, setLoading] = useState(true); + const [departments, setDepartments] = useState([]); + const [categories, setCategories] = useState([]); + const [thumb, setThumb] = useState(""); + const [type, setType] = useState("open"); const [chapterType, setChapterType] = useState(0); const [chapters, setChapters] = useState([]); const [hours, setHours] = useState([]); const [chapterHours, setChapterHours] = useState([]); - const [videoVisible, setVideoVisible] = useState(false); + const [videoVisible, setVideoVisible] = useState(false); const [treeData, setTreeData] = useState([]); const [addvideoCurrent, setAddvideoCurrent] = useState(0); - const [showDrop, setShowDrop] = useState(false); - const [attachmentVisible, setAttachmentVisible] = useState(false); + const [showDrop, setShowDrop] = useState(false); + const [attachmentVisible, setAttachmentVisible] = useState(false); const [attachmentData, setAttachmentData] = useState([]); const [attachments, setAttachments] = useState([]); @@ -91,7 +97,7 @@ export const CourseCreate: React.FC = ({ const getParams = () => { department.departmentList().then((res: any) => { const departments = res.data.departments; - const departCount = res.data.dep_user_count; + const departCount: DepIdsModel = res.data.dep_user_count; if (JSON.stringify(departments) !== "{}") { const new_arr: any = checkArr(departments, 0, departCount); setDepartments(new_arr); diff --git a/src/pages/course/compenents/update.tsx b/src/pages/course/compenents/update.tsx index 60356ab..60fce1f 100644 --- a/src/pages/course/compenents/update.tsx +++ b/src/pages/course/compenents/update.tsx @@ -22,6 +22,12 @@ interface PropInterface { onCancel: () => void; } +interface Option { + value: string | number; + title: string; + children?: Option[]; +} + export const CourseUpdate: React.FC = ({ id, open, @@ -36,10 +42,10 @@ export const CourseUpdate: React.FC = ({ const defaultThumb2 = courseDefaultThumbs[1]; const defaultThumb3 = courseDefaultThumbs[2]; const [loading, setLoading] = useState(true); - const [departments, setDepartments] = useState([]); - const [categories, setCategories] = useState([]); - const [thumb, setThumb] = useState(""); - const [type, setType] = useState("open"); + const [departments, setDepartments] = useState([]); + const [categories, setCategories] = useState([]); + const [thumb, setThumb] = useState(""); + const [type, setType] = useState("open"); useEffect(() => { setInit(true); diff --git a/src/pages/department/index.tsx b/src/pages/department/index.tsx index 6752be7..7617bc5 100644 --- a/src/pages/department/index.tsx +++ b/src/pages/department/index.tsx @@ -23,13 +23,13 @@ const DepartmentPage = () => { const permissions = useSelector( (state: any) => state.loginUser.value.permissions ); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); const [refresh, setRefresh] = useState(false); const [treeData, setTreeData] = useState([]); const [selectKey, setSelectKey] = useState([]); - const [createVisible, setCreateVisible] = useState(false); - const [updateVisible, setUpdateVisible] = useState(false); + const [createVisible, setCreateVisible] = useState(false); + const [updateVisible, setUpdateVisible] = useState(false); const [did, setDid] = useState(0); const [modal, contextHolder] = Modal.useModal(); diff --git a/src/pages/resource/videos/compenents/update-dialog/index.tsx b/src/pages/resource/videos/compenents/update-dialog/index.tsx index 7b424ea..efc17e0 100644 --- a/src/pages/resource/videos/compenents/update-dialog/index.tsx +++ b/src/pages/resource/videos/compenents/update-dialog/index.tsx @@ -9,6 +9,12 @@ interface PropInterface { onSuccess: () => void; } +interface Option { + value: string | number; + title: string; + children?: Option[]; +} + export const VideosUpdateDialog: React.FC = ({ id, open, @@ -16,9 +22,9 @@ export const VideosUpdateDialog: React.FC = ({ onSuccess, }) => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); const [init, setInit] = useState(true); - const [categories, setCategories] = useState([]); + const [categories, setCategories] = useState([]); useEffect(() => { setInit(true); @@ -33,7 +39,7 @@ export const VideosUpdateDialog: React.FC = ({ const getCategory = () => { resourceCategory.resourceCategoryList().then((res: any) => { - const categories = res.data.categories; + const categories: CategoriesBoxModel = res.data.categories; if (JSON.stringify(categories) !== "{}") { const new_arr: any = checkArr(categories, 0, null); setCategories(new_arr); @@ -52,7 +58,11 @@ export const VideosUpdateDialog: React.FC = ({ }); }; - const checkArr = (departments: any[], id: number, counts: any) => { + const checkArr = ( + departments: CategoriesBoxModel, + id: number, + counts: any + ) => { const arr = []; for (let i = 0; i < departments[id].length; i++) { if (!departments[departments[id][i].id]) { diff --git a/src/pages/resource/videos/compenents/video-play-dialog/index.tsx b/src/pages/resource/videos/compenents/video-play-dialog/index.tsx index df7d064..42fbdf4 100644 --- a/src/pages/resource/videos/compenents/video-play-dialog/index.tsx +++ b/src/pages/resource/videos/compenents/video-play-dialog/index.tsx @@ -17,7 +17,7 @@ export const VideoPlayDialog: React.FC = ({ open, onCancel, }) => { - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); useEffect(() => { if (open && url) { diff --git a/src/pages/system/administrator/compenents/create.tsx b/src/pages/system/administrator/compenents/create.tsx index 392c4a8..49d4a07 100644 --- a/src/pages/system/administrator/compenents/create.tsx +++ b/src/pages/system/administrator/compenents/create.tsx @@ -10,6 +10,11 @@ interface PropInterface { onCancel: () => void; } +type selRoleModel = { + label: string; + value: number; +}; + export const SystemAdministratorCreate: React.FC = ({ roleId, refresh, @@ -17,8 +22,8 @@ export const SystemAdministratorCreate: React.FC = ({ onCancel, }) => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(true); - const [roles, setRoles] = useState([]); + const [loading, setLoading] = useState(true); + const [roles, setRoles] = useState([]); useEffect(() => { if (open) { @@ -43,7 +48,7 @@ export const SystemAdministratorCreate: React.FC = ({ const getParams = () => { adminUser.createAdminUser().then((res: any) => { const arr = []; - let roles = res.data.roles; + let roles: RoleModel[] = res.data.roles; for (let i = 0; i < roles.length; i++) { arr.push({ label: roles[i].name, diff --git a/src/pages/system/administrator/compenents/update.tsx b/src/pages/system/administrator/compenents/update.tsx index d953202..afb2913 100644 --- a/src/pages/system/administrator/compenents/update.tsx +++ b/src/pages/system/administrator/compenents/update.tsx @@ -10,6 +10,11 @@ interface PropInterface { onCancel: () => void; } +type selRoleModel = { + label: string; + value: number; +}; + export const SystemAdministratorUpdate: React.FC = ({ id, refresh, @@ -18,8 +23,8 @@ export const SystemAdministratorUpdate: React.FC = ({ }) => { const [form] = Form.useForm(); const [init, setInit] = useState(true); - const [loading, setLoading] = useState(true); - const [roles, setRoles] = useState([]); + const [loading, setLoading] = useState(true); + const [roles, setRoles] = useState([]); useEffect(() => { if (open) { @@ -40,7 +45,7 @@ export const SystemAdministratorUpdate: React.FC = ({ const getParams = () => { adminUser.createAdminUser().then((res: any) => { const arr = []; - let roles = res.data.roles; + let roles: RoleModel[] = res.data.roles; for (let i = 0; i < roles.length; i++) { arr.push({ label: roles[i].name, @@ -53,7 +58,7 @@ export const SystemAdministratorUpdate: React.FC = ({ const getDetail = () => { adminUser.AdminUser(id).then((res: any) => { - let user = res.data.user; + let user: AdminUserDetailModel = res.data.user; form.setFieldsValue({ email: user.email, name: user.name, diff --git a/src/pages/system/administrator/index.tsx b/src/pages/system/administrator/index.tsx index 83e95ec..30af95d 100644 --- a/src/pages/system/administrator/index.tsx +++ b/src/pages/system/administrator/index.tsx @@ -25,22 +25,6 @@ interface DataType { updated_at: string; } -type RolesModel = { - [key: number]: RoleModel[]; -}; - -type RoleModel = { - created_at: string; - id: number; - name: string; - slug: string; - updated_at: string; -}; - -type RoleIdsModel = { - [key: number]: number[]; -}; - const SystemAdministratorPage = () => { const navigate = useNavigate(); const [loading, setLoading] = useState(true); @@ -57,11 +41,10 @@ const SystemAdministratorPage = () => { const [updateRoleVisible, setUpdateRoleVisible] = useState(false); const [cid, setCid] = useState(0); const [role_ids, setRoleIds] = useState([]); - const [selLabel, setLabel] = useState("全部管理员"); + const [selLabel, setLabel] = useState("全部管理员"); const [roleDelSuccess, setRoleDelSuccess] = useState(false); const [isSuper, setIsSuper] = useState(false); - - const [name, setName] = useState(""); + const [name, setName] = useState(""); const columns: ColumnsType = [ { diff --git a/src/pages/system/adminlog/compenents/detail-dialog.tsx b/src/pages/system/adminlog/compenents/detail-dialog.tsx index 2070095..52a68e0 100644 --- a/src/pages/system/adminlog/compenents/detail-dialog.tsx +++ b/src/pages/system/adminlog/compenents/detail-dialog.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import { Modal, Form } from "antd"; interface PropInterface { @@ -15,7 +15,7 @@ export const AdminLogDetailDialog: React.FC = ({ result, }) => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(true); const onFinish = (values: any) => {}; diff --git a/src/pages/system/adminlog/index.tsx b/src/pages/system/adminlog/index.tsx index 276ed7c..cabde4a 100644 --- a/src/pages/system/adminlog/index.tsx +++ b/src/pages/system/adminlog/index.tsx @@ -35,7 +35,7 @@ const SystemLogPage = () => { const [title, setTitle] = useState(""); const [adminId, setAdminId] = useState(""); const [adminName, setAdminName] = useState(""); - const [created_at, setCreatedAt] = useState([]); + const [created_at, setCreatedAt] = useState([]); const [createdAts, setCreatedAts] = useState([]); const [param, setParam] = useState(""); const [result, setResult] = useState(""); diff --git a/src/pages/system/adminroles/compenents/create.tsx b/src/pages/system/adminroles/compenents/create.tsx index 383a5a3..ede5536 100644 --- a/src/pages/system/adminroles/compenents/create.tsx +++ b/src/pages/system/adminroles/compenents/create.tsx @@ -19,9 +19,9 @@ export const SystemAdminrolesCreate: React.FC = ({ onCancel, }) => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(true); - const [permissions, setPermissions] = useState([]); - const [actions, setActions] = useState([]); + const [loading, setLoading] = useState(true); + const [permissions, setPermissions] = useState([]); + const [actions, setActions] = useState([]); useEffect(() => { if (open) { diff --git a/src/pages/system/adminroles/compenents/update.tsx b/src/pages/system/adminroles/compenents/update.tsx index 36b0504..68d1e57 100644 --- a/src/pages/system/adminroles/compenents/update.tsx +++ b/src/pages/system/adminroles/compenents/update.tsx @@ -31,9 +31,9 @@ export const SystemAdminrolesUpdate: React.FC = ({ }) => { const [form] = Form.useForm(); const [init, setInit] = useState(true); - const [loading, setLoading] = useState(true); - const [permissions, setPermissions] = useState([]); - const [actions, setActions] = useState([]); + const [loading, setLoading] = useState(true); + const [permissions, setPermissions] = useState([]); + const [actions, setActions] = useState([]); useEffect(() => { if (open) { diff --git a/src/pages/system/config/index.tsx b/src/pages/system/config/index.tsx index 4e8dfbe..024b678 100644 --- a/src/pages/system/config/index.tsx +++ b/src/pages/system/config/index.tsx @@ -20,10 +20,10 @@ import type { CheckboxChangeEvent } from "antd/es/checkbox"; const SystemConfigPage = () => { const [form] = Form.useForm(); - const [loading, setLoading] = useState(false); - const [logo, setLogo] = useState(""); - const [thumb, setThumb] = useState(""); - const [avatar, setAvatar] = useState(""); + const [loading, setLoading] = useState(false); + const [logo, setLogo] = useState(""); + const [thumb, setThumb] = useState(""); + const [avatar, setAvatar] = useState(""); const [tabKey, setTabKey] = useState(1); const [nameChecked, setNameChecked] = useState(false); const [emailChecked, setEmailChecked] = useState(false); diff --git a/src/playedu.d.ts b/src/playedu.d.ts index 644b204..910e705 100644 --- a/src/playedu.d.ts +++ b/src/playedu.d.ts @@ -35,6 +35,18 @@ declare global { verify_at?: string; } + interface AdminUserDetailModel { + created_at: string; + email: string; + id: number; + is_ban_login: number; + login_at: string; + login_ip: string; + login_times: number; + name: string; + updated_at: string; + } + interface CourseModel { charge: number; class_hour: number; @@ -88,6 +100,22 @@ declare global { sort: number; updated_at: string; } + + interface RolesModel { + [key: number]: RoleModel[]; + } + + interface RoleModel { + created_at: string; + id: number; + name: string; + slug: string; + updated_at: string; + } + + interface RoleIdsModel { + [key: number]: number[]; + } } export {};