fix: HTML export tojson filter + authenticated file download (v0.14.1)
- Enable minijinja 'json' feature so the tojson filter is available in the Memories.html template (was causing 'unknown filter' render error) - Replace window.location.href downloads with fetch+blob so the Authorization header is sent (window.location.href caused 401) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ sysinfo = "0.32"
|
||||
image = "0.25"
|
||||
oxipng = "9"
|
||||
async_zip = { version = "0.0.17", features = ["tokio", "deflate"] }
|
||||
minijinja = "2"
|
||||
minijinja = { version = "2", features = ["json"] }
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
|
||||
@@ -72,13 +72,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFile(endpoint: string, filename: string) {
|
||||
const token = getToken();
|
||||
const res = await fetch(endpoint, {
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
||||
});
|
||||
if (!res.ok) return;
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function downloadZip() {
|
||||
window.location.href = '/api/v1/export/zip';
|
||||
downloadFile('/api/v1/export/zip', 'Gallery.zip');
|
||||
}
|
||||
|
||||
function downloadHtml() {
|
||||
if (localStorage.getItem(HTML_GUIDE_KEY)) {
|
||||
window.location.href = '/api/v1/export/html';
|
||||
downloadFile('/api/v1/export/html', 'Memories.zip');
|
||||
} else {
|
||||
showHtmlGuide = true;
|
||||
}
|
||||
@@ -87,7 +102,7 @@
|
||||
function confirmHtmlDownload() {
|
||||
localStorage.setItem(HTML_GUIDE_KEY, '1');
|
||||
showHtmlGuide = false;
|
||||
window.location.href = '/api/v1/export/html';
|
||||
downloadFile('/api/v1/export/html', 'Memories.zip');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user