From d216edd0e9931d71664f33e625cff6d8131a0fad Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 13 三月 2026 16:00:40 +0800
Subject: [PATCH] 重构: 实现前后端分离架构

---
 Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/wwwroot/js/site.js |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/wwwroot/js/site.js b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/wwwroot/js/site.js
index 4754930..7cecf88 100644
--- a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/wwwroot/js/site.js
+++ b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/wwwroot/js/site.js
@@ -1,8 +1,8 @@
 锘�// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
 // for details on configuring this project to bundle and minify static web assets.
 
-// API Base URL
-const API_BASE_URL = '/api';
+// API Base URL (configured server-side)
+const API_BASE_URL = window.API_BASE_URL || '/api';
 
 // Show toast notification
 function showToast(message, type = 'info') {
@@ -72,13 +72,17 @@
 
 // API call helper
 async function apiCall(url, options = {}) {
+    const { silent = false, ...fetchOptions } = options;
+
     try {
-        showLoading();
+        if (!silent) {
+            showLoading();
+        }
         const response = await fetch(url, {
-            ...options,
+            ...fetchOptions,
             headers: {
                 'Content-Type': 'application/json',
-                ...options.headers
+                ...fetchOptions.headers
             }
         });
 
@@ -89,10 +93,14 @@
 
         return await response.json();
     } catch (error) {
-        showToast(error.message, 'error');
+        if (!silent) {
+            showToast(error.message, 'error');
+        }
         throw error;
     } finally {
-        hideLoading();
+        if (!silent) {
+            hideLoading();
+        }
     }
 }
 

--
Gitblit v1.9.3