Improve voice turns, local commands and Spotify controls
This commit is contained in:
+21
-3
@@ -65,8 +65,14 @@ showHistory.onclick = async () => {
|
||||
};
|
||||
function renderSpotify(spotify) {
|
||||
spotifyStatus.textContent = !spotify.configured ? 'Spotify пока не настроен на сервере.' : spotify.connected ? 'Аккаунт подключён.' : 'Подключи аккаунт для управления музыкой.';
|
||||
const playback = spotify.playback;
|
||||
if (playback) {
|
||||
spotifyStatus.textContent += playback.online
|
||||
? ` Колонка онлайн${playback.active ? ', активна' : ', неактивна'}. ${playback.item?.name || ''}${playback.status === 'paused' ? ' — пауза' : ''}`
|
||||
: ` Колонка офлайн.${playback.lastPlayback?.item?.name ? ' Последний трек — ' + playback.lastPlayback.item.name + '.' : ''}`;
|
||||
}
|
||||
spotifyConnect.disabled = !spotify.configured;
|
||||
spotifyConnect.textContent = spotify.connected ? 'Подключить другой аккаунт' : 'Подключить Spotify';
|
||||
spotifyConnect.textContent = spotify.connected ? 'Переподключить Spotify' : 'Подключить Spotify';
|
||||
}
|
||||
showSettings.onclick = async () => {
|
||||
selectTab(false);
|
||||
@@ -88,7 +94,8 @@ form.onsubmit = async (event) => {
|
||||
const button = form.querySelector('button');
|
||||
button.disabled = true;
|
||||
try {
|
||||
const body = JSON.stringify(Object.fromEntries(new FormData(form)));
|
||||
const values = Object.fromEntries(new FormData(form));
|
||||
const body = JSON.stringify({ ...values, followUpMs: Number(values.followUpMs), activationSound: form.elements.activationSound.checked });
|
||||
await api('/settings', { method: 'PUT', body });
|
||||
status.textContent = 'Сохранено. Настройки вступят в силу со следующего запроса.';
|
||||
} catch (error) {
|
||||
@@ -119,7 +126,12 @@ if (!telegram?.initData) {
|
||||
} else {
|
||||
try {
|
||||
const data = await api();
|
||||
for (const [name, value] of Object.entries(data.settings)) form.elements.namedItem(name).value = value;
|
||||
for (const [name, value] of Object.entries(data.settings)) {
|
||||
const input = form.elements.namedItem(name);
|
||||
if (!input) continue;
|
||||
if (input.type === 'checkbox') input.checked = value === true;
|
||||
else input.value = value;
|
||||
}
|
||||
renderTurns(data.history);
|
||||
renderSpotify(data.spotify);
|
||||
status.textContent = '';
|
||||
@@ -128,3 +140,9 @@ if (!telegram?.initData) {
|
||||
status.textContent = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setInterval(async () => {
|
||||
if (settings.hidden || !telegram?.initData) return;
|
||||
try { renderSpotify((await api()).spotify); } catch {}
|
||||
}, 15000);
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
</select></label>
|
||||
<label>ID голоса ElevenLabs<input name="voiceId" required minlength="20" maxlength="20" spellcheck="false" autocomplete="off"></label>
|
||||
<label>Системный промпт<textarea name="systemPrompt" required maxlength="4000" rows="6"></textarea></label>
|
||||
<label>Окно продолжения, мс (0 отключает)<input name="followUpMs" type="number" required min="0" max="10000" step="500"></label>
|
||||
<label><input name="activationSound" type="checkbox"> Звук активации</label>
|
||||
<button class="primary">Сохранить</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -42,3 +42,5 @@ textarea { resize: vertical; }
|
||||
|
||||
.spotify-card { background: var(--surface); padding: 16px; border-radius: 15px; margin-bottom: 24px; }
|
||||
.spotify-card p { color: var(--muted); margin: 5px 0 12px; }
|
||||
|
||||
#form input[type="checkbox"] { width: auto; vertical-align: middle; }
|
||||
|
||||
Reference in New Issue
Block a user