fix: 所有 API 调用改为相对路径 /api,修复按钮无响应问题
This commit is contained in:
@@ -98,7 +98,7 @@ function toggleScheduler() {
|
|||||||
|
|
||||||
if (btn.classList.contains('stopped')) {
|
if (btn.classList.contains('stopped')) {
|
||||||
// 当前已停止,启动
|
// 当前已停止,启动
|
||||||
fetch(API_BASE + '/api/scheduler/start', {method: 'POST'})
|
fetch('/api/scheduler/start', {method: 'POST'})
|
||||||
.then(function(res) { return res.json(); })
|
.then(function(res) { return res.json(); })
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@@ -115,7 +115,7 @@ function toggleScheduler() {
|
|||||||
.catch(function(e) { showToast('错误: ' + e.message, 3000); });
|
.catch(function(e) { showToast('错误: ' + e.message, 3000); });
|
||||||
} else {
|
} else {
|
||||||
// 当前运行中,停止
|
// 当前运行中,停止
|
||||||
fetch(API_BASE + '/api/scheduler/stop', {method: 'POST'})
|
fetch('/api/scheduler/stop', {method: 'POST'})
|
||||||
.then(function(res) { return res.json(); })
|
.then(function(res) { return res.json(); })
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@@ -148,27 +148,27 @@ function updateToggleButton(running) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function captureNow() {
|
function captureNow() {
|
||||||
fetch(API_BASE + '/api/capture', {method: 'POST'})
|
fetch('/api/capture', {method: 'POST'})
|
||||||
.then(function(res) { return res.json(); })
|
.then(function(res) { return res.json(); })
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
showToast('Captured! ID: ' + data.image_id, 1500);
|
showToast('拍照成功!ID: ' + data.image_id, 1500);
|
||||||
refreshAll();
|
refreshAll();
|
||||||
} else {
|
} else {
|
||||||
showToast('Failed: ' + data.error, 3000);
|
showToast('拍照失败: ' + data.error, 3000);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function(e) { showToast('Error: ' + e.message, 3000); });
|
.catch(function(e) { showToast('错误: ' + e.message, 3000); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function analyzeUnanalyzed() {
|
function analyzeUnanalyzed() {
|
||||||
fetch(API_BASE + '/api/analyze/unanalyzed', {method: 'POST'})
|
fetch('/api/analyze/unanalyzed', {method: 'POST'})
|
||||||
.then(function(res) { return res.json(); })
|
.then(function(res) { return res.json(); })
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
showToast('Analyzed ' + data.results.length + ' images', 1500);
|
showToast('分析了 ' + data.results.length + ' 张图片', 1500);
|
||||||
refreshAll();
|
refreshAll();
|
||||||
})
|
})
|
||||||
.catch(function(e) { showToast('Error: ' + e.message, 3000); });
|
.catch(function(e) { showToast('错误: ' + e.message, 3000); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
|
|||||||
Reference in New Issue
Block a user