Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
data_report
/
daw
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8b0e6616
authored
Jul 08, 2026
by
江名洋
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 动态推导API路径并修正相对路径
1 parent
5005b25a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
app/static/js/common.js
app/templates/analysis.html
app/templates/harmony.html
app/static/js/common.js
View file @
8b0e661
...
@@ -4,6 +4,15 @@
...
@@ -4,6 +4,15 @@
注意: 不要删除这个注释。
注意: 不要删除这个注释。
*/
*/
// ========== 自动计算 API 基础路径 ==========
// 从浏览器地址栏 pathname 动态推导,兼容本地 /ods 和服务器 /daw/ods 两种场景
(
function
()
{
var
p
=
window
.
location
.
pathname
;
if
(
p
.
endsWith
(
'/'
))
p
=
p
.
slice
(
0
,
-
1
);
var
idx
=
p
.
lastIndexOf
(
'/'
);
window
.
API_BASE
=
p
.
substring
(
0
,
idx
)
+
'/api'
;
})();
// ========== 工具函数 ==========
// ========== 工具函数 ==========
function
fmtDate
(
d
)
{
function
fmtDate
(
d
)
{
return
`
${
d
.
getFullYear
()}
-
${
String
(
d
.
getMonth
()
+
1
).
padStart
(
2
,
'0'
)}
-
${
String
(
d
.
getDate
()).
padStart
(
2
,
'0'
)}
`
;
return
`
${
d
.
getFullYear
()}
-
${
String
(
d
.
getMonth
()
+
1
).
padStart
(
2
,
'0'
)}
-
${
String
(
d
.
getDate
()).
padStart
(
2
,
'0'
)}
`
;
...
@@ -22,8 +31,7 @@ let historyCache = {};
...
@@ -22,8 +31,7 @@ let historyCache = {};
// ========== 历史记录渲染 ==========
// ========== 历史记录渲染 ==========
async
function
fetchHistory
(
filterFn
)
{
async
function
fetchHistory
(
filterFn
)
{
try
{
try
{
const
apiBase
=
(
typeof
APP_ROOT
!==
'undefined'
?
APP_ROOT
:
'.'
)
+
'/api'
;
const
res
=
await
fetch
(
window
.
API_BASE
+
'/etl/history?limit=15'
);
const
res
=
await
fetch
(
apiBase
+
'/etl/history?limit=15'
);
const
history
=
await
res
.
json
();
const
history
=
await
res
.
json
();
const
tbody
=
document
.
getElementById
(
'history-tbody'
);
const
tbody
=
document
.
getElementById
(
'history-tbody'
);
if
(
!
tbody
)
return
false
;
if
(
!
tbody
)
return
false
;
...
...
app/templates/analysis.html
View file @
8b0e661
...
@@ -197,7 +197,7 @@
...
@@ -197,7 +197,7 @@
if
(
natStart
)
genForm
.
append
(
'nature_start_date'
,
natStart
);
if
(
natStart
)
genForm
.
append
(
'nature_start_date'
,
natStart
);
if
(
natEnd
)
genForm
.
append
(
'nature_end_date'
,
natEnd
);
if
(
natEnd
)
genForm
.
append
(
'nature_end_date'
,
natEnd
);
const
genRes
=
await
fetch
(
'../api
/analysis/generate'
,
{
method
:
'POST'
,
body
:
genForm
});
const
genRes
=
await
fetch
(
window
.
API_BASE
+
'
/analysis/generate'
,
{
method
:
'POST'
,
body
:
genForm
});
const
genData
=
await
genRes
.
json
();
const
genData
=
await
genRes
.
json
();
if
(
genData
.
status
===
'success'
)
{
if
(
genData
.
status
===
'success'
)
{
...
...
app/templates/harmony.html
View file @
8b0e661
...
@@ -98,8 +98,8 @@
...
@@ -98,8 +98,8 @@
</section>
</section>
</main>
</main>
<script>
var
APP_ROOT
=
'..'
;
</script>
<script>
<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'
,
()
=>
{
document
.
addEventListener
(
'DOMContentLoaded'
,
()
=>
{
const
fmt
=
d
=>
`
${
d
.
getFullYear
()}
-
${
String
(
d
.
getMonth
()
+
1
).
padStart
(
2
,
'0'
)}
-
${
String
(
d
.
getDate
()).
padStart
(
2
,
'0'
)}
`
;
const
fmt
=
d
=>
`
${
d
.
getFullYear
()}
-
${
String
(
d
.
getMonth
()
+
1
).
padStart
(
2
,
'0'
)}
-
${
String
(
d
.
getDate
()).
padStart
(
2
,
'0'
)}
`
;
const
now
=
new
Date
();
const
now
=
new
Date
();
...
@@ -176,7 +176,7 @@
...
@@ -176,7 +176,7 @@
if
(
hasFactory
)
uploadForm
.
append
(
'factory_file'
,
factoryFileInput
.
files
[
0
]);
if
(
hasFactory
)
uploadForm
.
append
(
'factory_file'
,
factoryFileInput
.
files
[
0
]);
if
(
hasValue
)
uploadForm
.
append
(
'value_file'
,
valueFileInput
.
files
[
0
]);
if
(
hasValue
)
uploadForm
.
append
(
'value_file'
,
valueFileInput
.
files
[
0
]);
const
uploadRes
=
await
fetch
(
'../api
/harmony/upload'
,
{
method
:
'POST'
,
body
:
uploadForm
});
const
uploadRes
=
await
fetch
(
window
.
API_BASE
+
'
/harmony/upload'
,
{
method
:
'POST'
,
body
:
uploadForm
});
const
uploadData
=
await
uploadRes
.
json
();
const
uploadData
=
await
uploadRes
.
json
();
if
(
uploadData
.
status
!==
'success'
)
{
if
(
uploadData
.
status
!==
'success'
)
{
throw
new
Error
(
uploadData
.
detail
||
'文件上传失败'
);
throw
new
Error
(
uploadData
.
detail
||
'文件上传失败'
);
...
@@ -191,7 +191,7 @@
...
@@ -191,7 +191,7 @@
if
(
sd
)
genForm
.
append
(
'start_date'
,
sd
);
if
(
sd
)
genForm
.
append
(
'start_date'
,
sd
);
if
(
ed
)
genForm
.
append
(
'end_date'
,
ed
);
if
(
ed
)
genForm
.
append
(
'end_date'
,
ed
);
const
genRes
=
await
fetch
(
'../api
/harmony/generate'
,
{
method
:
'POST'
,
body
:
genForm
});
const
genRes
=
await
fetch
(
window
.
API_BASE
+
'
/harmony/generate'
,
{
method
:
'POST'
,
body
:
genForm
});
const
genData
=
await
genRes
.
json
();
const
genData
=
await
genRes
.
json
();
if
(
genData
.
status
===
'success'
)
{
if
(
genData
.
status
===
'success'
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment