Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/app/HomeSite/ContestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ const Contest1 = () => (
<Title level={3}>精彩回顾</Title>
<Bold></Bold>
<Center direction="column">
<Image
alt="THUAI_8_cover"
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/2024/2024_THUAI_8.png`}
width={800}
/>
<P>THUAI8——西游真经劫</P>
<P></P>
<Image
alt="THUAI_7_cover"
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/2024/2024_THUAI_7.png`}
Expand Down Expand Up @@ -155,6 +162,13 @@ const Contest3 = () => (
<Title level={3}>精彩回顾</Title>
<Center direction="column">
<Bold></Bold>
<Image
alt="software_cover_2024"
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/2024/2024_software_2025.png`}
width={800}
/>
<P>2025 特等奖——ZeroDay</P>
<P></P>
<Image
alt="software_cover_2024"
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/2024/2024_software_2024.jpg`}
Expand Down
2 changes: 1 addition & 1 deletion src/app/HomeSite/DivisionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const SoftwareDepartment = () => (
<StyledTypography>
<Typography.Title level={2}>软件部</Typography.Title>
<Image
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/division-introduction-software-group-photo-2023.jpg`}
src={`${process.env.REACT_APP_STATIC_URL!}/public/images/division-introduction-software-group-photo-2024.png`}
alt="软件部集体照"
width="900"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/app/HomeSite/NewsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const news = [
{
title: "清华大学电子工程系学生科协",
content: "宽口径、厚基础,我们软硬皆通。",
image: `${process.env.REACT_APP_STATIC_URL!}/public/images/eesast-group-photo-2024.jpg`,
image: `${process.env.REACT_APP_STATIC_URL!}/public/images/eesast-group-photo-2025.jpg`,
},
// {
// title: "“商汤杯”第二十一届电子设计大赛",
Expand Down
32 changes: 16 additions & 16 deletions src/app/InfoSite/MentorChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import dayjs from "dayjs";
import Scrollbars from "react-custom-scrollbars";
import { useUrl } from "../../api/hooks/url";
import * as graphql from "@/generated/graphql";
import axios from "axios";
import { PageProps } from "..";

/*----- 不依赖于 props 和 hooks 的定义 -----*/
Expand Down Expand Up @@ -48,10 +49,9 @@ const MentorChatPage: React.FC<PageProps> = ({ mode, user }) => {
},
skip: user.role === "counselor",
});

// 发送信息 hook
const [addMessage, { loading: addMessageLoading, error: addMessageError }] =
graphql.useAddMessageMutation();
// 删除原有的addMessage相关hook定义,改用本地state
const [addMessageLoading, setAddMessageLoading] = useState(false);
const [addMessageError, setAddMessageError] = useState<any>(null);

/*----- useEffect 部分 -----*/
// 申请数据加载失败时提示
Expand Down Expand Up @@ -99,18 +99,18 @@ const MentorChatPage: React.FC<PageProps> = ({ mode, user }) => {
if (!text.trim()) {
return;
}

await addMessage({
variables: {
from_uuid: from!,
to_uuid: to!,
payload: JSON.stringify({
text: text.trim(),
}),
},
});

setText(""); //清空文本框
setAddMessageLoading(true);
setAddMessageError(null);
try {
await axios.post("/chat/send", {
receiver_id: to!,
content: JSON.stringify({ text: text.trim() }),
});
setText(""); //清空文本框
} catch (err) {
setAddMessageError(err);
}
setAddMessageLoading(false);
};

/*----- 渲染逻辑 -----*/
Expand Down
96 changes: 63 additions & 33 deletions src/app/InfoSite/NoticePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { RcFile } from "rc-upload/lib/interface";
import Markdown from "react-markdown";
import * as graphql from "@/generated/graphql";
import { PageProps } from "..";

import axios from "axios";
/*----- 不依赖于 props 和 hooks 的定义 -----*/
const { Text } = Typography;
const { confirm } = Modal;
Expand Down Expand Up @@ -80,12 +80,14 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
});

// 更新、发布、删除公告的 hooks
const [updateNotice, { loading: noticeUpdating, error: noticeUpdateError }] =
graphql.useUpdateNoticeMutation();
const [addNotice, { loading: noticeAdding, error: noticeAddError }] =
graphql.useAddNoticeMutation();
const [deleteNotice, { error: noticeDeleteError }] =
graphql.useDeleteNoticeMutation();
// const [updateNotice, { loading: noticeUpdating, error: noticeUpdateError }] =
// graphql.useUpdateNoticeMutation();
// const [addNotice, { loading: noticeAdding, error: noticeAddError }] =
// graphql.useAddNoticeMutation();
// const [deleteNotice, { error: noticeDeleteError }] =
// graphql.useDeleteNoticeMutation();
const [noticeAdding, setNoticeAdding] = useState(false);
const [noticeAddError, setNoticeAddError] = useState<any>(null);

/*----- useEffect 部分 -----*/
// 公告加载失败时提示
Expand All @@ -96,13 +98,6 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
}
}, [noticeError]);

// 公告更新失败时提示
useEffect(() => {
if (noticeUpdateError) {
message.error("公告更新失败");
}
}, [noticeUpdateError]);

// 公告发布失败时提示
useEffect(() => {
if (noticeAddError) {
Expand All @@ -111,43 +106,71 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
}, [noticeAddError]);

// 公告删除失败时提示
useEffect(() => {
/* useEffect(() => {
if (noticeDeleteError) {
message.error("公告删除失败");
}
}, [noticeDeleteError]);
}, [noticeDeleteError]);*/

/*----- 其他函数和处理逻辑 -----*/
// 处理公告编辑
const handleNoticeEdit = async () => {
try {
form.validateFields();
await form.validateFields();
const values = form.getFieldsValue();
const files = fileList.map((f) => ({
filename: f.name,
url: "/upload/" + f.name,
}));
if (editingNotice) {
await updateNotice({
// 更新公告
variables: {
setNoticeAdding(true);
setNoticeAddError(null);
// 使用 /notice/update 路由更新公告
try {
const res = await axios.post("/notice/update", {
id: editingNotice.id,
title: values.title,
content: values.content,
files: JSON.stringify(files),
notice_type: editingNotice.notice_type,
},
});
});
if (!res || res.status !== 200) {
setNoticeAddError("公告更新失败");
message.error("公告更新失败");
setNoticeAdding(false);
return;
}
} catch (err) {
setNoticeAddError(err);
message.error("公告更新失败");
setNoticeAdding(false);
return;
}
setNoticeAdding(false);
} else {
await addNotice({
// 发布公告
variables: {
setNoticeAdding(true);
setNoticeAddError(null);
// 使用 /notice/add 路由发布公告
try {
const res = await axios.post("/notice/add", {
title: values.title,
content: values.content,
files: JSON.stringify(files),
notice_type: values.type,
},
});
});
if (!res || res.status !== 200) {
setNoticeAddError("公告发布失败");
message.error("公告发布失败");
setNoticeAdding(false);
return;
}
} catch (err) {
setNoticeAddError(err);
message.error("公告发布失败");
setNoticeAdding(false);
return;
}
setNoticeAdding(false);
}
// 关闭模态框,清空表单,重载公告
setModalVisible(false);
Expand Down Expand Up @@ -187,15 +210,18 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
}));
const values = form.getFieldsValue();
if (editingNotice) {
await updateNotice({
variables: {
// 用 axios 调用 /notice/update 路由
try {
await axios.post("/notice/update", {
id: editingNotice.id,
title: values.title,
content: values.content,
files: JSON.stringify(files),
notice_type: editingNotice.notice_type,
},
});
});
} catch (err) {
message.error("公告更新失败");
}
} else throw Error("error");
if (file.response?.status === 200) {
await deleteFile("upload/" + file.name); //删除文件
Expand All @@ -213,7 +239,11 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
icon: <ExclamationCircleOutlined />,
content: "此操作不可恢复。",
onOk: async () => {
await deleteNotice({ variables: { id } });
try {
await axios.post("/notice/delete", { id });
} catch (err) {
message.error("公告删除失败");
}
await refetchNotices();
},
});
Expand Down Expand Up @@ -332,7 +362,7 @@ const NoticePage: React.FC<PageProps> = ({ mode, user }) => {
}}
onOk={handleNoticeEdit}
maskClosable={false}
confirmLoading={noticeUpdating || noticeAdding}
confirmLoading={noticeAdding}
destroyOnClose
>
<Form
Expand Down