fix
This commit is contained in:
parent
fab8bb24b5
commit
706048c882
|
|
@ -15,7 +15,6 @@ export const _ = {
|
|||
|
||||
let is_msgpack = req.query_parameters["msgpack"];
|
||||
|
||||
console.log(is_msgpack);
|
||||
if (validate(site_id)) {
|
||||
const mode = is_msgpack ? "binary" : "string";
|
||||
const result = {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -2,8 +2,19 @@ import { get } from "idb-keyval";
|
|||
import { IRoot } from "../../../utils/types/root";
|
||||
import { base } from "./base";
|
||||
|
||||
const pendingPage = {} as Record<
|
||||
string,
|
||||
Promise<{
|
||||
id: string;
|
||||
url: string;
|
||||
root: IRoot;
|
||||
}>
|
||||
>;
|
||||
|
||||
export const loadPage = (page_id: string) => {
|
||||
return new Promise<{
|
||||
if (typeof pendingPage[page_id] === "object") return pendingPage[page_id];
|
||||
|
||||
pendingPage[page_id] = new Promise<{
|
||||
id: string;
|
||||
url: string;
|
||||
root: IRoot;
|
||||
|
|
@ -22,10 +33,18 @@ export const loadPage = (page_id: string) => {
|
|||
id: string;
|
||||
url: string;
|
||||
root: IRoot;
|
||||
content_tree?: IRoot;
|
||||
};
|
||||
|
||||
if (!res.root && res.content_tree) {
|
||||
res.root = res.content_tree;
|
||||
delete res.content_tree;
|
||||
}
|
||||
|
||||
if (!returned) done(res);
|
||||
});
|
||||
|
||||
return pendingPage[page_id];
|
||||
};
|
||||
|
||||
export const loadPages = (page_ids: string[]) => {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ import { IMeta } from "../../vi/utils/types";
|
|||
import { base } from "./base";
|
||||
import { scanComponent } from "./component";
|
||||
|
||||
const cached = { route: null as any };
|
||||
const cached = { route: null as any, promise: null as any };
|
||||
|
||||
const getRoute = () => {
|
||||
return new Promise<{
|
||||
if (cached.promise) return cached.promise;
|
||||
cached.promise = new Promise<{
|
||||
site: any;
|
||||
urls: {
|
||||
id: string;
|
||||
|
|
@ -21,8 +22,7 @@ const getRoute = () => {
|
|||
if (cached.route) done(cached.route);
|
||||
|
||||
let is_done = false;
|
||||
|
||||
let res = await fetch(base.url`_prasi/route`);
|
||||
const res = await fetch(base.url`_prasi/route`);
|
||||
if (!is_done) {
|
||||
if (!res.headers.get("content-encoding")) {
|
||||
fetch(base.url`_prasi/compress/only-gz`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue