Commit fcb97ad0 by 江名洋

fix: 使用动态API_BASE替换硬编码相对路径

1 parent 8b0e6616
......@@ -97,6 +97,7 @@
</main>
<script>
(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';})();
document.addEventListener('DOMContentLoaded', () => {
const fmt = d => `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`;
const now = new Date();
......@@ -179,7 +180,7 @@
if (hasEcology) uploadForm.append('ecology_factory_file', ecologyFactoryInput.files[0]);
if (hasNature) uploadForm.append('nature_factory_file', natureFactoryInput.files[0]);
const uploadRes = await fetch('../api/analysis/upload', { method: 'POST', body: uploadForm });
const uploadRes = await fetch(window.API_BASE + '/analysis/upload', { method: 'POST', body: uploadForm });
const uploadData = await uploadRes.json();
if (uploadData.status !== 'success') {
throw new Error(uploadData.detail || '文件上传失败');
......
......@@ -128,7 +128,7 @@
btn.disabled = true;
btn.textContent = '加工中...';
try {
const res = await fetch('../api/etl/run-dw', { method: 'POST', body: formData });
const res = await fetch(window.API_BASE + '/etl/run-dw', { method: 'POST', body: formData });
const data = await res.json();
if (data.status === 'success') {
setTimeout(() => { btn.disabled = false; btn.textContent = '开始加工'; }, 2000);
......
......@@ -84,7 +84,7 @@
document.addEventListener('DOMContentLoaded', async () => {
try {
const res = await fetch('../api/etl/scheduler-config?task_id=sync_ods_data');
const res = await fetch(window.API_BASE + '/etl/scheduler-config?task_id=sync_ods_data');
const config = await res.json();
document.getElementById('conf-task-id').textContent = config.task_id || '-';
document.getElementById('conf-status').textContent = config.status || '-';
......@@ -101,7 +101,7 @@
btn.disabled = true;
btn.textContent = '任务已启动...';
try {
const res = await fetch('../api/etl/run-ods', { method: 'POST' });
const res = await fetch(window.API_BASE + '/etl/run-ods', { method: 'POST' });
const data = await res.json();
if (data.status === 'success') {
setTimeout(() => { btn.disabled = false; btn.textContent = '立即同步 ODS'; }, 2000);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!