From 68b284b2c15ac5620ed59e8aa6402163ce84699c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=94=A6=E5=BC=BA?= <1061669148@qq.com> Date: Thu, 13 Mar 2025 08:17:15 +0800 Subject: [PATCH] feat: update HttpTTS link generation to use dynamic text and rate values, improve button label --- web/static/js/app.js | 12 ++++-------- web/templates/index.html | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/web/static/js/app.js b/web/static/js/app.js index 0be377f..d4da6cf 100644 --- a/web/static/js/app.js +++ b/web/static/js/app.js @@ -207,20 +207,16 @@ document.addEventListener('DOMContentLoaded', function() { // 复制HttpTTS链接按钮点击事件 copyHttpTtsLinkButton.addEventListener('click', function() { - const text = textInput.value.trim(); - if (!text) { - showCustomAlert('请输入要转换的文本', 'warning'); - return; - } - const voice = voiceSelect.value; const style = styleSelect.value; - const rate = rateInput.value; const pitch = pitchInput.value; const apiKey = apiKeyInput.value.trim(); + const text = "{{java.encodeURI(speakText)}}"; + const rate = "{{speakSpeed*4}}"; // 构建HttpTTS链接 - let httpTtsLink = `${window.location.origin}${config.basePath}/tts?t=${encodeURIComponent(text)}&v=${voice}&r=${rate}&p=${pitch}&s=${style}`; + let httpTtsLink = `${window.location.origin}${config.basePath}/tts?t=${text}&v=${voice}&r=${rate}&p=${pitch}&s=${style}`; + // 添加API Key参数(如果有) if (apiKey) { diff --git a/web/templates/index.html b/web/templates/index.html index 5d10bfd..55c7b6b 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1167,7 +1167,7 @@ - 复制HttpTTS链接 + 复制 HTTP TTS 链接