mirror of
https://github.com/PlayEdu/backend
synced 2025-06-29 17:32:48 +08:00
commit
0fe75d745e
@ -7,7 +7,7 @@
|
|||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
|
||||||
/>
|
/>
|
||||||
<title>PlayEdu</title>
|
<title>管理后台</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
@ -3,3 +3,7 @@ import client from "./internal/httpClient";
|
|||||||
export function getImageCaptcha() {
|
export function getImageCaptcha() {
|
||||||
return client.get("/backend/v1/system/image-captcha", {});
|
return client.get("/backend/v1/system/image-captcha", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSystemConfig() {
|
||||||
|
return client.get("/backend/v1/system/config", {});
|
||||||
|
}
|
@ -13,7 +13,7 @@ export const Footer: React.FC = () => {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link to="https://playedu.xyz/">
|
<Link to="https://playedu.xyz/" target="blank">
|
||||||
<i
|
<i
|
||||||
style={{ fontSize: 30, color: "#cccccc" }}
|
style={{ fontSize: 30, color: "#cccccc" }}
|
||||||
className="iconfont icon-waterprint footer-icon"
|
className="iconfont icon-waterprint footer-icon"
|
||||||
|
@ -89,13 +89,16 @@ export const TreeCategory = (props: PropInterface) => {
|
|||||||
<span>全部{props.text}</span>
|
<span>全部{props.text}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Tree
|
{treeData.length > 0 && (
|
||||||
onSelect={onSelect}
|
<Tree
|
||||||
selectedKeys={selectKey}
|
onSelect={onSelect}
|
||||||
onExpand={onExpand}
|
selectedKeys={selectKey}
|
||||||
treeData={treeData}
|
onExpand={onExpand}
|
||||||
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
treeData={treeData}
|
||||||
/>
|
defaultExpandAll={true}
|
||||||
|
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -90,13 +90,16 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
>
|
>
|
||||||
全部{props.text}
|
全部{props.text}
|
||||||
</div>
|
</div>
|
||||||
<Tree
|
{treeData.length > 0 && (
|
||||||
selectedKeys={selectKey}
|
<Tree
|
||||||
onSelect={onSelect}
|
selectedKeys={selectKey}
|
||||||
onExpand={onExpand}
|
onSelect={onSelect}
|
||||||
treeData={treeData}
|
onExpand={onExpand}
|
||||||
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
treeData={treeData}
|
||||||
/>
|
defaultExpandAll={true}
|
||||||
|
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -36,6 +36,7 @@ interface ImageItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface PropsInterface {
|
interface PropsInterface {
|
||||||
|
text: any;
|
||||||
onSelected: (url: string) => void;
|
onSelected: (url: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +72,10 @@ export const UploadImageButton = (props: PropsInterface) => {
|
|||||||
|
|
||||||
// 加载图片列表
|
// 加载图片列表
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getImageList();
|
if (showModal) {
|
||||||
}, [category_ids, refresh, page, size]);
|
getImageList();
|
||||||
|
}
|
||||||
|
}, [category_ids, refresh, page, size, showModal]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -81,7 +84,7 @@ export const UploadImageButton = (props: PropsInterface) => {
|
|||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
上传图片
|
{props.text ? props.text : "上传图片"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{showModal && (
|
{showModal && (
|
||||||
|
@ -12,10 +12,10 @@ import {
|
|||||||
TreeSelect,
|
TreeSelect,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import styles from "./create.module.less";
|
import styles from "./create.module.less";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import { course, department } from "../../../api/index";
|
import { course, department } from "../../../api/index";
|
||||||
import { UploadImageButton, SelectResource } from "../../../compenents";
|
import { UploadImageButton, SelectResource } from "../../../compenents";
|
||||||
import { ExclamationCircleFilled } from "@ant-design/icons";
|
import { ExclamationCircleFilled } from "@ant-design/icons";
|
||||||
import { getHost } from "../../../utils/index";
|
|
||||||
import { TreeHours } from "./hours";
|
import { TreeHours } from "./hours";
|
||||||
|
|
||||||
const { confirm } = Modal;
|
const { confirm } = Modal;
|
||||||
@ -40,9 +40,12 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const defaultThumb1 = getHost() + "thumb/thumb1.png";
|
const courseDefaultThumbs = useSelector(
|
||||||
const defaultThumb2 = getHost() + "thumb/thumb2.png";
|
(state: any) => state.systemConfig.value.courseDefaultThumbs
|
||||||
const defaultThumb3 = getHost() + "thumb/thumb3.png";
|
);
|
||||||
|
const defaultThumb1 = courseDefaultThumbs[0];
|
||||||
|
const defaultThumb2 = courseDefaultThumbs[1];
|
||||||
|
const defaultThumb3 = courseDefaultThumbs[2];
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [departments, setDepartments] = useState<any>([]);
|
const [departments, setDepartments] = useState<any>([]);
|
||||||
const [categories, setCategories] = useState<any>([]);
|
const [categories, setCategories] = useState<any>([]);
|
||||||
@ -82,8 +85,9 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
const getParams = () => {
|
const getParams = () => {
|
||||||
department.departmentList().then((res: any) => {
|
department.departmentList().then((res: any) => {
|
||||||
const departments = res.data.departments;
|
const departments = res.data.departments;
|
||||||
|
const departCount = res.data.dep_user_count;
|
||||||
if (JSON.stringify(departments) !== "{}") {
|
if (JSON.stringify(departments) !== "{}") {
|
||||||
const new_arr: Option[] = checkArr(departments, 0);
|
const new_arr: any = checkArr(departments, 0, departCount);
|
||||||
setDepartments(new_arr);
|
setDepartments(new_arr);
|
||||||
}
|
}
|
||||||
let type = "open";
|
let type = "open";
|
||||||
@ -131,7 +135,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
course.createCourse().then((res: any) => {
|
course.createCourse().then((res: any) => {
|
||||||
const categories = res.data.categories;
|
const categories = res.data.categories;
|
||||||
if (JSON.stringify(categories) !== "{}") {
|
if (JSON.stringify(categories) !== "{}") {
|
||||||
const new_arr: Option[] = checkArr(categories, 0);
|
const new_arr: any = checkArr(categories, 0, null);
|
||||||
setCategories(new_arr);
|
setCategories(new_arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,18 +164,39 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkArr = (departments: any[], id: number) => {
|
const getNewTitle = (title: any, id: number, counts: any) => {
|
||||||
|
if (counts) {
|
||||||
|
let value = counts[id] || 0;
|
||||||
|
return title + "(" + value + ")";
|
||||||
|
} else {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkArr = (departments: any[], id: number, counts: any) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let i = 0; i < departments[id].length; i++) {
|
for (let i = 0; i < departments[id].length; i++) {
|
||||||
if (!departments[departments[id][i].id]) {
|
if (!departments[departments[id][i].id]) {
|
||||||
arr.push({
|
arr.push({
|
||||||
title: departments[id][i].name,
|
title: getNewTitle(
|
||||||
|
departments[id][i].name,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
),
|
||||||
value: departments[id][i].id,
|
value: departments[id][i].id,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const new_arr: Option[] = checkArr(departments, departments[id][i].id);
|
const new_arr: any = checkArr(
|
||||||
|
departments,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
);
|
||||||
arr.push({
|
arr.push({
|
||||||
title: departments[id][i].name,
|
title: getNewTitle(
|
||||||
|
departments[id][i].name,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
),
|
||||||
value: departments[id][i].id,
|
value: departments[id][i].id,
|
||||||
children: new_arr,
|
children: new_arr,
|
||||||
});
|
});
|
||||||
@ -434,6 +459,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
style={{ width: 424 }}
|
style={{ width: 424 }}
|
||||||
treeData={categories}
|
treeData={categories}
|
||||||
placeholder="请选择课程分类"
|
placeholder="请选择课程分类"
|
||||||
|
treeDefaultExpandAll
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@ -486,6 +512,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
treeData={departments}
|
treeData={departments}
|
||||||
multiple
|
multiple
|
||||||
allowClear
|
allowClear
|
||||||
|
treeDefaultExpandAll
|
||||||
placeholder="请选择部门"
|
placeholder="请选择部门"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -572,6 +599,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换封面"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setThumb(url);
|
setThumb(url);
|
||||||
form.setFieldsValue({ thumb: url });
|
form.setFieldsValue({ thumb: url });
|
||||||
|
@ -12,9 +12,9 @@ import {
|
|||||||
Image,
|
Image,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import styles from "./update.module.less";
|
import styles from "./update.module.less";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import { course, department } from "../../../api/index";
|
import { course, department } from "../../../api/index";
|
||||||
import { UploadImageButton } from "../../../compenents";
|
import { UploadImageButton } from "../../../compenents";
|
||||||
import { getHost } from "../../../utils/index";
|
|
||||||
|
|
||||||
const { confirm } = Modal;
|
const { confirm } = Modal;
|
||||||
|
|
||||||
@ -36,9 +36,12 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const defaultThumb1 = getHost() + "thumb/thumb1.png";
|
const courseDefaultThumbs = useSelector(
|
||||||
const defaultThumb2 = getHost() + "thumb/thumb2.png";
|
(state: any) => state.systemConfig.value.courseDefaultThumbs
|
||||||
const defaultThumb3 = getHost() + "thumb/thumb3.png";
|
);
|
||||||
|
const defaultThumb1 = courseDefaultThumbs[0];
|
||||||
|
const defaultThumb2 = courseDefaultThumbs[1];
|
||||||
|
const defaultThumb3 = courseDefaultThumbs[2];
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [departments, setDepartments] = useState<any>([]);
|
const [departments, setDepartments] = useState<any>([]);
|
||||||
const [categories, setCategories] = useState<any>([]);
|
const [categories, setCategories] = useState<any>([]);
|
||||||
@ -63,7 +66,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
course.createCourse().then((res: any) => {
|
course.createCourse().then((res: any) => {
|
||||||
const categories = res.data.categories;
|
const categories = res.data.categories;
|
||||||
if (JSON.stringify(categories) !== "{}") {
|
if (JSON.stringify(categories) !== "{}") {
|
||||||
const new_arr: Option[] = checkArr(categories, 0);
|
const new_arr: any = checkArr(categories, 0, null);
|
||||||
setCategories(new_arr);
|
setCategories(new_arr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -71,8 +74,9 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
const getParams = () => {
|
const getParams = () => {
|
||||||
department.departmentList().then((res: any) => {
|
department.departmentList().then((res: any) => {
|
||||||
const departments = res.data.departments;
|
const departments = res.data.departments;
|
||||||
|
const departCount = res.data.dep_user_count;
|
||||||
if (JSON.stringify(departments) !== "{}") {
|
if (JSON.stringify(departments) !== "{}") {
|
||||||
const new_arr: Option[] = checkArr(departments, 0);
|
const new_arr: any = checkArr(departments, 0, departCount);
|
||||||
setDepartments(new_arr);
|
setDepartments(new_arr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -98,18 +102,39 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkArr = (departments: any[], id: number) => {
|
const getNewTitle = (title: any, id: number, counts: any) => {
|
||||||
|
if (counts) {
|
||||||
|
let value = counts[id] || 0;
|
||||||
|
return title + "(" + value + ")";
|
||||||
|
} else {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkArr = (departments: any[], id: number, counts: any) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let i = 0; i < departments[id].length; i++) {
|
for (let i = 0; i < departments[id].length; i++) {
|
||||||
if (!departments[departments[id][i].id]) {
|
if (!departments[departments[id][i].id]) {
|
||||||
arr.push({
|
arr.push({
|
||||||
title: departments[id][i].name,
|
title: getNewTitle(
|
||||||
|
departments[id][i].name,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
),
|
||||||
value: departments[id][i].id,
|
value: departments[id][i].id,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const new_arr: Option[] = checkArr(departments, departments[id][i].id);
|
const new_arr: any = checkArr(
|
||||||
|
departments,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
);
|
||||||
arr.push({
|
arr.push({
|
||||||
title: departments[id][i].name,
|
title: getNewTitle(
|
||||||
|
departments[id][i].name,
|
||||||
|
departments[id][i].id,
|
||||||
|
counts
|
||||||
|
),
|
||||||
value: departments[id][i].id,
|
value: departments[id][i].id,
|
||||||
children: new_arr,
|
children: new_arr,
|
||||||
});
|
});
|
||||||
@ -190,6 +215,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
style={{ width: 424 }}
|
style={{ width: 424 }}
|
||||||
treeData={categories}
|
treeData={categories}
|
||||||
placeholder="请选择课程分类"
|
placeholder="请选择课程分类"
|
||||||
|
treeDefaultExpandAll
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@ -242,6 +268,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
treeData={departments}
|
treeData={departments}
|
||||||
multiple
|
multiple
|
||||||
allowClear
|
allowClear
|
||||||
|
treeDefaultExpandAll
|
||||||
placeholder="请选择部门"
|
placeholder="请选择部门"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -328,6 +355,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换封面"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setThumb(url);
|
setThumb(url);
|
||||||
form.setFieldsValue({ thumb: url });
|
form.setFieldsValue({ thumb: url });
|
||||||
|
@ -181,7 +181,7 @@ const DashboardPage = () => {
|
|||||||
<div className={styles["num"]}>{basicData.user_total}</div>
|
<div className={styles["num"]}>{basicData.user_total}</div>
|
||||||
<div className={styles["compare"]}>
|
<div className={styles["compare"]}>
|
||||||
<span className="mr-5">较昨日</span>
|
<span className="mr-5">较昨日</span>
|
||||||
{compareNum(basicData.user_today, basicData.user_yesterday)}
|
{compareNum(basicData.user_today, 0)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -515,7 +515,11 @@ const DashboardPage = () => {
|
|||||||
<div className={styles["large-title"]}>产品文档</div>
|
<div className={styles["large-title"]}>产品文档</div>
|
||||||
<div className={styles["usage-guide"]}>
|
<div className={styles["usage-guide"]}>
|
||||||
<img className={styles["banner"]} src={banner} alt="" />
|
<img className={styles["banner"]} src={banner} alt="" />
|
||||||
<Link to="https://www.playedu.xyz/" className={styles["link"]}>
|
<Link
|
||||||
|
to="https://www.playedu.xyz/docs/docs/intro/"
|
||||||
|
target="blank"
|
||||||
|
className={styles["link"]}
|
||||||
|
>
|
||||||
点击查看产品文档,快速玩转Playedu!
|
点击查看产品文档,快速玩转Playedu!
|
||||||
<img className={styles["icon"]} src={icon} alt="" />
|
<img className={styles["icon"]} src={icon} alt="" />
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -364,15 +364,18 @@ const DepartmentPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="playedu-main-body">
|
<div className="playedu-main-body">
|
||||||
<div style={{ width: 366 }}>
|
<div style={{ width: 366 }}>
|
||||||
<Tree
|
{treeData.length > 0 && (
|
||||||
onSelect={onSelect}
|
<Tree
|
||||||
treeData={treeData}
|
onSelect={onSelect}
|
||||||
draggable
|
treeData={treeData}
|
||||||
blockNode
|
draggable
|
||||||
onDragEnter={onDragEnter}
|
blockNode
|
||||||
onDrop={onDrop}
|
onDragEnter={onDragEnter}
|
||||||
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
onDrop={onDrop}
|
||||||
/>
|
defaultExpandAll={true}
|
||||||
|
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DepartmentCreate
|
<DepartmentCreate
|
||||||
open={createVisible}
|
open={createVisible}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import { loginAction } from "../../store/user/loginUserSlice";
|
import { loginAction } from "../../store/user/loginUserSlice";
|
||||||
|
import {
|
||||||
|
SystemConfigStoreInterface,
|
||||||
|
saveConfigAction,
|
||||||
|
} from "../../store/system/systemConfigSlice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
loginData: any | null;
|
loginData?: any;
|
||||||
|
configData?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InitPage = (props: Props) => {
|
const InitPage = (props: Props) => {
|
||||||
@ -12,6 +17,19 @@ const InitPage = (props: Props) => {
|
|||||||
dispatch(loginAction(props.loginData));
|
dispatch(loginAction(props.loginData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.configData) {
|
||||||
|
let config: SystemConfigStoreInterface = {
|
||||||
|
systemName: props.configData["system.name"],
|
||||||
|
systemLogo: props.configData["system.logo"],
|
||||||
|
systemApiUrl: props.configData["system.api_url"],
|
||||||
|
systemPcUrl: props.configData["system.pc_url"],
|
||||||
|
systemH5Url: props.configData["system.h5_url"],
|
||||||
|
memberDefaultAvatar: props.configData["member.default_avatar"],
|
||||||
|
courseDefaultThumbs: props.configData["default.course_thumbs"],
|
||||||
|
};
|
||||||
|
dispatch(saveConfigAction(config));
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { Spin, Input, Button, message } from "antd";
|
import { Spin, Input, Button, message } from "antd";
|
||||||
import { login, system } from "../../api/index";
|
import { login as loginApi, system } from "../../api/index";
|
||||||
import { setToken } from "../../utils/index";
|
import { setToken } from "../../utils/index";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
@ -9,6 +9,10 @@ import banner from "../../assets/images/login/banner.png";
|
|||||||
import icon from "../../assets/images/login/icon.png";
|
import icon from "../../assets/images/login/icon.png";
|
||||||
import "./login.less";
|
import "./login.less";
|
||||||
import { loginAction } from "../../store/user/loginUserSlice";
|
import { loginAction } from "../../store/user/loginUserSlice";
|
||||||
|
import {
|
||||||
|
SystemConfigStoreInterface,
|
||||||
|
saveConfigAction,
|
||||||
|
} from "../../store/system/systemConfigSlice";
|
||||||
|
|
||||||
const LoginPage = () => {
|
const LoginPage = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -22,6 +26,7 @@ const LoginPage = () => {
|
|||||||
const [captchaLoading, setCaptchaLoading] = useState(true);
|
const [captchaLoading, setCaptchaLoading] = useState(true);
|
||||||
|
|
||||||
const fetchImageCaptcha = () => {
|
const fetchImageCaptcha = () => {
|
||||||
|
setCaptchaVal("");
|
||||||
setCaptchaLoading(true);
|
setCaptchaLoading(true);
|
||||||
system.getImageCaptcha().then((res: any) => {
|
system.getImageCaptcha().then((res: any) => {
|
||||||
setImage(res.data.image);
|
setImage(res.data.image);
|
||||||
@ -30,7 +35,7 @@ const LoginPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const loginSubmit = (e: any) => {
|
const loginSubmit = async () => {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
message.error("请输入管理员邮箱账号");
|
message.error("请输入管理员邮箱账号");
|
||||||
return;
|
return;
|
||||||
@ -43,43 +48,60 @@ const LoginPage = () => {
|
|||||||
message.error("请输入图形验证码");
|
message.error("请输入图形验证码");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (loading) {
|
if (captchaVal.length !== 4) {
|
||||||
|
message.error("图形验证码错误");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleSubmit();
|
await handleSubmit();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = async () => {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
login
|
try {
|
||||||
.login(email, password, captchaKey, captchaVal)
|
let res: any = await loginApi.login(
|
||||||
.then((res: any) => {
|
email,
|
||||||
const token = res.data.token;
|
password,
|
||||||
setToken(token);
|
captchaKey,
|
||||||
getUser();
|
captchaVal
|
||||||
})
|
);
|
||||||
.catch((e) => {
|
setToken(res.data.token); //将token写入本地
|
||||||
setLoading(false);
|
await getSystemConfig(); //获取系统配置并写入store
|
||||||
setCaptchaVal("");
|
await getUser(); //获取登录用户的信息并写入store
|
||||||
fetchImageCaptcha();
|
|
||||||
});
|
navigate("/");
|
||||||
|
} catch (e) {
|
||||||
|
message.error("登录出现错误");
|
||||||
|
console.error("错误信息", e);
|
||||||
|
setLoading(false);
|
||||||
|
fetchImageCaptcha(); //刷新图形验证码
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUser = () => {
|
const getUser = async () => {
|
||||||
login.getUser().then((res: any) => {
|
let res: any = await loginApi.getUser();
|
||||||
const data = res.data;
|
dispatch(loginAction(res.data));
|
||||||
dispatch(loginAction(data));
|
};
|
||||||
setLoading(false);
|
|
||||||
navigate("/");
|
const getSystemConfig = async () => {
|
||||||
});
|
let res: any = await system.getSystemConfig();
|
||||||
|
let data: SystemConfigStoreInterface = {
|
||||||
|
systemName: res.data["system.name"],
|
||||||
|
systemLogo: res.data["system.logo"],
|
||||||
|
systemApiUrl: res.data["system.api_url"],
|
||||||
|
systemPcUrl: res.data["system.pc_url"],
|
||||||
|
systemH5Url: res.data["system.h5_url"],
|
||||||
|
memberDefaultAvatar: res.data["member.default_avatar"],
|
||||||
|
courseDefaultThumbs: res.data["default.course_thumbs"],
|
||||||
|
};
|
||||||
|
dispatch(saveConfigAction(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
const keyUp = (e: any) => {
|
const keyUp = (e: any) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
loginSubmit(e);
|
loginSubmit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Modal, Form, TreeSelect, Input, message } from "antd";
|
import { Modal, Form, TreeSelect, Input, message } from "antd";
|
||||||
import styles from "./create.module.less";
|
import styles from "./create.module.less";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import { user, department } from "../../../api/index";
|
import { user, department } from "../../../api/index";
|
||||||
import { UploadImageButton } from "../../../compenents";
|
import { UploadImageButton } from "../../../compenents";
|
||||||
import { ValidataCredentials, getHost } from "../../../utils/index";
|
import { ValidataCredentials } from "../../../utils/index";
|
||||||
|
|
||||||
interface PropInterface {
|
interface PropInterface {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -20,7 +21,10 @@ export const MemberCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [departments, setDepartments] = useState<any>([]);
|
const [departments, setDepartments] = useState<any>([]);
|
||||||
const [avatar, setAvatar] = useState<string>(getHost() + "avatar/avatar.png");
|
const memberDefaultAvatar = useSelector(
|
||||||
|
(state: any) => state.systemConfig.value.memberDefaultAvatar
|
||||||
|
);
|
||||||
|
const [avatar, setAvatar] = useState<string>(memberDefaultAvatar);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
@ -33,11 +37,11 @@ export const MemberCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
email: "",
|
email: "",
|
||||||
name: "",
|
name: "",
|
||||||
password: "",
|
password: "",
|
||||||
avatar: getHost() + "avatar/avatar.png",
|
avatar: memberDefaultAvatar,
|
||||||
idCard: "",
|
idCard: "",
|
||||||
dep_ids: [],
|
dep_ids: [],
|
||||||
});
|
});
|
||||||
setAvatar(getHost() + "avatar/avatar.png");
|
setAvatar(memberDefaultAvatar);
|
||||||
}, [form, open]);
|
}, [form, open]);
|
||||||
|
|
||||||
const getParams = () => {
|
const getParams = () => {
|
||||||
@ -129,6 +133,7 @@ export const MemberCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
)}
|
)}
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换头像"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setAvatar(url);
|
setAvatar(url);
|
||||||
form.setFieldsValue({ avatar: url });
|
form.setFieldsValue({ avatar: url });
|
||||||
@ -172,6 +177,7 @@ export const MemberCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
treeData={departments}
|
treeData={departments}
|
||||||
multiple
|
multiple
|
||||||
allowClear
|
allowClear
|
||||||
|
treeDefaultExpandAll
|
||||||
placeholder="请选择学员所属部门"
|
placeholder="请选择学员所属部门"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Modal, Form, TreeSelect, Input, message } from "antd";
|
import { Modal, Form, TreeSelect, Input, message } from "antd";
|
||||||
import styles from "./create.module.less";
|
import styles from "./update.module.less";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import { user, department } from "../../../api/index";
|
import { user, department } from "../../../api/index";
|
||||||
import { UploadImageButton } from "../../../compenents";
|
import { UploadImageButton } from "../../../compenents";
|
||||||
import { ValidataCredentials, getHost } from "../../../utils/index";
|
import { ValidataCredentials } from "../../../utils/index";
|
||||||
|
|
||||||
interface PropInterface {
|
interface PropInterface {
|
||||||
id: number;
|
id: number;
|
||||||
@ -25,7 +26,10 @@ export const MemberUpdate: React.FC<PropInterface> = ({
|
|||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [departments, setDepartments] = useState<any>([]);
|
const [departments, setDepartments] = useState<any>([]);
|
||||||
const [avatar, setAvatar] = useState<string>(getHost() + "avatar/avatar.png");
|
const memberDefaultAvatar = useSelector(
|
||||||
|
(state: any) => state.systemConfig.value.memberDefaultAvatar
|
||||||
|
);
|
||||||
|
const [avatar, setAvatar] = useState<string>(memberDefaultAvatar);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
@ -163,6 +167,7 @@ export const MemberUpdate: React.FC<PropInterface> = ({
|
|||||||
)}
|
)}
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换头像"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setAvatar(url);
|
setAvatar(url);
|
||||||
form.setFieldsValue({ avatar: url });
|
form.setFieldsValue({ avatar: url });
|
||||||
@ -202,6 +207,7 @@ export const MemberUpdate: React.FC<PropInterface> = ({
|
|||||||
treeData={departments}
|
treeData={departments}
|
||||||
multiple
|
multiple
|
||||||
allowClear
|
allowClear
|
||||||
|
treeDefaultExpandAll
|
||||||
placeholder="请选择学员所属部门"
|
placeholder="请选择学员所属部门"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -372,15 +372,18 @@ const ResourceCategoryPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="playedu-main-body">
|
<div className="playedu-main-body">
|
||||||
<div style={{ width: 366 }}>
|
<div style={{ width: 366 }}>
|
||||||
<Tree
|
{treeData.length > 0 && (
|
||||||
onSelect={onSelect}
|
<Tree
|
||||||
treeData={treeData}
|
onSelect={onSelect}
|
||||||
draggable
|
treeData={treeData}
|
||||||
blockNode
|
draggable
|
||||||
onDragEnter={onDragEnter}
|
blockNode
|
||||||
onDrop={onDrop}
|
onDragEnter={onDragEnter}
|
||||||
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
onDrop={onDrop}
|
||||||
/>
|
defaultExpandAll={true}
|
||||||
|
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ResourceCategoryCreate
|
<ResourceCategoryCreate
|
||||||
open={createVisible}
|
open={createVisible}
|
||||||
|
@ -30,7 +30,9 @@ export const SystemAdministratorUpdate: React.FC<PropInterface> = ({
|
|||||||
if (id === 0) {
|
if (id === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getDetail();
|
if (open) {
|
||||||
|
getDetail();
|
||||||
|
}
|
||||||
}, [id, open]);
|
}, [id, open]);
|
||||||
|
|
||||||
const getParams = () => {
|
const getParams = () => {
|
||||||
|
@ -35,7 +35,9 @@ export const SystemAdminrolesUpdate: React.FC<PropInterface> = ({
|
|||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getDetail();
|
if (open) {
|
||||||
|
getDetail();
|
||||||
|
}
|
||||||
}, [id, open]);
|
}, [id, open]);
|
||||||
|
|
||||||
const getParams = () => {
|
const getParams = () => {
|
||||||
|
@ -198,6 +198,7 @@ const SystemConfigPage = () => {
|
|||||||
<Image preview={false} height={40} src={logo} />
|
<Image preview={false} height={40} src={logo} />
|
||||||
<div className="d-flex ml-24">
|
<div className="d-flex ml-24">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换Logo"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setLogo(url);
|
setLogo(url);
|
||||||
form.setFieldsValue({ "system.logo": url });
|
form.setFieldsValue({ "system.logo": url });
|
||||||
@ -219,6 +220,7 @@ const SystemConfigPage = () => {
|
|||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<div className="d-flex ml-24">
|
<div className="d-flex ml-24">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换Logo"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setLogo(url);
|
setLogo(url);
|
||||||
form.setFieldsValue({ "system.logo": url });
|
form.setFieldsValue({ "system.logo": url });
|
||||||
@ -363,6 +365,7 @@ const SystemConfigPage = () => {
|
|||||||
/>
|
/>
|
||||||
<div className="d-flex ml-24">
|
<div className="d-flex ml-24">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换封面"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setThumb(url);
|
setThumb(url);
|
||||||
form.setFieldsValue({ "player.poster": url });
|
form.setFieldsValue({ "player.poster": url });
|
||||||
@ -384,6 +387,7 @@ const SystemConfigPage = () => {
|
|||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
<UploadImageButton
|
<UploadImageButton
|
||||||
|
text="更换封面"
|
||||||
onSelected={(url) => {
|
onSelected={(url) => {
|
||||||
setThumb(url);
|
setThumb(url);
|
||||||
form.setFieldsValue({ "player.poster": url });
|
form.setFieldsValue({ "player.poster": url });
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { lazy } from "react";
|
import { lazy } from "react";
|
||||||
import { RouteObject } from "react-router-dom";
|
import { RouteObject } from "react-router-dom";
|
||||||
import { login } from "../api";
|
import { login, system } from "../api";
|
||||||
|
|
||||||
import InitPage from "../pages/init";
|
import InitPage from "../pages/init";
|
||||||
import { getToken } from "../utils";
|
import { getToken } from "../utils";
|
||||||
@ -23,52 +23,34 @@ import DepartmentPage from "../pages/department";
|
|||||||
import TestPage from "../pages/test";
|
import TestPage from "../pages/test";
|
||||||
import ErrorPage from "../pages/error";
|
import ErrorPage from "../pages/error";
|
||||||
|
|
||||||
// 异步加载页面
|
|
||||||
// const LoginPage = lazy(() => import("../pages/login"));
|
// const LoginPage = lazy(() => import("../pages/login"));
|
||||||
// const HomePage = lazy(() => import("../pages/home"));
|
|
||||||
// const DashboardPage = lazy(() => import("../pages/dashboard"));
|
|
||||||
// const ErrorPage = lazy(() => import("../pages/error"));
|
|
||||||
// const CoursePage = lazy(() => import("../pages/course"));
|
|
||||||
// const TestPage = lazy(() => import("../pages/test"));
|
|
||||||
// const MemberPage = lazy(() => import("../pages/member"));
|
|
||||||
// const MemberImportPage = lazy(() => import("../pages/member/import"));
|
|
||||||
// const SystemAdministratorPage = lazy(
|
|
||||||
// () => import("../pages/system/administrator")
|
|
||||||
// );
|
|
||||||
// const SystemAdminrolesPage = lazy(() => import("../pages/system/adminroles"));
|
|
||||||
// const DepartmentPage = lazy(() => import("../pages/department"));
|
|
||||||
// const ChangePasswordPage = lazy(() => import("../pages/change-password"));
|
|
||||||
// const ResourceImagesPage = lazy(() => import("../pages/resource/images"));
|
|
||||||
// const ResourceCategoryPage = lazy(
|
|
||||||
// () => import("../pages/resource/resource-category")
|
|
||||||
// );
|
|
||||||
// const ResourceVideosPage = lazy(() => import("../pages/resource/videos"));
|
|
||||||
// const SystemConfigPage = lazy(() => import("../pages/system/config"));
|
|
||||||
|
|
||||||
let RootPage: any = null;
|
let RootPage: any = null;
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
RootPage = lazy(async () => {
|
RootPage = lazy(async () => {
|
||||||
return new Promise<any>((resolve) => {
|
return new Promise<any>(async (resolve) => {
|
||||||
let userLoginToken = getToken();
|
try {
|
||||||
if (!userLoginToken) {
|
let configRes: any = await system.getSystemConfig();
|
||||||
|
let userRes: any = await login.getUser();
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
default: InitPage,
|
default: (
|
||||||
|
<InitPage configData={configRes.data} loginData={userRes.data} />
|
||||||
|
),
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error("系统初始化失败", e);
|
||||||
|
resolve({
|
||||||
|
default: <ErrorPage />,
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
login.getUser().then((res: any) => {
|
|
||||||
resolve({
|
|
||||||
default: <InitPage loginData={res.data} />,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// todo token过期处理
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (window.location.pathname !== "/login") {
|
if (window.location.pathname !== "/login") {
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
}
|
}
|
||||||
RootPage = <InitPage loginData={null} />;
|
RootPage = <InitPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes: RouteObject[] = [
|
const routes: RouteObject[] = [
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
import { createSlice } from "@reduxjs/toolkit";
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
type SystemConfigStoreInterface = {
|
type SystemConfigStoreInterface = {
|
||||||
systemApiUrl: string;
|
systemApiUrl?: string;
|
||||||
systemPcUrl: string;
|
systemPcUrl?: string;
|
||||||
systemH5Url: string;
|
systemH5Url?: string;
|
||||||
systemLogo: string;
|
systemLogo?: string;
|
||||||
systemName: string;
|
systemName?: string;
|
||||||
};
|
memberDefaultAvatar?: string;
|
||||||
|
courseDefaultThumbs?: string[];
|
||||||
let defaultValue: SystemConfigStoreInterface = {
|
|
||||||
systemApiUrl: "",
|
|
||||||
systemPcUrl: "",
|
|
||||||
systemH5Url: "",
|
|
||||||
systemLogo: "",
|
|
||||||
systemName: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const systemConfigSlice = createSlice({
|
const systemConfigSlice = createSlice({
|
||||||
name: "systemConfig",
|
name: "systemConfig",
|
||||||
initialState: {
|
initialState: {
|
||||||
value: defaultValue,
|
value: {},
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
saveConfigAction(stage, e) {
|
saveConfigAction(stage, e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user