wanshenmean
2026-03-13 d216edd0e9931d71664f33e625cff6d8131a0fad
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();
        }
    }
}