diff --git a/src/app/globals.css b/src/app/globals.css
index a2dc41e..2afc210 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -24,3 +24,7 @@ body {
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
+
+.iconify {
+ display: inline;
+}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index a2695ba..16b6c0d 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -15,7 +15,7 @@ const geistMono = Geist_Mono({
});
export const metadata: Metadata = {
- title: "uwuzu軽量クライアント",
+ title: "uwuzu Light Client",
description: "(自称)超軽量uwuzuクライアントです。",
};
diff --git a/src/app/page.tsx b/src/app/page.tsx
index aa751d5..adf2d58 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,9 +1,17 @@
"use client";
import { Icon } from "@iconify/react";
+import { useRouter } from "next/navigation";
+import Cookies from "js-cookie";
import Image from "next/image";
import Link from "next/link";
export default function Home() {
+ // ログイン済みの場合ホームへ移動
+ const router = useRouter();
+ if (typeof Cookies.get("host") !== "undefined") {
+ router.push("/home");
+ }
+
return (
) => {
+ e.preventDefault();
+ setLoading(true);
+
+
+ // データを変数に代入
+ const host: string = e.currentTarget.host.value;
+ const token: string = e.currentTarget.token.value;
+
+ try {
+ // APIテスト
+ const test = await (await fetch(
+ `https://${host}/api/me/?token=${token}`
+ )).json();
+
+ if (typeof test.error_code !== "undefined") {
+ alert(`
+ トークンが誤っています。
+ `);
+ setLoading(false);
+ return;
+ } else {
+ Cookies.set("host", host, { expires: 999 });
+ Cookies.set("token", token, { expires: 999 });
+
+ alert(`${test.username}へログインしました!`);
+ router.push("/home");
+ }
+ } catch (err) {
+ alert(`
+ サーバーとの通信に失敗しました。
+ プロトコルあるいはホストが誤っている可能性があります。
+
+
+ 詳細エラー: ${err}
+ `);
+ setLoading(false);
+ return;
+ }
+ }
+
+ return (
+
+ );
}
diff --git a/src/components/footer/main.tsx b/src/components/footer/main.tsx
index 02e7fca..3922cda 100644
--- a/src/components/footer/main.tsx
+++ b/src/components/footer/main.tsx
@@ -32,21 +32,9 @@ export default function Footer() {
target=""
/>
-
-
diff --git a/test.ts b/test.ts
new file mode 100644
index 0000000..96ddc3c
--- /dev/null
+++ b/test.ts
@@ -0,0 +1,12 @@
+(async () => {
+ const req = await fetch("https://uwuzu.net/api/me", {
+ method: "POST",
+ cache: "no-store",
+ body: JSON.stringify({
+ token: "RpC9X0BuNUsaOxLkw3Pf5YGMIEHVtgldDnrbWKzhFvjT7eZ4qJ6m81Si2oQcAy",
+ }),
+ });
+ const res = await req.json();
+
+ console.log(res);
+})();