mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
🆙 Fix the save / delete button in the camera editor
This commit is contained in:
@@ -112,18 +112,27 @@ export const CameraWidgetEditorView: FC<CameraWidgetEditorViewProps> = props =>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 'clear_effects':
|
case 'clear_effects':
|
||||||
setSelectedEffectName(null);
|
onCancel();
|
||||||
setSelectedEffects([]);
|
|
||||||
return;
|
return;
|
||||||
case 'download': {
|
case 'download': {
|
||||||
if(!currentPictureUrl || !currentPictureUrl.startsWith('data:image/')) return;
|
if(!currentPictureUrl) return;
|
||||||
|
|
||||||
|
const parts = currentPictureUrl.split(',');
|
||||||
|
const mime = parts[0].match(/:(.*?);/)?.[1] || 'image/png';
|
||||||
|
const binary = atob(parts[1]);
|
||||||
|
const bytes = new Uint8Array(binary.length);
|
||||||
|
for(let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
||||||
|
const blob = new Blob([ bytes ], { type: mime });
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
const w = window.open('', '_blank');
|
||||||
|
if(w)
|
||||||
|
{
|
||||||
|
w.document.title = 'camera_photo.png';
|
||||||
|
w.document.body.style.margin = '0';
|
||||||
|
w.document.body.innerHTML = `<img src="${ blobUrl }" style="max-width:100%"/>`;
|
||||||
|
}
|
||||||
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = currentPictureUrl;
|
|
||||||
link.download = 'camera_photo.png';
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
document.body.removeChild(link);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 'zoom':
|
case 'zoom':
|
||||||
|
|||||||
Reference in New Issue
Block a user