Commit afed034e by 江名洋

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

1 parent 40d07faa
......@@ -9,6 +9,7 @@
APP_ENV=dev
APP_DEBUG=false
APP_PORT=9500
ROOT_PATH=/daw
# ============================================================================
# 数据库 (MySQL)
......
......@@ -15,6 +15,7 @@ class Settings(BaseSettings):
APP_ENV: str = "dev"
APP_DEBUG: bool = False
APP_PORT: int = 9500
ROOT_PATH: str = "" # 如 "/daw",Nginx 反向代理时设置
# Security
SECRET_KEY: str = "change-me-in-production-32-char-long-key" # 用于 JWT 签名,生产环境务必修改
......
......@@ -35,7 +35,7 @@
try {
const res = await fetch(window.API_BASE + '/auth/me', { credentials: 'include' });
if (res.status === 401) {
window.location.href = '/login';
window.location.href = './login';
return;
}
if (!res.ok) {
......@@ -70,7 +70,7 @@
} catch (err) {
console.error('退出请求失败:', err);
}
window.location.href = '/login';
window.location.href = './login';
});
userInfo.appendChild(nameSpan);
userInfo.appendChild(logoutLink);
......
......@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>策略效果盯防 - 问界门店运营数据分析平台</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="./static/css/style.css">
<style>
.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; }
......@@ -183,12 +183,12 @@
<header>
<div class="logo">问界运营分析平台</div>
<nav class="nav-links">
<a class="nav-item" href="/">首页</a>
<a class="nav-item" href="/ods">ODS 同步任务</a>
<a class="nav-item" href="/dw">DWS/DWM/DWA 任务</a>
<a class="nav-item" href="/analysis">问界生态系数分析</a>
<a class="nav-item" href="/harmony">鸿蒙生态分析</a>
<a class="nav-item active" href="/strategy">策略效果盯防</a>
<a class="nav-item" href="./">首页</a>
<a class="nav-item" href="./ods">ODS 同步任务</a>
<a class="nav-item" href="./dw">DWS/DWM/DWA 任务</a>
<a class="nav-item" href="./analysis">问界生态系数分析</a>
<a class="nav-item" href="./harmony">鸿蒙生态分析</a>
<a class="nav-item active" href="./strategy">策略效果盯防</a>
</nav>
<div class="user-info" id="user-info">管理员</div>
</header>
......@@ -285,7 +285,7 @@
</div>
<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 currentFilters = {};
......@@ -830,6 +830,6 @@
document.getElementById('btn-reset').addEventListener('click', resetFilters);
});
</script>
<script src="/static/js/auth.js"></script>
<script src="./static/js/auth.js"></script>
</body>
</html>
......@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>盯防效果数据查看 - 问界门店运营数据分析平台</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="./static/css/style.css">
<style>
:root {
--primary: #1890ff;
......@@ -217,7 +217,7 @@
</div>
<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 = {
ew: { name: '整车延保', color: '#1890ff' },
......
......@@ -77,6 +77,7 @@ app = FastAPI(
description="支持 ODS/DWS/DWM/DWA 各层数据同步任务及分析模版展示",
version="1.0.0",
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!