This commit is contained in:
Rizky 2024-02-08 00:43:23 +07:00
parent 447b71576d
commit 9b1976ea70
5 changed files with 37 additions and 6 deletions

View File

@ -5,6 +5,10 @@ import { TopBtn } from "../top-btn";
export const EdPagePicker = () => { export const EdPagePicker = () => {
const p = useGlobal(EDGlobal, "EDITOR"); const p = useGlobal(EDGlobal, "EDITOR");
if (p.page.cur.name !== p.page.list[p.page.cur.id].page.name) {
p.page.cur.name = p.page.list[p.page.cur.id].page.name;
}
return ( return (
<TopBtn <TopBtn
onClick={(e) => { onClick={(e) => {

View File

@ -12,10 +12,11 @@ import {
savePageMetaCache, savePageMetaCache,
} from "../ed/logic/ed-route"; } from "../ed/logic/ed-route";
import { loadSite } from "../ed/logic/ed-site"; import { loadSite } from "../ed/logic/ed-site";
import { treeCacheBuild } from "../ed/logic/tree/build"; import { treeCacheBuild, treeRebuild } 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 parseUA from "ua-parser-js"; import parseUA from "ua-parser-js";
import { DeadEnd } from "../../utils/ui/deadend";
const decoder = new TextDecoder(); const decoder = new TextDecoder();
export const ViPreview = (arg: { pathname: string }) => { export const ViPreview = (arg: { pathname: string }) => {
@ -66,6 +67,18 @@ export const ViPreview = (arg: { pathname: string }) => {
viRoute(p); viRoute(p);
if (p.status !== "ready" && p.status !== "reload") { if (p.status !== "ready" && p.status !== "reload") {
if (p.status === "page-not-found") {
return (
<DeadEnd
back={() => {
history.back();
}}
>
Page Not Found
</DeadEnd>
);
}
return <Loading note={p.status + "-page"} />; return <Loading note={p.status + "-page"} />;
} }

View File

@ -1,9 +1,18 @@
import { FC } from "react"; import { FC } from "react";
import { treeRebuild } from "../../nova/ed/logic/tree/build";
import { useGlobal } from "web-utils";
export const DeadEnd: FC<{ children: any }> = ({ children }) => { export const DeadEnd: FC<{ children: any; back: () => void }> = ({
children,
back,
}) => {
return ( return (
<div className="flex items-center justify-center w-full h-full fixed inset-0"> <div className="flex items-center justify-center w-full h-full fixed inset-0 flex-col">
{children} <div>{children}</div>
<div className="border mt-2 rounded-md p-2 cursor-pointer" onClick={back}>
{" "}
Go Back
</div>
</div> </div>
); );
}; };

View File

@ -21,9 +21,14 @@ export const Input: FC<
delete prop.onChange; delete prop.onChange;
} }
let value = form[name];
if (value instanceof URL) {
value = value.toString();
}
return ( return (
<input <input
value={form[name] || ""} value={value || ""}
spellCheck={false} spellCheck={false}
onInput={(e) => { onInput={(e) => {
form[name] = e.currentTarget.value; form[name] = e.currentTarget.value;

View File

@ -76,7 +76,7 @@ export const defineWindow = async (awaitServerUrl = true) => {
if (!_href) return null; if (!_href) return null;
} }
history.pushState({}, "", _href); history.pushState({ prevUrl: window.location.href }, "", _href);
w.pathname = href; w.pathname = href;
if (w.prasiContext && w.prasiContext.render) { if (w.prasiContext && w.prasiContext.render) {