feat: 编译历史记录和代码生成结果(#51)
地址已绑定编译结果,支持历史记录切换功能 Co-authored-by: jackfiled <xcrenchangjun@outlook.com> Reviewed-on: PostGuard/Canon#51 Co-authored-by: Ichirinko <1621543655@qq.com> Co-committed-by: Ichirinko <1621543655@qq.com>
This commit is contained in:
26
Canon.Server/client-app/src/Pages/Loader.tsx
Normal file
26
Canon.Server/client-app/src/Pages/Loader.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import {redirect} from "react-router-dom";
|
||||
import createClient from "openapi-fetch";
|
||||
import * as openapi from "../openapi";
|
||||
|
||||
export async function loader() {
|
||||
const client = createClient<openapi.paths>();
|
||||
const compileId = location.pathname.substring(1);
|
||||
console.log("hello")
|
||||
|
||||
const compileInstance = await client.GET("/api/Compiler/{compileId}", {
|
||||
params:
|
||||
{
|
||||
path:
|
||||
{
|
||||
compileId: compileId
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (compileInstance.response.status !== 200) {
|
||||
// 不存在的id
|
||||
console.log("redirect")
|
||||
return redirect("/");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user