Commit 5d82719d by 江名洋

fix: 适配子路径部署的路径与API基础地址

1 parent afed034e
......@@ -14,7 +14,7 @@
try {
const response = await originalFetch.apply(this, args);
if (response.status === 401 && !window.location.pathname.includes('/login')) {
window.location.href = '/login';
window.location.href = './login';
}
return response;
} catch (err) {
......@@ -22,8 +22,10 @@
}
};
// API 基础路径始终为 /api(FastAPI 统一挂载)
window.API_BASE = '/api';
// API 基础路径:动态计算(适配子路径部署),页面已设置则保留
// if (!window.API_BASE) {
(function(){var p=window.location.pathname;if(p.endsWith('/'))p=p.slice(0,-1);var i=p.lastIndexOf('/');window.API_BASE=p.substring(0,i)+'/api';})();
// }
// 登录页不执行后续逻辑
if (window.location.pathname.includes('/login')) {
......
......@@ -193,19 +193,19 @@
<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>
<div class="detail-header">
<div class="breadcrumb">
<a href="/strategy">盯防管理</a> &gt; <span class="current">盯防效果数据查看</span>
<a href="./strategy">盯防管理</a> &gt; <span class="current">盯防效果数据查看</span>
</div>
<div class="header-actions">
<button class="btn btn-primary" onclick="history.back()">返回列表</button>
......@@ -569,6 +569,6 @@
document.addEventListener('DOMContentLoaded', loadDetail);
</script>
<script src="/static/js/auth.js"></script>
<script src="./static/js/auth.js"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!