mirror of
https://github.com/shadoll/sLogos.git
synced 2026-08-28 11:33:29 +00:00
feat: Add image generation for SVG logos and improve clipboard functionality
- Added @resvg/resvg-js dependency for SVG to PNG/JPG conversion. - Implemented pregeneration of PNG and JPG images from SVG files in the scanLogos script. - Enhanced copy URL functionality in App.svelte to support modern clipboard API with fallbacks. - Removed unnecessary onCopy prop from LogoActions component and handled copy actions locally. - Introduced notification system for copy actions with success/error feedback. - Updated styles for action buttons and notifications for better user experience. - Cleaned up unused code and improved overall structure for clarity.
This commit is contained in:
+34
-6
@@ -83,13 +83,41 @@
|
||||
|
||||
function copyUrl(logoPath) {
|
||||
const url = `${window.location.origin}/${logoPath}`;
|
||||
navigator.clipboard.writeText(url)
|
||||
.then(() => {
|
||||
// Try modern clipboard API first
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(url)
|
||||
.then(() => {
|
||||
alert('URL copied to clipboard!');
|
||||
})
|
||||
.catch(err => {
|
||||
// Fallback: use execCommand for legacy support
|
||||
try {
|
||||
const input = document.createElement('input');
|
||||
input.value = url;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(input);
|
||||
alert('URL copied to clipboard!');
|
||||
} catch (fallbackErr) {
|
||||
// Final fallback: show prompt for manual copy
|
||||
window.prompt('Copy this URL:', url);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Fallback for non-secure context or missing clipboard API
|
||||
try {
|
||||
const input = document.createElement('input');
|
||||
input.value = url;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(input);
|
||||
alert('URL copied to clipboard!');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to copy URL: ', err);
|
||||
});
|
||||
} catch (fallbackErr) {
|
||||
window.prompt('Copy this URL:', url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function downloadLogo(logoPath, logoName) {
|
||||
|
||||
Reference in New Issue
Block a user