From b4a6632018c81ae52a21ee207a94ae381494304a Mon Sep 17 00:00:00 2001 From: ichirinko <1621543655@qq.com> Date: Thu, 25 Apr 2024 00:14:45 +0800 Subject: [PATCH] feat-frontend (#54) Reviewed-on: https://git.rrricardo.top/PostGuard/Canon/pulls/54 --- .../client-app/src/Pages/HistoryPage.tsx | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/Canon.Server/client-app/src/Pages/HistoryPage.tsx b/Canon.Server/client-app/src/Pages/HistoryPage.tsx index 2a7c8fd..0c40a37 100644 --- a/Canon.Server/client-app/src/Pages/HistoryPage.tsx +++ b/Canon.Server/client-app/src/Pages/HistoryPage.tsx @@ -1,4 +1,15 @@ -import {Box, Button, Card, CardActionArea, Drawer, Stack, Typography} from "@mui/material"; +import { + Box, + Button, + Card, + CardActionArea, + Dialog, DialogActions, + DialogContent, DialogContentText, + DialogTitle, + Drawer, + Stack, + Typography +} from "@mui/material"; import createClient from "openapi-fetch"; import * as openapi from "../openapi"; import {useEffect, useState} from "react"; @@ -12,6 +23,7 @@ const client = createClient(); // @ts-expect-error ... export function HistoryPage({state, setState}) { const [data, setData] = useState([]); + const [deleteDialog, setDeleteDialog] = useState(false); const navigate = useNavigate(); useEffect(() => { @@ -25,8 +37,7 @@ export function HistoryPage({state, setState}) { } } }).then((response) => { - if (response !== undefined) { - // @ts-expect-error ... + if (response!==undefined && response.data !== undefined) { setData(response.data) } }); @@ -42,17 +53,27 @@ export function HistoryPage({state, setState}) { const deleteHistory = async () => { await client.DELETE("/api/Compiler") .then((res) => { - if(res.response.status === 204) { - enqueueSnackbar("删除缓存成功", {variant: "success", anchorOrigin: {vertical: 'bottom', horizontal: 'right'}}); + if (res.response.status === 204) { + enqueueSnackbar("删除缓存成功", { + variant: "success", + anchorOrigin: {vertical: 'bottom', horizontal: 'right'} + }); navigate('/'); } else { - enqueueSnackbar("删除缓存失败", {variant: "error", anchorOrigin: {vertical: 'bottom', horizontal: 'right'}}); + enqueueSnackbar("删除缓存失败", { + variant: "error", + anchorOrigin: {vertical: 'bottom', horizontal: 'right'} + }); } } ); - } + const onDeleteDialogClose = () => { + setDeleteDialog(false); + }; + + return <> { - console.log(item.id) navigate(`/${item.id}`) }}> @@ -83,9 +103,39 @@ export function HistoryPage({state, setState}) { ) } - + + + {"是否清除历史记录?"} + + + + 编译历史记录将会被不可恢复地删除,请谨慎操作! + + + + + + + }