feat: 🎸 update portal ui

This commit is contained in:
zhangqingwu
2024-07-01 16:52:04 +08:00
committed by Lyric Wai
parent 8cc38e0e18
commit 7f1ea7e49e
8 changed files with 134 additions and 25 deletions

View File

@@ -0,0 +1,27 @@
export async function request(url: string) {
const perfix = "http-cache";
const key = `${perfix}-${url}`;
try {
const value = JSON.parse(localStorage.getItem(key) || "");
if (Number(value.expire_time) > new Date().getTime()) {
return value.data;
}
} catch (error) {
// ignore
}
const resp = await fetch(url, { method: "Get" });
const data = await resp.json();
localStorage.setItem(
key,
JSON.stringify({
expire_time: new Date().getTime() + 1000 * 60 * 60 * 24,
data,
})
);
return data;
}