fix: Use direct Gitea download URLs (no auth needed)
This commit is contained in:
@@ -47,43 +47,29 @@ async function loadRepos() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadRepo(repo: Repo) {
|
function downloadRepo(repo: Repo) {
|
||||||
downloading.value = repo.id
|
downloading.value = repo.id
|
||||||
try {
|
|
||||||
const [owner, repoName] = repo.fullName.split('/')
|
|
||||||
const response = await fetch(
|
|
||||||
`${import.meta.env.VITE_API_URL || 'https://api.ams.kronos-soulution.de/api'}/backup/download/${owner}/${repoName}?branch=${repo.branch}`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${localStorage.getItem('token')}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Download failed')
|
// Direct download via Gitea URL
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = repo.downloadUrl
|
||||||
|
link.download = `${repo.name}-${repo.branch}.zip`
|
||||||
|
link.target = '_blank'
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
|
||||||
const blob = await response.blob()
|
toast.add({ severity: 'success', summary: 'Download', detail: `${repo.name} wird heruntergeladen`, life: 3000 })
|
||||||
const url = window.URL.createObjectURL(blob)
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = url
|
|
||||||
a.download = `${repoName}-${repo.branch}.zip`
|
|
||||||
document.body.appendChild(a)
|
|
||||||
a.click()
|
|
||||||
window.URL.revokeObjectURL(url)
|
|
||||||
document.body.removeChild(a)
|
|
||||||
|
|
||||||
toast.add({ severity: 'success', summary: 'Download', detail: `${repo.name} heruntergeladen`, life: 3000 })
|
setTimeout(() => {
|
||||||
} catch {
|
|
||||||
toast.add({ severity: 'error', summary: 'Fehler', detail: 'Download fehlgeschlagen', life: 3000 })
|
|
||||||
} finally {
|
|
||||||
downloading.value = null
|
downloading.value = null
|
||||||
}
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadAll() {
|
async function downloadAll() {
|
||||||
for (const repo of repos.value) {
|
for (const repo of repos.value) {
|
||||||
await downloadRepo(repo)
|
downloadRepo(repo)
|
||||||
await new Promise(r => setTimeout(r, 500)) // kleine Pause zwischen Downloads
|
await new Promise(r => setTimeout(r, 1000))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user