Youngger9765 Claude commited on
Commit
78052ea
·
1 Parent(s): f8d0f2d

fix: Reorganize header layout and fix API docs link

Browse files

- Split header into two rows: title+nav and selectors
- Fix API docs link to work in both local and HF Spaces
- Update HF routing to properly handle /docs requests
- Improve layout spacing and organization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (3) hide show
  1. frontend/src/App.css +11 -9
  2. frontend/src/App.tsx +3 -3
  3. hf_app.py +3 -3
frontend/src/App.css CHANGED
@@ -33,25 +33,27 @@ body {
33
 
34
  .app-header {
35
  display: flex;
36
- align-items: center;
37
- justify-content: space-between;
38
  margin-bottom: 20px;
39
  width: 100%;
40
  max-width: 1400px;
41
- gap: 30px;
42
  }
43
 
44
- .header-title {
45
- flex-shrink: 0;
 
 
 
46
  }
47
 
48
- .header-controls {
49
  display: flex;
50
  gap: 15px;
51
  flex-wrap: wrap;
52
  align-items: center;
53
- flex-grow: 1;
54
- justify-content: flex-end;
55
  }
56
 
57
  .header-selector {
@@ -91,7 +93,7 @@ body {
91
 
92
  .app-header h1 {
93
  font-size: 2.2rem;
94
- margin-bottom: 1rem;
95
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
96
  -webkit-background-clip: text;
97
  -webkit-text-fill-color: transparent;
 
33
 
34
  .app-header {
35
  display: flex;
36
+ flex-direction: column;
37
+ gap: 15px;
38
  margin-bottom: 20px;
39
  width: 100%;
40
  max-width: 1400px;
 
41
  }
42
 
43
+ .header-row-1 {
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: space-between;
47
+ width: 100%;
48
  }
49
 
50
+ .header-row-2 {
51
  display: flex;
52
  gap: 15px;
53
  flex-wrap: wrap;
54
  align-items: center;
55
+ justify-content: center;
56
+ width: 100%;
57
  }
58
 
59
  .header-selector {
 
93
 
94
  .app-header h1 {
95
  font-size: 2.2rem;
96
+ margin: 0;
97
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
98
  -webkit-background-clip: text;
99
  -webkit-text-fill-color: transparent;
frontend/src/App.tsx CHANGED
@@ -167,7 +167,7 @@ function App() {
167
  return (
168
  <div className="App">
169
  <header className="app-header">
170
- <div className="header-title">
171
  <h1>AI 批改平台</h1>
172
  <nav className="header-nav">
173
  <button
@@ -183,7 +183,7 @@ function App() {
183
  設定指南
184
  </button>
185
  <a
186
- href="/api/docs"
187
  target="_blank"
188
  rel="noopener noreferrer"
189
  className="nav-link"
@@ -200,7 +200,7 @@ function App() {
200
  </a>
201
  </nav>
202
  </div>
203
- <div className="header-controls">
204
  <div className="header-selector">
205
  <label htmlFor="language">{currentLabels.language}</label>
206
  <select
 
167
  return (
168
  <div className="App">
169
  <header className="app-header">
170
+ <div className="header-row-1">
171
  <h1>AI 批改平台</h1>
172
  <nav className="header-nav">
173
  <button
 
183
  設定指南
184
  </button>
185
  <a
186
+ href={window.location.port === '5174' ? 'http://localhost:8001/docs' : '/docs'}
187
  target="_blank"
188
  rel="noopener noreferrer"
189
  className="nav-link"
 
200
  </a>
201
  </nav>
202
  </div>
203
+ <div className="header-row-2">
204
  <div className="header-selector">
205
  <label htmlFor="language">{currentLabels.language}</label>
206
  <select
hf_app.py CHANGED
@@ -52,9 +52,9 @@ if frontend_dist.exists():
52
  @backend_app.get("/{full_path:path}")
53
  async def serve_spa(full_path: str):
54
  """Handle client-side routing"""
55
- # Don't catch API routes
56
- if full_path.startswith("api/"):
57
- return {"error": "API route not found", "path": full_path}
58
 
59
  # Check if it's a static file
60
  file_path = frontend_dist / full_path
 
52
  @backend_app.get("/{full_path:path}")
53
  async def serve_spa(full_path: str):
54
  """Handle client-side routing"""
55
+ # Don't catch API routes or docs
56
+ if full_path.startswith("api/") or full_path == "docs" or full_path.startswith("docs/"):
57
+ return {"error": "Route not found", "path": full_path}
58
 
59
  # Check if it's a static file
60
  file_path = frontend_dist / full_path