Commit
·
8374ff5
1
Parent(s):
5d0314c
(wip)update html
Browse files- templates/arena.html +45 -0
templates/arena.html
CHANGED
|
@@ -2018,3 +2018,48 @@
|
|
| 2018 |
});
|
| 2019 |
</script>
|
| 2020 |
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2018 |
});
|
| 2019 |
</script>
|
| 2020 |
{% endblock %}
|
| 2021 |
+
|
| 2022 |
+
{% block scripts %}
|
| 2023 |
+
{{ super() }}
|
| 2024 |
+
<script>
|
| 2025 |
+
// 1. 参考音色试听功能
|
| 2026 |
+
const voiceFileInput = document.getElementById('voice-file');
|
| 2027 |
+
const voicePreview = document.getElementById('voice-preview');
|
| 2028 |
+
voiceFileInput.addEventListener('change', function() {
|
| 2029 |
+
const file = this.files[0];
|
| 2030 |
+
if (file) {
|
| 2031 |
+
const url = URL.createObjectURL(file);
|
| 2032 |
+
voicePreview.src = url;
|
| 2033 |
+
voicePreview.style.display = 'inline-block';
|
| 2034 |
+
voicePreview.load();
|
| 2035 |
+
} else {
|
| 2036 |
+
voicePreview.src = '';
|
| 2037 |
+
voicePreview.style.display = 'none';
|
| 2038 |
+
}
|
| 2039 |
+
});
|
| 2040 |
+
|
| 2041 |
+
// 2. 阻止输入框Enter触发合成,只允许点击按钮合成
|
| 2042 |
+
const ttsForm = document.querySelector('#tts-tab form.input-container');
|
| 2043 |
+
const textInput = ttsForm.querySelector('.text-input');
|
| 2044 |
+
const synthBtn = ttsForm.querySelector('.synth-btn');
|
| 2045 |
+
|
| 2046 |
+
textInput.addEventListener('keydown', function(e) {
|
| 2047 |
+
if (e.key === 'Enter') {
|
| 2048 |
+
e.preventDefault(); // 阻止回车提交
|
| 2049 |
+
}
|
| 2050 |
+
});
|
| 2051 |
+
// 可选:防止form回车自动提交
|
| 2052 |
+
ttsForm.addEventListener('submit', function(e) {
|
| 2053 |
+
e.preventDefault(); // 阻止默认提交
|
| 2054 |
+
// 只有点击合成按钮时才触发合成
|
| 2055 |
+
if (document.activeElement === synthBtn || e.submitter === synthBtn) {
|
| 2056 |
+
// 这里调用原有的合成逻辑(如有)
|
| 2057 |
+
// 例如:triggerSynthesize();
|
| 2058 |
+
if (typeof window.triggerSynthesize === 'function') {
|
| 2059 |
+
window.triggerSynthesize();
|
| 2060 |
+
}
|
| 2061 |
+
}
|
| 2062 |
+
});
|
| 2063 |
+
</script>
|
| 2064 |
+
{% endblock %}
|
| 2065 |
+
|