Format files

This commit is contained in:
2023-05-29 16:53:19 +08:00
parent 0ab1c45bdc
commit 1c07fe9dc1

View File

@@ -1,6 +1,6 @@
import { Head } from "$fresh/runtime.ts"; import { Head } from "$fresh/runtime.ts";
import { Component, ContextType } from "preact"; import { Component, ContextType } from "preact";
import { useState, StateUpdater, useEffect } from "preact/hooks"; import { StateUpdater, useEffect, useState } from "preact/hooks";
import Icon from "preact-material-components/Icon"; import Icon from "preact-material-components/Icon";
import List from "preact-material-components/List"; import List from "preact-material-components/List";
import TopAppBar from "preact-material-components/TopAppBar"; import TopAppBar from "preact-material-components/TopAppBar";
@@ -24,7 +24,7 @@ export default class Container extends Component<ContainerProps> {
const v = typeof updater === "function" ? updater(state) : updater; const v = typeof updater === "function" ? updater(state) : updater;
set_state1(v); set_state1(v);
history.pushState(v, "", v); history.pushState(v, "", v);
} };
useEffect(() => { useEffect(() => {
const hash = document.location.hash; const hash = document.location.hash;
if (!hash || hash == "#") { if (!hash || hash == "#") {
@@ -32,15 +32,15 @@ export default class Container extends Component<ContainerProps> {
} else { } else {
set_state1(hash); set_state1(hash);
} }
self.addEventListener('popstate', (e) => { self.addEventListener("popstate", (e) => {
const s = e.state; const s = e.state;
if (typeof s === "string") { if (typeof s === "string") {
set_state1(s); set_state1(s);
} else { } else {
set_state1("#/"); set_state1("#/");
} }
}) });
}, []) }, []);
return ( return (
<div> <div>
<Head> <Head>
@@ -68,10 +68,12 @@ export default class Container extends Component<ContainerProps> {
<List.Item onClick={() => set_display(false)}> <List.Item onClick={() => set_display(false)}>
<Icon>close</Icon> <Icon>close</Icon>
</List.Item> </List.Item>
<List.Item onClick={() => { <List.Item
set_display(false); onClick={() => {
set_state("#/"); set_display(false);
}}> set_state("#/");
}}
>
<Icon>home</Icon> <Icon>home</Icon>
</List.Item> </List.Item>
<List.Item <List.Item