// 全局错误处理，防止JavaScript错误中断执行
window.onerror = function(msg, url, line, col, error) {
    console.error('JavaScript错误:', msg, 'at', url, 'line:', line);
    return true; // 阻止错误传播
};

let editingConfigId = null;
let allFields = [];
let currentPage = 1;
const pageSize = 20;

// 切换标签页
function switchTab(tabName, event) {
    document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
    document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
    
    if (event && event.target) {
        event.target.classList.add('active');
    }
    document.getElementById(`${tabName}-tab`).classList.add('active');

    if (tabName === 'config') {
        loadConfigs();
    } else if (tabName === 'generate') {
        loadGenerateConfigs();
    } else if (tabName === 'history') {
        loadHistory();
    }
}

// 加载配置列表
