1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-19 00:18:09 +00:00

新しいページの作成に対応

This commit is contained in:
Nebel 2022-08-24 13:17:37 +09:00
parent 86afc69f56
commit 60c86f146e
3 changed files with 10 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import "./app.css";
import { createSignal } from "solid-js";
import Index from "./pages/index";
import Page from "./pages/page";
import random from "./helpers/random";
const routes = {
"/": Index,
@ -36,7 +37,9 @@ export default () => {
</h1>
<a href="/new">📄</a>
</header>
{routes[pathname()] ?? <Page id={Number(pathname().slice(1))} />}
{routes[pathname()] ?? (
<Page id={Number(pathname().slice(1)) || random()} />
)}
</>
);
};

View file

@ -0,0 +1,5 @@
function random(): number {
return window.crypto.getRandomValues(new Uint16Array(1))[0]!;
}
export default random;

View file

@ -37,6 +37,7 @@ export default (props: { id: number }) => {
if (await updatePage(id, content)) {
unblock();
refetch();
window.history.replaceState({}, "", `/${id}`);
}
},
intervalMs