chore: adiciona README, .gitignore, remove binarios do repo
- Adiciona .gitignore com *.exe, *.tar.gz, *.dll, *.log - Remove binários commitados do tracking (58MB节省) - Adiciona README.md com instruções de setup, estrutura, comandos Tauri - Substitui location.reload() na impressão por iframe (preserva estado) - Substitui location.reload() no btn-limpar por reset de estado in-memory - Nota: security — service_role_key ainda no cliente desktop
This commit is contained in:
+40
-26
@@ -1329,37 +1329,44 @@ ${data.observacoes ? `<div class="obs">Obs: ${data.observacoes}</div>` : ''}
|
||||
}
|
||||
|
||||
function openPrintPreview(data) {
|
||||
// Gera HTML e injeta no body de uma div temporária para window.print()
|
||||
// Cria iframe oculto para impressão — NÃO substitui o DOM do app
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.style.cssText = 'position:fixed;right:0;bottom:0;width:0;height:0;border:none;';
|
||||
iframe.id = 'print-iframe';
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
const html = buildPrintHTML(data);
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
@media print {
|
||||
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 13px; }
|
||||
.no-print { display: none !important; }
|
||||
}
|
||||
.print-actions { position: fixed; top: 10px; right: 10px; z-index: 9999; }
|
||||
.print-actions button { padding: 8px 16px; cursor: pointer; background: #2563eb; color: #fff; border: none; border-radius: 4px; font-size: 14px; }
|
||||
.print-actions button:hover { background: #1d4ed8; }
|
||||
const printStyle = `
|
||||
<style>
|
||||
@media print {
|
||||
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 13px; }
|
||||
.no-print { display: none !important; }
|
||||
}
|
||||
body { padding: 10px; }
|
||||
.print-actions { text-align: center; margin-bottom: 10px; }
|
||||
.print-actions button { padding: 8px 16px; cursor: pointer; background: #e65100; color: #fff; border: none; border-radius: 4px; font-size: 14px; }
|
||||
</style>
|
||||
`;
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'print-actions no-print';
|
||||
actions.innerHTML = '<button onclick="window.print()">🖨️ Imprimir (Ctrl+P)</button>';
|
||||
|
||||
// Guarda conteúdo original
|
||||
const originalBody = document.body.innerHTML;
|
||||
const iframeDoc = iframe.contentWindow.document;
|
||||
iframeDoc.open();
|
||||
iframeDoc.write(`<!DOCTYPE html><html><head><title>Recibo</title>${printStyle}</head><body>${html}</body></html>`);
|
||||
iframeDoc.close();
|
||||
|
||||
document.body.innerHTML = html;
|
||||
document.head.appendChild(style);
|
||||
document.body.insertBefore(actions, document.body.firstChild);
|
||||
// Focus e imprime
|
||||
iframe.contentWindow.focus();
|
||||
iframe.contentWindow.print();
|
||||
|
||||
// Quando fechar print dialog, restaura
|
||||
const onAfterPrint = () => {
|
||||
document.body.innerHTML = originalBody;
|
||||
window.removeEventListener('afterprint', onAfterPrint);
|
||||
// Re-carrega scripts essenciais
|
||||
location.reload();
|
||||
// Remove iframe após impressão
|
||||
iframe.contentWindow.onafterprint = () => {
|
||||
document.body.removeChild(iframe);
|
||||
};
|
||||
window.addEventListener('afterprint', onAfterPrint);
|
||||
// Fallback: remove iframe após 5s (onafterprint pode não disparar em alguns browsers)
|
||||
setTimeout(() => {
|
||||
if (document.getElementById('print-iframe')) {
|
||||
document.body.removeChild(iframe);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function triggerWindowPrint() {
|
||||
@@ -1569,7 +1576,14 @@ document.getElementById('btn-recibo').addEventListener('click', async () => {
|
||||
document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||
if (!confirm('Limpar rascunho? Esta acção não pode ser revertida.')) return;
|
||||
localStorage.removeItem(LS_KEY);
|
||||
location.reload();
|
||||
// Reseta estado e re-renderiza sem reload
|
||||
estado = newEstado();
|
||||
estado.loja = val('f-loja') || 'União';
|
||||
estado.data = val('f-data') || new Date().toISOString().split('T')[0];
|
||||
calcular();
|
||||
renderAllTables();
|
||||
syncUI();
|
||||
showToast('Rascunho limpo.', 'info');
|
||||
});
|
||||
|
||||
document.getElementById('btn-anterior').addEventListener('click', async () => {
|
||||
|
||||
Reference in New Issue
Block a user