feat: new version of website

This commit is contained in:
delong.wang
2023-08-02 13:56:10 +08:00
parent 7c8e4f2585
commit 45987efeea
102 changed files with 18519 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
export { submitSampleSet, getSampleSet, getSampleSetResult, getSampleDetail };
const BASE_API = "/api/poc/";
function submitSampleSet(data: {
pocs: Array<{ content: string; tag: string }>;
record_it: boolean;
}) {
return fetch(BASE_API + "list", {
method: "POST",
headers: { "Content-Type": "application/json" },
mode: "cors",
// credentials: "include",
body: JSON.stringify(data),
}).then((res) => res.json());
}
function getSampleSet(id: string) {
return fetch(BASE_API + "list?id=" + id).then((res) => res.json());
}
function getSampleDetail(id: string) {
return fetch(BASE_API + "detail?id=" + id).then((res) => res.json());
}
async function getSampleSetResult(id: string, timeout: number = 60) {
const startAt = new Date().getTime();
const isTimeout = () => new Date().getTime() - startAt > timeout * 1000;
const maxRetry = 20;
for (let i = 0; i < maxRetry; i++) {
const res = await fetch(BASE_API + "results?id=" + id).then((res) =>
res.json()
);
if (res.code == 0 && res.data.data) {
return { data: res.data.data, timeout: false };
}
if (isTimeout()) break;
await new Promise((r) => setTimeout(r, 2000));
}
return { data: [], timeout: true };
}

5
website/src/api/home.ts Normal file
View File

@@ -0,0 +1,5 @@
export { getSetupCount };
function getSetupCount() {
return fetch("/api/count").then((res) => res.json());
}