/* ============================================ Proxy Component Управление прокси ============================================ */ import { api } from '../api/wails.js'; import { isWailsAvailable } from '../utils/helpers.js'; import { $ } from '../utils/dom.js'; // Класс для управления прокси export class ProxyManager { constructor() { this.proxiesData = []; this.mockData = [ { enable: true, external_domain: 'git.example.ru', local_address: '127.0.0.1', local_port: '3333', service_https_use: false, auto_https: true, status: 'active' }, { enable: true, external_domain: 'api.example.com', local_address: '127.0.0.1', local_port: '8080', service_https_use: true, auto_https: false, status: 'active' }, { enable: false, external_domain: 'test.example.net', local_address: '127.0.0.1', local_port: '5000', service_https_use: false, auto_https: false, status: 'disabled' } ]; } // Загрузить список прокси async load() { if (isWailsAvailable()) { this.proxiesData = await api.getProxyList(); } else { // Используем тестовые данные если Wails недоступен this.proxiesData = this.mockData; } this.render(); } // Отрисовать список прокси render() { const tbody = $('proxyTable')?.querySelector('tbody'); if (!tbody) return; tbody.innerHTML = ''; this.proxiesData.forEach((proxy, index) => { const row = document.createElement('tr'); const statusBadge = proxy.status === 'active' ? 'badge-online' : 'badge-offline'; const httpsBadge = proxy.service_https_use ? 'badge-yes">HTTPS' : 'badge-no">HTTP'; const autoHttpsBadge = proxy.auto_https ? 'badge-yes">Да' : 'badge-no">Нет'; const protocol = proxy.auto_https ? 'https' : 'http'; row.innerHTML = `
${proxy.external_domain} ${proxy.local_address}:${proxy.local_port}