feat: update HttpTTS link generation to use dynamic text and rate values, improve button label

This commit is contained in:
王锦强
2025-03-13 08:17:15 +08:00
parent 17fe8c9f8e
commit 68b284b2c1
2 changed files with 5 additions and 9 deletions

View File

@@ -207,20 +207,16 @@ document.addEventListener('DOMContentLoaded', function() {
// 复制HttpTTS链接按钮点击事件 // 复制HttpTTS链接按钮点击事件
copyHttpTtsLinkButton.addEventListener('click', function() { copyHttpTtsLinkButton.addEventListener('click', function() {
const text = textInput.value.trim();
if (!text) {
showCustomAlert('请输入要转换的文本', 'warning');
return;
}
const voice = voiceSelect.value; const voice = voiceSelect.value;
const style = styleSelect.value; const style = styleSelect.value;
const rate = rateInput.value;
const pitch = pitchInput.value; const pitch = pitchInput.value;
const apiKey = apiKeyInput.value.trim(); const apiKey = apiKeyInput.value.trim();
const text = "{{java.encodeURI(speakText)}}";
const rate = "{{speakSpeed*4}}";
// 构建HttpTTS链接 // 构建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参数如果有 // 添加API Key参数如果有
if (apiKey) { if (apiKey) {

View File

@@ -1167,7 +1167,7 @@
<path stroke-linecap="round" stroke-linejoin="round" <path stroke-linecap="round" stroke-linejoin="round"
d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/> d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>
</svg> </svg>
复制HttpTTS链接 复制 HTTP TTS 链接
</button> </button>
</div> </div>
</div> </div>