|
|
|
|
|
|
|
|
|
|
|
|
|
function copyToClipboard(text, id) {
|
|
|
|
const textarea = document.createElement('textarea');
|
|
textarea.value = text;
|
|
textarea.style.position = 'fixed';
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
|
|
try {
|
|
document.execCommand('copy');
|
|
this.copiedId = id;
|
|
|
|
|
|
const Toast = Swal.mixin({
|
|
toast: true,
|
|
position: 'top-end',
|
|
showConfirmButton: false,
|
|
timer: 1500,
|
|
timerProgressBar: true,
|
|
didOpen: (toast) => {
|
|
toast.onmouseenter = Swal.stopTimer;
|
|
toast.onmouseleave = Swal.resumeTimer;
|
|
}
|
|
});
|
|
|
|
Toast.fire({
|
|
icon: 'success',
|
|
title: '已复制到剪贴板',
|
|
background: '#f0fdf4',
|
|
iconColor: '#16a34a'
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
|
this.copiedId = null;
|
|
}, 2000);
|
|
} catch (err) {
|
|
console.error('复制失败:', err);
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: '复制失败',
|
|
text: '请手动复制内容',
|
|
confirmButtonColor: '#0284c7'
|
|
});
|
|
} finally {
|
|
document.body.removeChild(textarea);
|
|
}
|
|
}
|
|
|
|
|
|
function showNotification(message, type = 'info') {
|
|
const event = new CustomEvent('show-notification', {
|
|
detail: { message, type }
|
|
});
|
|
window.dispatchEvent(event);
|
|
}
|
|
|
|
|
|
function totalKeyCount() {
|
|
|
|
if (this.currentView === 'valid') {
|
|
return this.apiKeys.filter(key => key.success === true).length;
|
|
} else if (this.currentView === 'invalid') {
|
|
return this.apiKeys.filter(key => key.success === false).length;
|
|
}
|
|
return this.apiKeys.length;
|
|
}
|
|
|
|
|
|
function matchesSearch(name, key, notes) {
|
|
if (!this.searchTerm) return true;
|
|
|
|
const searchLower = this.searchTerm.toLowerCase();
|
|
return (
|
|
(name && name.toLowerCase().includes(searchLower)) ||
|
|
(key && key.toLowerCase().includes(searchLower))
|
|
);
|
|
}
|
|
|