From 60c86f146ebaf9a744f12d51a45fc9a371b32c06 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Wed, 24 Aug 2022 13:17:37 +0900 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E3=81=97=E3=81=84=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E4=BD=9C=E6=88=90=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/app.tsx | 5 ++++- app/src/helpers/random.ts | 5 +++++ app/src/pages/page.tsx | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 app/src/helpers/random.ts diff --git a/app/src/app.tsx b/app/src/app.tsx index 4b1b5a9..e01a788 100644 --- a/app/src/app.tsx +++ b/app/src/app.tsx @@ -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 () => { 📄 - {routes[pathname()] ?? } + {routes[pathname()] ?? ( + + )} ); }; diff --git a/app/src/helpers/random.ts b/app/src/helpers/random.ts new file mode 100644 index 0000000..94f9e8e --- /dev/null +++ b/app/src/helpers/random.ts @@ -0,0 +1,5 @@ +function random(): number { + return window.crypto.getRandomValues(new Uint16Array(1))[0]!; +} + +export default random; diff --git a/app/src/pages/page.tsx b/app/src/pages/page.tsx index 5ef43e2..493a9d3 100644 --- a/app/src/pages/page.tsx +++ b/app/src/pages/page.tsx @@ -37,6 +37,7 @@ export default (props: { id: number }) => { if (await updatePage(id, content)) { unblock(); refetch(); + window.history.replaceState({}, "", `/${id}`); } }, intervalMs