Commit 5d82719d by 江名洋

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

1 parent afed034e
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
try { try {
const response = await originalFetch.apply(this, args); const response = await originalFetch.apply(this, args);
if (response.status === 401 && !window.location.pathname.includes('/login')) { if (response.status === 401 && !window.location.pathname.includes('/login')) {
window.location.href = '/login'; window.location.href = './login';
} }
return response; return response;
} catch (err) { } catch (err) {
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
} }
}; };
// API 基础路径始终为 /api(FastAPI 统一挂载) // API 基础路径:动态计算(适配子路径部署),页面已设置则保留
window.API_BASE = '/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')) { if (window.location.pathname.includes('/login')) {
......
...@@ -193,19 +193,19 @@ ...@@ -193,19 +193,19 @@
<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>
<div class="detail-header"> <div class="detail-header">
<div class="breadcrumb"> <div class="breadcrumb">
<a href="/strategy">盯防管理</a> &gt; <span class="current">盯防效果数据查看</span> <a href="./strategy">盯防管理</a> &gt; <span class="current">盯防效果数据查看</span>
</div> </div>
<div class="header-actions"> <div class="header-actions">
<button class="btn btn-primary" onclick="history.back()">返回列表</button> <button class="btn btn-primary" onclick="history.back()">返回列表</button>
...@@ -569,6 +569,6 @@ ...@@ -569,6 +569,6 @@
document.addEventListener('DOMContentLoaded', loadDetail); document.addEventListener('DOMContentLoaded', loadDetail);
</script> </script>
<script src="/static/js/auth.js"></script> <script src="./static/js/auth.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file \ 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!