Commit afed034e by 江名洋

feat: 支持反向代理子路径部署

1 parent 40d07faa
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
APP_ENV=dev APP_ENV=dev
APP_DEBUG=false APP_DEBUG=false
APP_PORT=9500 APP_PORT=9500
ROOT_PATH=/daw
# ============================================================================ # ============================================================================
# 数据库 (MySQL) # 数据库 (MySQL)
......
...@@ -15,6 +15,7 @@ class Settings(BaseSettings): ...@@ -15,6 +15,7 @@ class Settings(BaseSettings):
APP_ENV: str = "dev" APP_ENV: str = "dev"
APP_DEBUG: bool = False APP_DEBUG: bool = False
APP_PORT: int = 9500 APP_PORT: int = 9500
ROOT_PATH: str = "" # 如 "/daw",Nginx 反向代理时设置
# Security # Security
SECRET_KEY: str = "change-me-in-production-32-char-long-key" # 用于 JWT 签名,生产环境务必修改 SECRET_KEY: str = "change-me-in-production-32-char-long-key" # 用于 JWT 签名,生产环境务必修改
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
try { try {
const res = await fetch(window.API_BASE + '/auth/me', { credentials: 'include' }); const res = await fetch(window.API_BASE + '/auth/me', { credentials: 'include' });
if (res.status === 401) { if (res.status === 401) {
window.location.href = '/login'; window.location.href = './login';
return; return;
} }
if (!res.ok) { if (!res.ok) {
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
} catch (err) { } catch (err) {
console.error('退出请求失败:', err); console.error('退出请求失败:', err);
} }
window.location.href = '/login'; window.location.href = './login';
}); });
userInfo.appendChild(nameSpan); userInfo.appendChild(nameSpan);
userInfo.appendChild(logoutLink); userInfo.appendChild(logoutLink);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>策略效果盯防 - 问界门店运营数据分析平台</title> <title>策略效果盯防 - 问界门店运营数据分析平台</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="./static/css/style.css">
<style> <style>
.strategy-stats { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; } .strategy-stats { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 150px; background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 12px; } .stat-card { flex: 1; min-width: 150px; background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 12px; }
...@@ -183,12 +183,12 @@ ...@@ -183,12 +183,12 @@
<header> <header>
<div class="logo">问界运营分析平台</div> <div class="logo">问界运营分析平台</div>
<nav class="nav-links"> <nav class="nav-links">
<a class="nav-item" href="/">首页</a> <a class="nav-item" href="./">首页</a>
<a class="nav-item" href="/ods">ODS 同步任务</a> <a class="nav-item" href="./ods">ODS 同步任务</a>
<a class="nav-item" href="/dw">DWS/DWM/DWA 任务</a> <a class="nav-item" href="./dw">DWS/DWM/DWA 任务</a>
<a class="nav-item" href="/analysis">问界生态系数分析</a> <a class="nav-item" href="./analysis">问界生态系数分析</a>
<a class="nav-item" href="/harmony">鸿蒙生态分析</a> <a class="nav-item" href="./harmony">鸿蒙生态分析</a>
<a class="nav-item active" href="/strategy">策略效果盯防</a> <a class="nav-item active" href="./strategy">策略效果盯防</a>
</nav> </nav>
<div class="user-info" id="user-info">管理员</div> <div class="user-info" id="user-info">管理员</div>
</header> </header>
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
</div> </div>
<script> <script>
window.API_BASE = '/api'; window.API_BASE = (function(){var p=window.location.pathname;if(p.endsWith('/'))p=p.slice(0,-1);var i=p.lastIndexOf('/');return p.substring(0,i)+'/api';})();
let currentPage = 1; let currentPage = 1;
let currentFilters = {}; let currentFilters = {};
...@@ -830,6 +830,6 @@ ...@@ -830,6 +830,6 @@
document.getElementById('btn-reset').addEventListener('click', resetFilters); document.getElementById('btn-reset').addEventListener('click', resetFilters);
}); });
</script> </script>
<script src="/static/js/auth.js"></script> <script src="./static/js/auth.js"></script>
</body> </body>
</html> </html>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>盯防效果数据查看 - 问界门店运营数据分析平台</title> <title>盯防效果数据查看 - 问界门店运营数据分析平台</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="./static/css/style.css">
<style> <style>
:root { :root {
--primary: #1890ff; --primary: #1890ff;
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
</div> </div>
<script> <script>
window.API_BASE = '/api'; window.API_BASE = (function(){var p=window.location.pathname;if(p.endsWith('/'))p=p.slice(0,-1);var i=p.lastIndexOf('/');return p.substring(0,i)+'/api';})();
const PRODUCT_META = { const PRODUCT_META = {
ew: { name: '整车延保', color: '#1890ff' }, ew: { name: '整车延保', color: '#1890ff' },
......
...@@ -77,6 +77,7 @@ app = FastAPI( ...@@ -77,6 +77,7 @@ app = FastAPI(
description="支持 ODS/DWS/DWM/DWA 各层数据同步任务及分析模版展示", description="支持 ODS/DWS/DWM/DWA 各层数据同步任务及分析模版展示",
version="1.0.0", version="1.0.0",
lifespan=lifespan, lifespan=lifespan,
root_path=settings.ROOT_PATH or "",
) )
# 挂载静态文件 # 挂载静态文件
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!