diff --git a/.history/front/dist/index_20260317151413.html b/.history/front/dist/index_20260317151413.html
new file mode 100644
index 0000000..f999315
--- /dev/null
+++ b/.history/front/dist/index_20260317151413.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Google AI Studio App
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151445.html b/.history/front/dist/index_20260317151445.html
new file mode 100644
index 0000000..82eb65d
--- /dev/null
+++ b/.history/front/dist/index_20260317151445.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My_
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151458.html b/.history/front/dist/index_20260317151458.html
new file mode 100644
index 0000000..a5167ce
--- /dev/null
+++ b/.history/front/dist/index_20260317151458.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Person
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151502.html b/.history/front/dist/index_20260317151502.html
new file mode 100644
index 0000000..a9eb91e
--- /dev/null
+++ b/.history/front/dist/index_20260317151502.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151507.html b/.history/front/dist/index_20260317151507.html
new file mode 100644
index 0000000..12abf90
--- /dev/null
+++ b/.history/front/dist/index_20260317151507.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal Por
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151508.html b/.history/front/dist/index_20260317151508.html
new file mode 100644
index 0000000..86d72bc
--- /dev/null
+++ b/.history/front/dist/index_20260317151508.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151511.html b/.history/front/dist/index_20260317151511.html
new file mode 100644
index 0000000..05d2b23
--- /dev/null
+++ b/.history/front/dist/index_20260317151511.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151516.html b/.history/front/dist/index_20260317151516.html
new file mode 100644
index 0000000..52ffd5c
--- /dev/null
+++ b/.history/front/dist/index_20260317151516.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal P
+
+
+
+
+
+
+
+
diff --git a/.history/front/dist/index_20260317151518.html b/.history/front/dist/index_20260317151518.html
new file mode 100644
index 0000000..37746ac
--- /dev/null
+++ b/.history/front/dist/index_20260317151518.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ My Personal Portal
+
+
+
+
+
+
+
+
diff --git a/front/src/App.tsx b/front/src/App.tsx
index ecbf184..e6c4d4e 100644
--- a/front/src/App.tsx
+++ b/front/src/App.tsx
@@ -1,25 +1,54 @@
import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { Layout } from './components/layout/Layout';
+import { useAuth } from './auth/AuthProvider';
import Login from './pages/Login';
import Overview from './pages/Overview';
import Files from './pages/Files';
import School from './pages/School';
import Games from './pages/Games';
+function AppRoutes() {
+ const { ready, session } = useAuth();
+
+ if (!ready) {
+ return (
+
+ 正在检查登录状态...
+
+ );
+ }
+
+ const isAuthenticated = Boolean(session?.token);
+
+ return (
+
+ : }
+ />
+ : }
+ >
+ } />
+ } />
+ } />
+ } />
+ } />
+
+ }
+ />
+
+ );
+}
+
export default function App() {
return (
-
- } />
- }>
- } />
- } />
- } />
- } />
- } />
-
-
+
);
}
diff --git a/front/src/main.tsx b/front/src/main.tsx
index 080dac3..4b899c2 100644
--- a/front/src/main.tsx
+++ b/front/src/main.tsx
@@ -1,10 +1,13 @@
import {StrictMode} from 'react';
import {createRoot} from 'react-dom/client';
import App from './App.tsx';
+import {AuthProvider} from './auth/AuthProvider.tsx';
import './index.css';
createRoot(document.getElementById('root')!).render(
-
+
+
+
,
);
diff --git a/server-api-checklist.xml b/server-api-checklist.xml
new file mode 100644
index 0000000..cc8d11e
--- /dev/null
+++ b/server-api-checklist.xml
@@ -0,0 +1,103 @@
+
+
+ yoyuzh.xyz
+ 校验服务器侧 API 与反向代理配置,确保前端登录请求不会因服务器配置错误而失败。
+
+
+ https://yoyuzh.xyz
+ https://api.yoyuzh.xyz
+ https://api.yoyuzh.xyz/api
+
+
+
+ POST
+ /api/auth/login
+ https://api.yoyuzh.xyz/api/auth/login
+ application/json
+ application/json
+
+
+ 浏览器直接打开该地址会发起 GET,请不要把 GET 返回 405 误判为接口故障。
+ 真正需要成功的是前端发出的 POST 请求。
+
+
+
+
+ - 前端生产环境应请求 https://api.yoyuzh.xyz/api/auth/login。
+ - 前端登录不应跳转到 /api/auth/login 页面,也不应以 GET 方式访问该接口。
+ - 浏览器 Network 中必须看到 Request Method=POST。
+
+
+
+
+ api.yoyuzh.xyz
+ 127.0.0.1:8080
+ HTTP method
+ request body
+ Content-Type
+ Authorization
+ Origin
+ Host
+ X-Forwarded-For
+ X-Forwarded-Proto
+
+
+
+ https://yoyuzh.xyz
+ GET
+ POST
+ PUT
+ DELETE
+ OPTIONS
+ Content-Type
+ Authorization
+ OPTIONS 预检请求不应返回 405。
+
+
+
+
+ - POST https://api.yoyuzh.xyz/api/auth/login 应返回 JSON。
+ - OPTIONS https://api.yoyuzh.xyz/api/auth/login 不应返回 405。
+ - GET https://api.yoyuzh.xyz/api/auth/login 返回 405 属正常现象。
+ - Nginx 不应把 POST 改成 GET。
+ - Nginx 不应丢失 JSON 请求体。
+ - Nginx 不应把 /api/auth/login 重写到其他路径。
+
+
+
+
+
+
+
+
+
+
+ GET returns 405
+ 正常,不代表接口异常。
+
+
+ POST returns JSON business response
+ 服务器链路正常。
+
+
+ POST returns 404/405/502 or HTML
+ 服务器或反向代理配置异常,需要检查转发、方法、路径或上游服务。
+
+
+ OPTIONS returns 405
+ CORS 预检处理异常,需要修复服务器配置。
+
+
+
+
+ - POST /api/auth/login 返回 JSON。
+ - OPTIONS /api/auth/login 不返回 405。
+ - 响应中允许 Origin=https://yoyuzh.xyz。
+ - 前端浏览器 Network 中登录请求为 POST 到 https://api.yoyuzh.xyz/api/auth/login。
+
+