This commit is contained in:
Rizky 2024-01-25 16:14:53 +07:00
parent ce4b1a5f7a
commit 57b4bf9c24
3 changed files with 25 additions and 19 deletions

View File

@ -4,7 +4,6 @@ import { fetchViaProxy } from "../proxy";
export const loadApiProxyDef = async (_url: string, with_types: boolean) => { export const loadApiProxyDef = async (_url: string, with_types: boolean) => {
const url = trim(_url, "/"); const url = trim(_url, "/");
console.log(url, _url);
const raw = await fetchViaProxy(urlPath(url, "/_prasi/_")); const raw = await fetchViaProxy(urlPath(url, "/_prasi/_"));
let ver = ""; let ver = "";
if (raw && (raw as any).prasi) { if (raw && (raw as any).prasi) {

View File

@ -6,25 +6,27 @@ import { Loading } from "../../utils/ui/loading";
import init from "wasm-gzip"; import init from "wasm-gzip";
export default page({ export default page({
url: "/ed/:site_id/:page_id", url: "/ed/:site_id/:page_id",
component: ({}) => { component: ({}) => {
const p = useGlobal(EDGlobal, "EDITOR"); const p = useGlobal(EDGlobal, "EDITOR");
const w = window as any; const w = window as any;
if (!w.Y) { if (!w.Y) {
(async () => { (async () => {
await init(); await init();
(window as any).Y = await import("yjs"); (window as any).Y = await import("yjs");
(window as any).syncronize = (await import("y-pojo")).syncronize; (window as any).syncronize = (await import("y-pojo")).syncronize;
p.render(); p.render();
})(); })();
return <Loading note="init" />; return <Loading note="init" />;
} }
if (!edInitSync(p)) { w.isEditor = true;
return <Loading note="connecting-ws" />;
}
return <EdBase />; if (!edInitSync(p)) {
}, return <Loading note="connecting-ws" />;
}
return <EdBase />;
},
}); });

View File

@ -7,6 +7,7 @@ import { ViRoot } from "./root";
import { ErrorBox } from "./utils/error-box"; import { ErrorBox } from "./utils/error-box";
import { render_stat } from "./render/render"; import { render_stat } from "./render/render";
const w = window as any;
export const Vi: FC<{ export const Vi: FC<{
meta: Record<string, IMeta>; meta: Record<string, IMeta>;
mode: "mobile" | "desktop"; mode: "mobile" | "desktop";
@ -36,6 +37,10 @@ export const Vi: FC<{
}) => { }) => {
const vi = useGlobal(ViGlobal, "VI"); const vi = useGlobal(ViGlobal, "VI");
vi.mode = mode; vi.mode = mode;
w.isMobile = mode === "mobile";
w.isDesktop = mode === "desktop";
vi.on_status_changes = on_status_changed; vi.on_status_changes = on_status_changed;
if (rs === "disabled") { if (rs === "disabled") {