wip fix
This commit is contained in:
parent
9b1976ea70
commit
5f87a3097f
|
|
@ -62,6 +62,25 @@ window._prasi={basepath: "/deploy/${site_id}",site_id:"${site_id}"}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const layouts = await _db.page.findMany({
|
||||||
|
where: {
|
||||||
|
name: { startsWith: "layout:" },
|
||||||
|
is_deleted: false,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
is_default_layout: true,
|
||||||
|
content_tree: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let layout = null as any;
|
||||||
|
for (const l of layouts) {
|
||||||
|
if (!layout) layout = l;
|
||||||
|
if (l.is_default_layout) layout = l;
|
||||||
|
}
|
||||||
|
|
||||||
let api_url = "";
|
let api_url = "";
|
||||||
if (site && site.config && (site.config as any).api_url) {
|
if (site && site.config && (site.config as any).api_url) {
|
||||||
api_url = (site.config as any).api_url;
|
api_url = (site.config as any).api_url;
|
||||||
|
|
@ -76,7 +95,13 @@ window._prasi={basepath: "/deploy/${site_id}",site_id:"${site_id}"}
|
||||||
select: { url: true, id: true },
|
select: { url: true, id: true },
|
||||||
});
|
});
|
||||||
return gzipAsync(
|
return gzipAsync(
|
||||||
JSON.stringify({ site: { ...site, api_url }, urls }) as any
|
JSON.stringify({
|
||||||
|
site: { ...site, api_url },
|
||||||
|
urls,
|
||||||
|
layout: layout
|
||||||
|
? { id: layout.id, root: layout.content_tree }
|
||||||
|
: undefined,
|
||||||
|
}) as any
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case "page": {
|
case "page": {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ export const base = {
|
||||||
list: {} as Record<string, IItem>,
|
list: {} as Record<string, IItem>,
|
||||||
pending: new Set<string>(),
|
pending: new Set<string>(),
|
||||||
},
|
},
|
||||||
|
layout: {
|
||||||
|
id: "",
|
||||||
|
root: null as null | IRoot,
|
||||||
|
meta: null as null | Record<string, IMeta>,
|
||||||
|
},
|
||||||
page: {
|
page: {
|
||||||
id: "",
|
id: "",
|
||||||
url: "",
|
url: "",
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,12 @@ const scanSingle = (item: IItem | ISection) => {
|
||||||
if (!comp.list[comp_id] && !comp.pending.has(comp_id)) {
|
if (!comp.list[comp_id] && !comp.pending.has(comp_id)) {
|
||||||
comp.pending.add(comp_id);
|
comp.pending.add(comp_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const prop of Object.values(item.component?.props || {})) {
|
||||||
|
if (prop.content && prop.meta?.type === "content-element") {
|
||||||
|
scanSingle(prop.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,18 @@ export const initBaseRoute = async () => {
|
||||||
id: string;
|
id: string;
|
||||||
url: string;
|
url: string;
|
||||||
}[];
|
}[];
|
||||||
|
layout: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (res && res.site && res.urls) {
|
if (res && res.site && res.urls) {
|
||||||
|
if (res.layout) {
|
||||||
|
base.layout.root = res.layout.root;
|
||||||
|
base.layout.meta = {};
|
||||||
|
if (base.layout.root) {
|
||||||
|
rebuildMeta(base.layout.meta, base.layout.root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
base.site = res.site;
|
base.site = res.site;
|
||||||
base.site.code = { mode: "new" };
|
base.site.code = { mode: "new" };
|
||||||
await injectSiteScript();
|
await injectSiteScript();
|
||||||
|
|
@ -32,7 +41,6 @@ export const initBaseRoute = async () => {
|
||||||
w.db = base.site.db;
|
w.db = base.site.db;
|
||||||
w.api = base.site.api;
|
w.api = base.site.api;
|
||||||
|
|
||||||
|
|
||||||
for (const item of res.urls) {
|
for (const item of res.urls) {
|
||||||
router.insert(item.url, item);
|
router.insert(item.url, item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,17 @@ export const Root = () => {
|
||||||
site_id={base.site.id}
|
site_id={base.site.id}
|
||||||
db={base.site.db}
|
db={base.site.db}
|
||||||
api={base.site.api}
|
api={base.site.api}
|
||||||
|
layout={
|
||||||
|
base.layout.id && base.layout.root && base.layout.meta
|
||||||
|
? {
|
||||||
|
id: base.layout.id,
|
||||||
|
meta: base.layout.meta,
|
||||||
|
entry: Object.values(base.layout.root.childs)
|
||||||
|
.filter((e) => e)
|
||||||
|
.map((e) => e.id),
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
script={{ init_local_effect: base.init_local_effect }}
|
script={{ init_local_effect: base.init_local_effect }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,23 @@ import { FC } from "react";
|
||||||
import { treeRebuild } from "../../nova/ed/logic/tree/build";
|
import { treeRebuild } from "../../nova/ed/logic/tree/build";
|
||||||
import { useGlobal } from "web-utils";
|
import { useGlobal } from "web-utils";
|
||||||
|
|
||||||
export const DeadEnd: FC<{ children: any; back: () => void }> = ({
|
export const DeadEnd: FC<{ children: any; back?: () => void }> = ({
|
||||||
children,
|
children,
|
||||||
back,
|
back,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center w-full h-full fixed inset-0 flex-col">
|
<div className="flex items-center justify-center w-full h-full fixed inset-0 flex-col">
|
||||||
<div>{children}</div>
|
<div>{children}</div>
|
||||||
<div className="border mt-2 rounded-md p-2 cursor-pointer" onClick={back}>
|
<div
|
||||||
|
className="border mt-2 rounded-md p-2 cursor-pointer"
|
||||||
|
onClick={
|
||||||
|
back
|
||||||
|
? back
|
||||||
|
: () => {
|
||||||
|
history.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
{" "}
|
{" "}
|
||||||
Go Back
|
Go Back
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue