This commit is contained in:
Rizky 2024-06-05 08:59:49 +07:00
parent ff1f2e2062
commit 0f520d14c4
5 changed files with 29 additions and 17 deletions

View File

@ -89,7 +89,7 @@ export const snapshot = {
async update(data: DocSnapshot) { async update(data: DocSnapshot) {
const id = `${data.type}-${data.id}`; const id = `${data.type}-${data.id}`;
this, _db[id] = data; this._db[id] = data;
return true; return true;
}, },

View File

@ -140,6 +140,7 @@ export const reloadPage = async (
p.status = "reload"; p.status = "reload";
const remotePage = await p.sync.page.load(page_id); const remotePage = await p.sync.page.load(page_id);
console.log(remotePage)
if (!remotePage) { if (!remotePage) {
p.status = "page-not-found"; p.status = "page-not-found";
p.render(); p.render();

View File

@ -50,8 +50,7 @@ export const Root = () => {
base.route.pages = pages; base.route.pages = pages;
const basepath = w._prasi.basepath; const basepath = w._prasi.basepath;
let url = `${ let url = `${basepath.endsWith("/") ? basepath : `${basepath}/`
basepath.endsWith("/") ? basepath : `${basepath}/`
}_prasi/code/index.js`; }_prasi/code/index.js`;
const cur = new URL(location.href); const cur = new URL(location.href);
@ -224,7 +223,7 @@ export const Root = () => {
await setkv(`comp-${id}`, item); await setkv(`comp-${id}`, item);
} }
} catch (e) {} } catch (e) { }
return comp.list[comp_id]; return comp.list[comp_id];
}} }}

View File

@ -1,7 +1,7 @@
import { get } from "idb-keyval"; import { get } from "idb-keyval";
import parseUA from "ua-parser-js"; import parseUA from "ua-parser-js";
import init, { decompress } from "wasm-gzip"; import init, { decompress } from "wasm-gzip";
import { useGlobal } from "web-utils"; import { deepClone, useGlobal } from "web-utils";
import { w } from "../../utils/types/general"; import { w } from "../../utils/types/general";
import { IRoot } from "../../utils/types/root"; import { IRoot } from "../../utils/types/root";
import { DeadEnd } from "../../utils/ui/deadend"; import { DeadEnd } from "../../utils/ui/deadend";
@ -16,6 +16,7 @@ import { loadSite } from "../ed/logic/ed-site";
import { treeCacheBuild } from "../ed/logic/tree/build"; import { treeCacheBuild } from "../ed/logic/tree/build";
import { nav } from "./render/script/extract-nav"; import { nav } from "./render/script/extract-nav";
import { Vi } from "./vi"; import { Vi } from "./vi";
import { loadComponent } from "../ed/logic/comp/load";
const decoder = new TextDecoder(); const decoder = new TextDecoder();
export const ViPreview = (arg: { pathname: string }) => { export const ViPreview = (arg: { pathname: string }) => {
@ -123,6 +124,17 @@ export const ViPreview = (arg: { pathname: string }) => {
entry={p.page.entry} entry={p.page.entry}
api={p.script.api} api={p.script.api}
db={p.script.db} db={p.script.db}
comp_load={async (comp_id) => {
let comp = p.comp.loaded[comp_id];
if (comp) {
return comp;
}
await loadComponent(p, comp_id);
comp = p.comp.loaded[comp_id];
return deepClone(comp);
}}
layout={ layout={
p.site.layout.id && p.site.layout.meta p.site.layout.id && p.site.layout.meta
? { ? {