新增完整的Web UI管理控制台,包含以下主要功能: 1. 响应式设计的现代化界面 2. 实时监控系统状态和提供商统计 3. 配置管理功能,支持多种模型提供商 4. 文件上传和OAuth凭据管理 5. 路径路由调用示例和curl命令生成 6. 实时日志查看和事件流处理 7. 提供完整的UI文档说明 新增多个前端模块文件,包括导航、事件处理、文件上传等功能组件,并更新package.json添加multer依赖以支持文件上传功能。同时添加详细的UI_README.md文档说明所有功能特性和使用方法。
66 lines
No EOL
1.5 KiB
JavaScript
66 lines
No EOL
1.5 KiB
JavaScript
// 全局变量
|
|
let eventSource = null;
|
|
let autoScroll = true;
|
|
let logs = [];
|
|
|
|
// 提供商统计全局变量
|
|
let providerStats = {
|
|
totalRequests: 0,
|
|
totalErrors: 0,
|
|
activeProviders: 0,
|
|
healthyProviders: 0,
|
|
totalAccounts: 0,
|
|
lastUpdateTime: null,
|
|
providerTypeStats: {} // 详细按类型统计
|
|
};
|
|
|
|
// DOM元素
|
|
const elements = {
|
|
serverStatus: document.getElementById('serverStatus'),
|
|
refreshBtn: document.getElementById('refreshBtn'),
|
|
sections: document.querySelectorAll('.section'),
|
|
navItems: document.querySelectorAll('.nav-item'),
|
|
logsContainer: document.getElementById('logsContainer'),
|
|
clearLogsBtn: document.getElementById('clearLogs'),
|
|
toggleAutoScrollBtn: document.getElementById('toggleAutoScroll'),
|
|
saveConfigBtn: document.getElementById('saveConfig'),
|
|
resetConfigBtn: document.getElementById('resetConfig'),
|
|
toastContainer: document.getElementById('toastContainer'),
|
|
modelProvider: document.getElementById('modelProvider'),
|
|
};
|
|
|
|
// 定期刷新间隔
|
|
const REFRESH_INTERVALS = {
|
|
SYSTEM_INFO: 10000
|
|
};
|
|
|
|
// 导出所有常量
|
|
export {
|
|
eventSource,
|
|
autoScroll,
|
|
logs,
|
|
providerStats,
|
|
elements,
|
|
REFRESH_INTERVALS
|
|
};
|
|
|
|
// 更新函数
|
|
export function setEventSource(source) {
|
|
eventSource = source;
|
|
}
|
|
|
|
export function setAutoScroll(value) {
|
|
autoScroll = value;
|
|
}
|
|
|
|
export function addLog(log) {
|
|
logs.push(log);
|
|
}
|
|
|
|
export function clearLogs() {
|
|
logs = [];
|
|
}
|
|
|
|
export function updateProviderStats(newStats) {
|
|
providerStats = { ...providerStats, ...newStats };
|
|
} |