From f748e074fd1a3c3415014e6416d499eda2698089 Mon Sep 17 00:00:00 2001 From: Maxim Dolgolyov Date: Thu, 4 Jun 2026 20:58:14 +0300 Subject: [PATCH] =?UTF-8?q?feat(assistant):=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B0=D0=B9=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20=D1=81=D0=B2=D1=91=D1=80=D0=BD=D1=83=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раскрывается кнопкой «+ Добавить провайдера» (и автоматически при «Изм.»), сворачивается после сохранения/отмены. Окно компактнее в обычном режиме. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/js/admin/sections/assistant.js | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/js/admin/sections/assistant.js b/frontend/js/admin/sections/assistant.js index e6e0e8b..1f00033 100644 --- a/frontend/js/admin/sections/assistant.js +++ b/frontend/js/admin/sections/assistant.js @@ -84,15 +84,18 @@ '
' + '
' + '
' + - '
Добавить провайдера
' + - '
Пресет
' + - '' + - '
Название
' + - '
URL (chat/completions)
' + - '' + - '
Модель
' + - '
API-ключ
' + - '
'; + '' + + ''; host.appendChild(pc); // ── Настройки/статистика ── @@ -137,7 +140,8 @@ ''; }).join(''); - function clearForm() { editingId = null; Q('#asst-fhead').textContent = 'Добавить провайдера'; Q('#asst-name').value = ''; Q('#asst-url').value = ''; Q('#asst-model').value = ''; Q('#asst-key').value = ''; Q('#asst-key').placeholder = 'ключ'; Q('#asst-cancel').style.display = 'none'; toggleKilo(); } + function openForm(show) { Q('#asst-form').style.display = show ? 'flex' : 'none'; } + function clearForm() { editingId = null; Q('#asst-fhead').textContent = 'Новый провайдер'; Q('#asst-preset').value = ''; Q('#asst-name').value = ''; Q('#asst-url').value = ''; Q('#asst-model').value = ''; Q('#asst-key').value = ''; Q('#asst-key').placeholder = 'ключ'; toggleKilo(); openForm(false); } function toggleKilo() { var isKilo = /kilocode\.ai/.test(Q('#asst-url').value || ''); Q('#asst-kbox').style.display = isKilo ? '' : 'none'; @@ -163,7 +167,7 @@ editingId = id; Q('#asst-fhead').textContent = 'Изменить: ' + (p.name || ''); Q('#asst-name').value = p.name || ''; Q('#asst-url').value = p.url || ''; Q('#asst-model').value = p.model || ''; Q('#asst-key').value = ''; Q('#asst-key').placeholder = p.hasKey ? 'ключ сохранён — введите новый, чтобы заменить' : 'ключ'; - Q('#asst-cancel').style.display = ''; toggleKilo(); Q('#asst-name').focus(); + toggleKilo(); openForm(true); Q('#asst-form').scrollIntoView({ behavior: 'smooth', block: 'nearest' }); Q('#asst-name').focus(); } else if (act === 'test') { var res = Q('#asst-ptest'); res.innerHTML = 'Проверяю…'; try { var r = await LS.adminTestAssistant({ id: id }); res.innerHTML = r && r.ok ? '✓ Работает (' + esc(r.model || '') + '): ' + esc(String(r.sample || 'ответ получен')) + '' : '✗ ' + esc(String((r && (r.error || ('HTTP ' + r.status))) || 'ошибка').slice(0, 200)) + ''; } catch (e) { res.innerHTML = '✗ ' + esc(e.message || 'ошибка') + ''; } @@ -172,6 +176,7 @@ }); // форма + Q('#asst-ftoggle').addEventListener('click', function () { var open = Q('#asst-form').style.display !== 'none'; if (open) { clearForm(); } else { clearForm(); openForm(true); Q('#asst-name').focus(); } }); Q('#asst-preset').addEventListener('change', function () { var p = presets[Number(this.value)]; if (p) { Q('#asst-url').value = p.url; Q('#asst-model').value = p.model; if (!Q('#asst-name').value) Q('#asst-name').value = p.name; toggleKilo(); } }); Q('#asst-url').addEventListener('input', toggleKilo); Q('#asst-kmodels').addEventListener('change', function () { Q('#asst-model').value = this.value; });