diff --git a/app/srv/api/deploy.ts b/app/srv/api/deploy.ts index 75fd7d27..d7b7094a 100644 --- a/app/srv/api/deploy.ts +++ b/app/srv/api/deploy.ts @@ -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 = ""; if (site && site.config && (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 }, }); 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": { diff --git a/app/web/src/nova/deploy/base/base.tsx b/app/web/src/nova/deploy/base/base.tsx index cdbc9208..8c36f699 100644 --- a/app/web/src/nova/deploy/base/base.tsx +++ b/app/web/src/nova/deploy/base/base.tsx @@ -30,7 +30,7 @@ export const base = { api: any; db: any; }, - init_local_effect: {} as any, + init_local_effect: {} as any, mode: "" as "desktop" | "mobile", route: { status: "init" as "init" | "loading" | "ready", @@ -40,6 +40,11 @@ export const base = { list: {} as Record, pending: new Set(), }, + layout: { + id: "", + root: null as null | IRoot, + meta: null as null | Record, + }, page: { id: "", url: "", diff --git a/app/web/src/nova/deploy/base/component.tsx b/app/web/src/nova/deploy/base/component.tsx index d17bd7cf..c074da0c 100644 --- a/app/web/src/nova/deploy/base/component.tsx +++ b/app/web/src/nova/deploy/base/component.tsx @@ -41,6 +41,12 @@ const scanSingle = (item: IItem | ISection) => { if (!comp.list[comp_id] && !comp.pending.has(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); + } + } } } diff --git a/app/web/src/nova/deploy/base/route.tsx b/app/web/src/nova/deploy/base/route.tsx index bee63c92..e5757e45 100644 --- a/app/web/src/nova/deploy/base/route.tsx +++ b/app/web/src/nova/deploy/base/route.tsx @@ -17,9 +17,18 @@ export const initBaseRoute = async () => { id: string; url: string; }[]; + layout: any; }; 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.code = { mode: "new" }; await injectSiteScript(); @@ -32,7 +41,6 @@ export const initBaseRoute = async () => { w.db = base.site.db; w.api = base.site.api; - for (const item of res.urls) { router.insert(item.url, item); } diff --git a/app/web/src/nova/deploy/root.tsx b/app/web/src/nova/deploy/root.tsx index 6120f8cb..f6a07393 100644 --- a/app/web/src/nova/deploy/root.tsx +++ b/app/web/src/nova/deploy/root.tsx @@ -121,6 +121,17 @@ export const Root = () => { site_id={base.site.id} db={base.site.db} 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 }} /> diff --git a/app/web/src/utils/ui/deadend.tsx b/app/web/src/utils/ui/deadend.tsx index ddb51fda..b9f8af8a 100644 --- a/app/web/src/utils/ui/deadend.tsx +++ b/app/web/src/utils/ui/deadend.tsx @@ -2,14 +2,23 @@ import { FC } from "react"; import { treeRebuild } from "../../nova/ed/logic/tree/build"; import { useGlobal } from "web-utils"; -export const DeadEnd: FC<{ children: any; back: () => void }> = ({ +export const DeadEnd: FC<{ children: any; back?: () => void }> = ({ children, back, }) => { return (
{children}
-
+
{ + history.back(); + } + } + > {" "} Go Back