This commit is contained in:
Rizky 2024-02-27 19:36:33 +07:00
parent 05cba735cb
commit fcf953b478
5 changed files with 33 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -82,7 +82,7 @@ export const fetchViaProxy = async (
);
const raw = await res.text();
try {
return JSON.parse(raw);
return JSON.parse(raw, replacer);
} catch (e) {
return raw;
}
@ -91,3 +91,10 @@ export const fetchViaProxy = async (
}
return null;
};
const replacer = (key: string, value: string) => {
if (typeof value === "string" && value.startsWith("BigInt::")) {
return BigInt(value.substring(8));
}
return value;
};

View File

@ -64,7 +64,7 @@ export const EdMid: FC<{}> = () => {
<div className=" text-slate-400 flex items-center pr-1 ">
<ResponsiveToggle />
</div>
<a href={`/vi/${params.site_id}/${params.page_id}`} target="_blank">
<a href={`/prod/${params.site_id}/${params.page_id}`} target="_blank">
<TopBtn style="slim" className="font-mono text-[9px]">
PREVIEW
</TopBtn>

View File

@ -20,7 +20,6 @@ export const EdFileBrowser = () => {
(async () => {
if (!p.script.api && p.site.config?.api_url) {
p.script.api = apiProxy(p.site.config.api_url);
await waitUntil(() => w.prasiApi[p.site.config.api_url]);
p.render();
}

View File

@ -40,6 +40,9 @@ export const viLoadSnapshot = async (p: PG) => {
});
}
}
if (!p.script.db) p.script.db = dbProxy(api_url);
if (!p.script.api) p.script.api = apiProxy(api_url);
}
} catch (e) {
console.warn("Failed to load API:", api_url);