feat: add copy link button for IFreeTime with event handling
This commit is contained in:
@@ -166,6 +166,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const downloadButton = document.getElementById('download');
|
const downloadButton = document.getElementById('download');
|
||||||
const copyLinkButton = document.getElementById('copyLink');
|
const copyLinkButton = document.getElementById('copyLink');
|
||||||
const copyHttpTtsLinkButton = document.getElementById('copyHttpTtsLink');
|
const copyHttpTtsLinkButton = document.getElementById('copyHttpTtsLink');
|
||||||
|
const copyIfreetimeLinkButton = document.getElementById('copyIfreetimeLink'); // 新增元素引用
|
||||||
const audioPlayer = document.getElementById('audioPlayer');
|
const audioPlayer = document.getElementById('audioPlayer');
|
||||||
const resultSection = document.getElementById('resultSection');
|
const resultSection = document.getElementById('resultSection');
|
||||||
const charCount = document.getElementById('charCount');
|
const charCount = document.getElementById('charCount');
|
||||||
@@ -384,6 +385,32 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
window.open(httpTtsLink, '_blank')
|
window.open(httpTtsLink, '_blank')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 复制爱阅记链接按钮点击事件
|
||||||
|
copyIfreetimeLinkButton.addEventListener('click', function () {
|
||||||
|
const text = "{{java.encodeURI(speakText)}}";
|
||||||
|
const voice = voiceSelect.value;
|
||||||
|
const displayName = voiceSelect.options[voiceSelect.selectedIndex].text;
|
||||||
|
const style = styleSelect.value;
|
||||||
|
const rate = "{{speakSpeed*4}}"
|
||||||
|
const pitch = pitchInput.value;
|
||||||
|
const apiKey = apiKeyInput.value.trim();
|
||||||
|
|
||||||
|
// 构建爱阅记链接
|
||||||
|
let ifreetimeLink = `${window.location.origin}${config.basePath}/ifreetime.json?&v=${voice}&r=${rate}&p=${pitch}&n=${displayName}`;
|
||||||
|
|
||||||
|
// 只有当style不为空时才添加
|
||||||
|
if (style) {
|
||||||
|
ifreetimeLink += `&s=${style}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加API Key参数(如果有)
|
||||||
|
if (apiKey) {
|
||||||
|
ifreetimeLink += `&api_key=${apiKey}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.open(ifreetimeLink, '_blank')
|
||||||
|
});
|
||||||
|
|
||||||
// 显示/隐藏API Key区域的按钮事件
|
// 显示/隐藏API Key区域的按钮事件
|
||||||
if (toggleApiKeyButton) {
|
if (toggleApiKeyButton) {
|
||||||
toggleApiKeyButton.addEventListener('click', function () {
|
toggleApiKeyButton.addEventListener('click', function () {
|
||||||
@@ -681,10 +708,10 @@ function showCustomAlert(message, type = 'info', title = '', duration = 3000) {
|
|||||||
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>';
|
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>';
|
||||||
break;
|
break;
|
||||||
case 'warning':
|
case 'warning':
|
||||||
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>';
|
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10-10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>';
|
||||||
break;
|
break;
|
||||||
default: // info
|
default: // info
|
||||||
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-11v6h2v-6h-2zm0-4v2h2V7h-2z"/></svg>';
|
iconSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10-10-4.477 10-10 10zm-1-11v6h2v-6h-2zm0-4v2h2V7h-2z"/></svg>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建通知内容
|
// 构建通知内容
|
||||||
|
|||||||
@@ -1154,6 +1154,16 @@
|
|||||||
</svg>
|
</svg>
|
||||||
导入阅读
|
导入阅读
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button id="copyIfreetimeLink"
|
||||||
|
class="btn-neo btn-neo-secondary btn-neo-icon inline-flex items-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-md transition hover:-translate-y-0.5 active:translate-y-0 shadow border border-slate-200">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||||
|
stroke="currentColor" stroke-width="2" class="w-5 h-5">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round"
|
||||||
|
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/>
|
||||||
|
</svg>
|
||||||
|
导入爱阅记
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user