mirror of
https://github.com/kou029w/quot.git
synced 2025-01-19 00:18:09 +00:00
新しいページの作成に対応
This commit is contained in:
parent
86afc69f56
commit
60c86f146e
3 changed files with 10 additions and 1 deletions
|
@ -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()} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
5
app/src/helpers/random.ts
Normal file
5
app/src/helpers/random.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
function random(): number {
|
||||
return window.crypto.getRandomValues(new Uint16Array(1))[0]!;
|
||||
}
|
||||
|
||||
export default random;
|
|
@ -37,6 +37,7 @@ export default (props: { id: number }) => {
|
|||
if (await updatePage(id, content)) {
|
||||
unblock();
|
||||
refetch();
|
||||
window.history.replaceState({}, "", `/${id}`);
|
||||
}
|
||||
},
|
||||
intervalMs
|
||||
|
|
Loading…
Add table
Reference in a new issue