From 536af9b0e0532330f1379e80a26ae95f9ec668de Mon Sep 17 00:00:00 2001 From: Project_IO Date: Thu, 20 Mar 2025 16:53:09 +0900 Subject: [PATCH] feat: middle save --- internal/service/auth.go | 1 - src/App.scss | 2 +- src/App.tsx | 22 +++++++++++++++++-- src/components/directory/directory.scss | 1 + src/components/file-view/index.tsx | 13 ++---------- src/components/navigation/index.tsx | 10 +++++++++ src/components/settings/index.tsx | 17 +++++++++++++-- src/components/settings/settings.scss | 28 +++++++++++++++++-------- src/store/auth.ts | 5 +++++ 9 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 src/components/navigation/index.tsx diff --git a/internal/service/auth.go b/internal/service/auth.go index 6ea4b33..bce0fd9 100644 --- a/internal/service/auth.go +++ b/internal/service/auth.go @@ -39,7 +39,6 @@ func init() { ); `)) if err != nil { - _, _ = fmt.Fprintf(os.Stderr, "%v\n", err) return } defer stmt.Close() diff --git a/src/App.scss b/src/App.scss index 487d400..e34f097 100644 --- a/src/App.scss +++ b/src/App.scss @@ -5,7 +5,7 @@ .ka-nav { width: 100%; - height: 50px; + min-height: 60px; display: flex; flex-direction: row; align-items: center; diff --git a/src/App.tsx b/src/App.tsx index 7d0c0f7..310ad09 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,9 +10,10 @@ import "./App.scss"; import kuma from "./assets/kuma.png"; import NotFound from "./components/notfound"; import Login from "./components/login"; -import { useAuthStore } from "./store/auth"; +import { AccountData, useAuthStore } from "./store/auth"; import Logout from "./components/logout"; import Settings from "./components/settings"; +import { FileNavigator } from "./components/navigation"; function App() { return ( @@ -31,6 +32,7 @@ function Dashboard({ children }: { children: React.ReactNode }) { return (
+ {children}
@@ -70,6 +72,7 @@ function View() { function Header() { const auth = useAuthStore(); const [isAuth, setAuth] = useState(false); + const [username, setUsername] = useState("undefined"); useEffect(() => { if (auth.token === null) { @@ -80,6 +83,21 @@ function Header() { if (ok) setAuth(true); }); + + fetch("/api/auth/read", { + method: "GET", + mode: "same-origin", + headers: { + "Authorization": `Basic ${auth.token}` + } + }).then(res => { + if (res.status !== 200) + return; + + return res.json(); + }).then((data: AccountData) => { + setUsername(data.username); + }); }, [auth, isAuth]); return ( @@ -107,7 +125,7 @@ function Header() {
- Logged in as Admin + Logged in as {username} Logout diff --git a/src/components/directory/directory.scss b/src/components/directory/directory.scss index 245c267..109922d 100644 --- a/src/components/directory/directory.scss +++ b/src/components/directory/directory.scss @@ -14,6 +14,7 @@ .ka-dir-row { width: 100%; + height: 35px; display: grid; padding: 0.25rem 10px; place-items: left center; diff --git a/src/components/file-view/index.tsx b/src/components/file-view/index.tsx index 802fb36..e4e2c5f 100644 --- a/src/components/file-view/index.tsx +++ b/src/components/file-view/index.tsx @@ -107,19 +107,10 @@ function FileView() { {convert(path.data.total)}
- +
); diff --git a/src/components/navigation/index.tsx b/src/components/navigation/index.tsx new file mode 100644 index 0000000..be8c829 --- /dev/null +++ b/src/components/navigation/index.tsx @@ -0,0 +1,10 @@ +import { useLocation } from "react-router"; + +export function FileNavigator() { + const location = useLocation(); + const split = location.pathname.substring(1, location.pathname.length).split("/"); + + return
+ +
; +} diff --git a/src/components/settings/index.tsx b/src/components/settings/index.tsx index 50173eb..91aedb3 100644 --- a/src/components/settings/index.tsx +++ b/src/components/settings/index.tsx @@ -33,8 +33,12 @@ function Settings() { return (

General

- + +

Private Directory

+ +

Not provided features

+
); } @@ -51,6 +55,8 @@ function AccountSetting({ auth }: { auth: AuthState }) { const orRef = useRef(null); const pwRef = useRef(null); const ckRef = useRef(null); + + const [remove, setRemove] = useState(false); return ( @@ -117,7 +123,14 @@ function AccountSetting({ auth }: { auth: AuthState }) {
-