({
compiledCode: "",
+ error: false,
sourceCode: "",
id: "",
imageAddress: "",
compileTime: "",
compileInformation: ""
});
- const [historyPageState,setHistoryPageState] = useState(false);
+ const [historyPageState, setHistoryPageState] = useState(false);
const navigate = useNavigate(); // 跳转hook
useEffect(() => {
@@ -32,6 +33,7 @@ export function Index() {
setInputValue("");
setOutputValue({
compiledCode: "",
+ error: false,
sourceCode: "",
id: "",
imageAddress: "pic/uncompiled.png",
@@ -41,14 +43,14 @@ export function Index() {
return;
}
const getCompileInstance = async () => {
- const {data} = await client.GET("/api/Compiler/{compileId}", {
+ const { data } = await client.GET("/api/Compiler/{compileId}", {
params:
+ {
+ path:
{
- path:
- {
- compileId: path
- }
+ compileId: path
}
+ }
})
if (data !== undefined) {
setInputValue(data.sourceCode);
@@ -66,21 +68,24 @@ export function Index() {
async function compilerButtonClick() {
- const {data} = await client.POST("/api/Compiler", {
+ const { data } = await client.POST("/api/Compiler", {
body: {
code: inputValue
}
- })
+ });
- if (data !== undefined) {
- setOutputValue(data);
- enqueueSnackbar("编译成功", {variant: "success", anchorOrigin: {vertical: 'bottom', horizontal: 'right'}});
- navigate(`/${data.id}`, {})
+ if (data == undefined) {
+ enqueueSnackbar("内部错误", { variant: "error", anchorOrigin: { vertical: 'bottom', horizontal: 'right' } });
+ return;
+ }
+ if (!data.error) {
+ enqueueSnackbar("编译成功", { variant: "success", anchorOrigin: { vertical: 'bottom', horizontal: 'right' } });
} else {
// error
- enqueueSnackbar("编译失败", {variant: "error", anchorOrigin: {vertical: 'bottom', horizontal: 'right'}});
+ enqueueSnackbar("编译失败", { variant: "error", anchorOrigin: { vertical: 'bottom', horizontal: 'right' } });
}
+ navigate(`/${data.id}`, {})
}
function historyButtonClick() {
@@ -89,9 +94,9 @@ export function Index() {
return <>
-
-
+ style={titleClassCss}>
+
+
Canon
@@ -101,9 +106,9 @@ export function Index() {
transform: "translateX(-50%)",
fontSize: "medium",
}}
- variant="outlined"
- color="inherit"
- onClick={compilerButtonClick}
+ variant="outlined"
+ color="inherit"
+ onClick={compilerButtonClick}
>
编译
@@ -113,29 +118,29 @@ export function Index() {
right: "10%",
fontSize: "medium",
}}
- variant="text"
- color="inherit"
- onClick={historyButtonClick}>
- 历史记录
+ variant="text"
+ color="inherit"
+ onClick={historyButtonClick}>
+ 历史记录
-
-
+ style={contentClassCss}>
+
+
-
+
-
+
>
diff --git a/Canon.Server/client-app/src/openapi.d.ts b/Canon.Server/client-app/src/openapi.d.ts
index a8fa80b..972094d 100644
--- a/Canon.Server/client-app/src/openapi.d.ts
+++ b/Canon.Server/client-app/src/openapi.d.ts
@@ -115,6 +115,7 @@ export interface components {
schemas: {
CompileResponse: {
id: string;
+ error: boolean;
sourceCode: string;
compiledCode: string;
imageAddress: string;