Upload-Freigabe: DickenDock-Text entfernt, Kurz-URL Button via is.gd
This commit is contained in:
@@ -170,6 +170,8 @@ function UploadShareManager({ toast }) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [copied, setCopied] = useState(null);
|
||||
const [sharePws, setSharePws] = useState({}); // {shareId: password} für Passwort-Kopieren
|
||||
const [shortUrls, setShortUrls] = useState({}); // {shareId: shortUrl}
|
||||
const [shortening, setShortening] = useState(null); // shareId being shortened
|
||||
|
||||
const load = () => api('/upload-shares').then(d=>{ setShares(d.shares||[]); setFolder(d.folder); }).catch(()=>{});
|
||||
useEffect(()=>{ load(); },[]);
|
||||
@@ -200,6 +202,24 @@ function UploadShareManager({ toast }) {
|
||||
toast('Entfernt');
|
||||
};
|
||||
|
||||
const shorten = async (shareId, token) => {
|
||||
setShortening(shareId);
|
||||
const url = `${window.location.origin}/u/${token}`;
|
||||
try {
|
||||
// is.gd – kostenloser URL-Shortener, kein API-Key nötig
|
||||
const r = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(url)}`);
|
||||
const short = await r.text();
|
||||
if (short.startsWith('http')) {
|
||||
setShortUrls(p=>({...p,[shareId]:short.trim()}));
|
||||
navigator.clipboard?.writeText(short.trim()).catch(()=>{});
|
||||
toast('Kurz-URL erstellt & kopiert ✓');
|
||||
} else {
|
||||
toast('Shortener nicht verfügbar','error');
|
||||
}
|
||||
} catch { toast('Shortener nicht erreichbar','error'); }
|
||||
setShortening(null);
|
||||
};
|
||||
|
||||
const copyLink = (token) => {
|
||||
const url = `${window.location.origin}/u/${token}`;
|
||||
navigator.clipboard?.writeText(url).then(()=>{ setCopied(token); setTimeout(()=>setCopied(null),2000); }).catch(()=>{
|
||||
@@ -324,6 +344,14 @@ function UploadShareManager({ toast }) {
|
||||
<button onClick={()=>{ navigator.clipboard?.writeText(sharePws[s.id]).then(()=>toast('Passwort kopiert ✓')).catch(()=>toast(sharePws[s.id])); }}
|
||||
style={{...S.btn('#ffe66d',true),fontSize:10,padding:'4px 10px'}}>🔑 PW</button>
|
||||
)}
|
||||
{shortUrls[s.id]
|
||||
? <button onClick={()=>{ navigator.clipboard?.writeText(shortUrls[s.id]).then(()=>toast('Kurz-URL kopiert ✓')).catch(()=>{}); }}
|
||||
style={{...S.btn('#4ecdc4',true),fontSize:10,padding:'4px 10px'}}>🔗 Kurz</button>
|
||||
: <button onClick={()=>shorten(s.id,s.token)} disabled={shortening===s.id}
|
||||
style={{background:'rgba(255,255,255,0.05)',border:'1px solid rgba(255,255,255,0.15)',borderRadius:6,color:'rgba(255,255,255,0.5)',cursor:shortening===s.id?'default':'pointer',fontFamily:'monospace',fontSize:10,padding:'4px 10px'}}>
|
||||
{shortening===s.id?'…':'🔗↓'}
|
||||
</button>
|
||||
}
|
||||
</>
|
||||
)}
|
||||
{!!s.is_active && (
|
||||
|
||||
Reference in New Issue
Block a user