Upload-Freigabe: URL-Shortener entfernt, einfaches Kopieren der Original-URL
This commit is contained in:
@@ -218,24 +218,20 @@ function UploadShareManager({ toast }) {
|
||||
setShortening(null);
|
||||
};
|
||||
|
||||
const copyLink = (shareId, token, shortUrl) => {
|
||||
// Kurz-URL vom Server nehmen (bereits beim Erstellen generiert), sonst Original
|
||||
const url = shortUrl || `${window.location.origin}/u/${token}`;
|
||||
// Synchron kopieren – kein await nötig
|
||||
const copyLink = (token) => {
|
||||
const url = `${window.location.origin}/u/${token}`;
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(url).catch(() => fallbackCopy(url));
|
||||
} else { fallbackCopy(url); }
|
||||
navigator.clipboard.writeText(url).catch(() => {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = url; ta.style.cssText='position:fixed;opacity:0.01';
|
||||
document.body.appendChild(ta); ta.focus(); ta.select();
|
||||
try { document.execCommand('copy'); } catch {}
|
||||
document.body.removeChild(ta);
|
||||
});
|
||||
}
|
||||
setCopied(token); setTimeout(()=>setCopied(null), 2500);
|
||||
};
|
||||
|
||||
const fallbackCopy = (text) => {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = text; ta.style.cssText = 'position:fixed;top:0;left:0;opacity:0.01';
|
||||
document.body.appendChild(ta); ta.focus(); ta.select();
|
||||
try { document.execCommand('copy'); } catch {}
|
||||
document.body.removeChild(ta);
|
||||
};
|
||||
|
||||
const loadLogs = () => {
|
||||
api('/upload-shares/logs').then(setLogs).catch(()=>{});
|
||||
setShowLogs(true);
|
||||
@@ -345,7 +341,7 @@ function UploadShareManager({ toast }) {
|
||||
<div style={{display:'flex',gap:5,flexShrink:0}}>
|
||||
{!!s.is_active && !expired && (
|
||||
<>
|
||||
<button onClick={()=>copyLink(s.id, s.token, s.short_url)}
|
||||
<button onClick={()=>copyLink(s.token)}
|
||||
style={{...S.btn(copied===s.token?'#4ecdc4':'#ffe66d',copied!==s.token),fontSize:10,padding:'4px 10px'}}>
|
||||
{copied===s.token?'✓ Kopiert':'📋 Link'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user