diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23e4fc8..3df5f4e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,19 @@
Formato baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/); versões seguem SemVer.
+## [0.2.0] - 2026-10-18
+
+### Adicionado
+- **Pré-visualização completa:** imagem (zoom), vídeo (MP4 e outros), áudio, PDF (pdf.js incluso, funciona offline), texto, Word/Excel/PowerPoint/OpenDocument, conteúdo de ZIP e hexadecimal; tela cheia com navegação por teclado (↑ ↓ ← → Espaço Esc). O conteúdo é lido sob demanda com suporte a Range, sem gravar em disco.
+- Seletor de tema **Auto / Claro / Escuro**; a escolha é salva e vale também no app reiniciado como administrador.
+- Nova identidade visual em verde-azulado, com logo de pixels que se juntam até formar um lobo-guará.
+
+### Corrigido
+- Reiniciar como administrador no Linux: no AppImage o executável fica num ponto de montagem inacessível ao root; agora usa o próprio `.AppImage`, mostra o motivo se falhar e fecha o app antigo só quando o novo abre.
+- Barra de ações inferior piscava a cada atualização; agora é criada uma vez e só atualiza o texto. O painel de progresso também deixou de ser recriado a cada ciclo.
+- FAT32 em mídias pequenas (menos de 65 525 clusters) não era reconhecido.
+- O tema não acompanhava a escolha ao abrir como root (o WebView do root usava outro tema do sistema).
+
## [0.1.0] - 2026-10-18
### Adicionado
diff --git a/Cargo.lock b/Cargo.lock
index 47262bf..d110d5a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -248,7 +248,7 @@ dependencies = [
[[package]]
name = "guara-cli"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"clap",
"ctrlc",
@@ -260,7 +260,7 @@ dependencies = [
[[package]]
name = "guara-core"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"libc",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index 5ebb7ce..4cc871c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/guara-core", "crates/guara-cli"]
[workspace.package]
-version = "0.1.0"
+version = "0.2.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/lucasrguerra/guara"
diff --git a/README.md b/README.md
index c7074cb..cdb8857 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
Guará
Recuperação de arquivos livre e gratuita para HD, SSD e pendrive. Terminal e interface gráfica · Windows, Linux e macOS · somente leitura na origem.
@@ -55,7 +55,9 @@ guara ui # interface no navegador (127.0.0.1 + t
## Interface gráfica
-App desktop (Tauri) com barra lateral de dispositivos, mapa do disco, resultados ao vivo, filtros por tipo, busca, pré-visualização de imagens, confiança por arquivo, pausar/continuar e salvar sessão. Tema claro/escuro automático e layout responsivo. O mesmo front-end roda em `guara ui`.
+App desktop (Tauri) com barra lateral de dispositivos, mapa do disco, resultados ao vivo, filtros por tipo, busca, confiança por arquivo, pausar/continuar e salvar sessão. Tema **Auto / Claro / Escuro** à sua escolha (lembrado também ao reiniciar como administrador) e layout responsivo. O mesmo front-end roda em `guara ui`.
+
+**Pré-visualização antes de recuperar** (lida direto do disco, sem gravar nada): imagens (com zoom), **vídeo (MP4/MOV/WebM)** e áudio com player, **PDF** (página a página), texto, documentos Word/Excel/PowerPoint/OpenDocument (texto extraído), conteúdo de ZIP e visão hexadecimal para o resto. Use ↑/↓ para percorrer a lista, Espaço/Enter ou duplo clique para abrir em tela cheia. Quando um arquivo não abre, o aviso ajuda a julgar se ele está danificado. A reprodução de vídeo depende dos codecs do seu sistema (no Linux, instale os plugins `gstreamer1.0-libav` e `gstreamer1.0-plugins-good`).
## Limites conhecidos (v0.1)
diff --git a/apps/gui/src-tauri/Cargo.toml b/apps/gui/src-tauri/Cargo.toml
index b59a2f1..ee04140 100644
--- a/apps/gui/src-tauri/Cargo.toml
+++ b/apps/gui/src-tauri/Cargo.toml
@@ -3,7 +3,7 @@
[package]
name = "guara-gui"
description = "Guará: interface gráfica de recuperação de arquivos"
-version = "0.1.0"
+version = "0.2.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/lucasrguerra/guara"
@@ -20,6 +20,9 @@ tauri-plugin-dialog = "2"
serde_json = "1"
guara-core = { path = "../../../crates/guara-core" }
+[target.'cfg(unix)'.dependencies]
+libc = "0.2"
+
[profile.release]
lto = "thin"
codegen-units = 1
diff --git a/apps/gui/src-tauri/icons/128x128.png b/apps/gui/src-tauri/icons/128x128.png
index b5f3037..98e2dc6 100644
Binary files a/apps/gui/src-tauri/icons/128x128.png and b/apps/gui/src-tauri/icons/128x128.png differ
diff --git a/apps/gui/src-tauri/icons/128x128@2x.png b/apps/gui/src-tauri/icons/128x128@2x.png
index 21850a2..d1768e8 100644
Binary files a/apps/gui/src-tauri/icons/128x128@2x.png and b/apps/gui/src-tauri/icons/128x128@2x.png differ
diff --git a/apps/gui/src-tauri/icons/32x32.png b/apps/gui/src-tauri/icons/32x32.png
index 0b3fe10..aae93ae 100644
Binary files a/apps/gui/src-tauri/icons/32x32.png and b/apps/gui/src-tauri/icons/32x32.png differ
diff --git a/apps/gui/src-tauri/icons/icon.ico b/apps/gui/src-tauri/icons/icon.ico
index cf03709..297ce64 100644
Binary files a/apps/gui/src-tauri/icons/icon.ico and b/apps/gui/src-tauri/icons/icon.ico differ
diff --git a/apps/gui/src-tauri/icons/icon.png b/apps/gui/src-tauri/icons/icon.png
index ae2a8d4..025426f 100644
Binary files a/apps/gui/src-tauri/icons/icon.png and b/apps/gui/src-tauri/icons/icon.png differ
diff --git a/apps/gui/src-tauri/icons/source.png b/apps/gui/src-tauri/icons/source.png
index ae2a8d4..025426f 100644
Binary files a/apps/gui/src-tauri/icons/source.png and b/apps/gui/src-tauri/icons/source.png differ
diff --git a/apps/gui/src-tauri/src/main.rs b/apps/gui/src-tauri/src/main.rs
index 1b39114..63b8219 100644
--- a/apps/gui/src-tauri/src/main.rs
+++ b/apps/gui/src-tauri/src/main.rs
@@ -16,40 +16,144 @@ async fn rpc(state: tauri::State<'_, State>, method: String, params: serde_json:
}
/// Reabre o app com privilégios de administrador (Linux/macOS). No Windows o
-/// manifesto já exige elevação.
+/// manifesto já exige elevação. O app novo encerra este quando abre; se a
+/// autorização falhar, a janela continua aqui e a interface mostra o motivo.
#[tauri::command]
-fn relaunch_elevated() -> Result<(), String> {
- let exe = std::env::current_exe().map_err(|e| e.to_string())?;
- #[cfg(target_os = "linux")]
+fn relaunch_elevated(app: tauri::AppHandle) -> Result<(), String> {
+ #[cfg(any(target_os = "linux", target_os = "macos"))]
{
- let mut cmd = std::process::Command::new("pkexec");
- cmd.arg("env");
- for k in ["DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS"] {
- if let Ok(v) = std::env::var(k) {
- cmd.arg(format!("{k}={v}"));
+ use tauri::Emitter;
+ let exe = elevated_exe()?;
+ let cfg = guara_core::settings::config_dir();
+ let log = std::env::temp_dir().join(format!("guara-elevate-{}.log", std::process::id()));
+ let _ = std::fs::write(&log, b"");
+ let out = std::fs::OpenOptions::new().append(true).open(&log).map_err(|e| e.to_string())?;
+ let err = out.try_clone().map_err(|e| e.to_string())?;
+ let pid = std::process::id().to_string();
+
+ #[cfg(target_os = "linux")]
+ let mut cmd = {
+ let mut c = std::process::Command::new("pkexec");
+ c.arg("/usr/bin/env");
+ for k in ["DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS", "GDK_BACKEND"] {
+ if let Ok(v) = std::env::var(k) {
+ c.arg(format!("{k}={v}"));
+ }
}
- }
- cmd.arg(exe);
- cmd.spawn().map_err(|e| format!("pkexec indisponível: {e}"))?;
- std::process::exit(0);
- }
- #[cfg(target_os = "macos")]
- {
- let script = format!("do shell script \"'{}' &> /dev/null &\" with administrator privileges", exe.display());
- std::process::Command::new("osascript").args(["-e", &script]).spawn().map_err(|e| e.to_string())?;
- std::process::exit(0);
+ c.arg(format!("GUARA_CONFIG_DIR={}", cfg.display()));
+ c.arg(format!("GUARA_REPLACE_PID={pid}"));
+ c.arg(&exe);
+ c
+ };
+ #[cfg(target_os = "macos")]
+ let mut cmd = {
+ let shell = format!(
+ "GUARA_CONFIG_DIR='{}' GUARA_REPLACE_PID={} '{}' >/dev/null 2>&1 &",
+ cfg.display(),
+ pid,
+ exe.display()
+ );
+ let script = format!("do shell script \"{}\" with administrator privileges", shell.replace('\\', "\\\\").replace('"', "\\\""));
+ let mut c = std::process::Command::new("osascript");
+ c.args(["-e", &script]);
+ c
+ };
+ cmd.stdout(out).stderr(err);
+ let mut child = cmd.spawn().map_err(|e| format!("não foi possível pedir privilégios: {e}"))?;
+ std::thread::spawn(move || {
+ // No Linux o pkexec só termina com sucesso quando o app elevado é fechado (e o app
+ // elevado já terá encerrado este processo). Qualquer falha antes disso vira aviso.
+ let status = child.wait();
+ if matches!(&status, Ok(s) if s.success()) {
+ let _ = std::fs::remove_file(&log);
+ return;
+ }
+ let detail = std::fs::read_to_string(&log).unwrap_or_default();
+ let msg = match status.ok().and_then(|s| s.code()) {
+ Some(126) => "Autorização cancelada.".to_string(),
+ Some(127) => "Não foi possível autenticar como administrador.".to_string(),
+ _ => format!("Não foi possível reiniciar como administrador. {}", detail.lines().last().unwrap_or("").trim()),
+ };
+ let _ = app.emit("elevate-failed", msg);
+ let _ = std::fs::remove_file(&log);
+ });
+ Ok(())
}
#[cfg(windows)]
{
- let _ = exe;
+ let _ = app;
Err("o Guará já roda como administrador no Windows".into())
}
}
+/// Caminho que o root consegue executar. No AppImage, `current_exe` aponta para
+/// dentro de um ponto de montagem FUSE do usuário, inacessível ao root: usa o
+/// próprio arquivo `.AppImage` (variável `APPIMAGE`).
+#[cfg(any(target_os = "linux", target_os = "macos"))]
+fn elevated_exe() -> Result {
+ if let Some(p) = std::env::var_os("APPIMAGE").map(std::path::PathBuf::from).filter(|p| p.is_file()) {
+ return Ok(p);
+ }
+ std::env::current_exe().map_err(|e| e.to_string())
+}
+
+/// Serve os arquivos recuperados para pré-visualização (`guara://localhost/file//`),
+/// com suporte a Range para vídeo/áudio/PDF, lendo direto da origem.
+fn serve_file(eng: &Engine, req: &tauri::http::Request>) -> tauri::http::Response> {
+ use tauri::http::Response;
+ const CAP: u64 = 8 * 1024 * 1024;
+ let mut it = req.uri().path().trim_start_matches("/file/").split('/');
+ let (job, id) = (it.next().unwrap_or(""), it.next().and_then(|s| s.parse::().ok()));
+ let err = |code: u16| Response::builder().status(code).header("Access-Control-Allow-Origin", "*").body(Vec::new()).unwrap();
+ let Some(id) = id else { return err(400) };
+ let range = req.headers().get("range").and_then(|v| v.to_str().ok());
+ let slice = match eng.file_slice(job, id, range) {
+ Ok(s) => s,
+ Err(code) => return err(code),
+ };
+ let total = slice.total;
+ let start = slice.start;
+ let want = slice.len();
+ let mut headers = slice.headers();
+ let partial = slice.partial || want > CAP;
+ let Ok(data) = slice.read_all(CAP) else { return err(500) };
+ let mut b = Response::builder().status(if partial { 206 } else { 200 });
+ headers.retain(|(k, _)| *k != "Content-Range");
+ for (k, v) in &headers {
+ b = b.header(*k, v);
+ }
+ if partial && !data.is_empty() {
+ b = b.header("Content-Range", format!("bytes {}-{}/{}", start, start + data.len() as u64 - 1, total));
+ }
+ b.body(data).unwrap_or_else(|_| err(500))
+}
+
fn main() {
+ let engine = Arc::new(Engine::new());
+ let for_protocol = engine.clone();
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
- .manage(State(Arc::new(Engine::new())))
+ .manage(State(engine))
+ .register_asynchronous_uri_scheme_protocol("guara", move |_ctx, request, responder| {
+ let eng = for_protocol.clone();
+ std::thread::spawn(move || responder.respond(serve_file(&eng, &request)));
+ })
+ .setup(|_app| {
+ // Quando abrimos elevados a pedido do app normal, ele fecha o app antigo.
+ #[cfg(unix)]
+ if let Some(pid) = std::env::var("GUARA_REPLACE_PID").ok().and_then(|p| p.parse::().ok()) {
+ std::thread::spawn(move || {
+ std::thread::sleep(std::time::Duration::from_millis(1200));
+ // SAFETY: só envia SIGTERM ao processo anterior do próprio usuário.
+ unsafe {
+ if libc::geteuid() == 0 {
+ libc::kill(pid, libc::SIGTERM);
+ }
+ }
+ });
+ }
+ Ok(())
+ })
.invoke_handler(tauri::generate_handler![rpc, relaunch_elevated])
.run(tauri::generate_context!())
.expect("erro ao iniciar o Guará");
diff --git a/apps/gui/src-tauri/tauri.conf.json b/apps/gui/src-tauri/tauri.conf.json
index f8365a5..d828477 100644
--- a/apps/gui/src-tauri/tauri.conf.json
+++ b/apps/gui/src-tauri/tauri.conf.json
@@ -1,9 +1,11 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Guara",
- "version": "0.1.0",
+ "version": "0.2.0",
"identifier": "dev.guara.app",
- "build": { "frontendDist": "../ui" },
+ "build": {
+ "frontendDist": "../ui"
+ },
"app": {
"withGlobalTauri": true,
"windows": [
@@ -16,7 +18,9 @@
"resizable": true
}
],
- "security": { "csp": "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'" }
+ "security": {
+ "csp": "default-src 'self'; img-src 'self' data: blob: guara: http://guara.localhost; media-src 'self' blob: guara: http://guara.localhost; connect-src 'self' ipc: http://ipc.localhost guara: http://guara.localhost; style-src 'self' 'unsafe-inline'; script-src 'self'; worker-src 'self' blob:; frame-src 'none'; object-src 'none'"
+ }
},
"bundle": {
"active": true,
@@ -24,6 +28,12 @@
"category": "Utility",
"shortDescription": "Recuperação de arquivos",
"longDescription": "Guará recupera arquivos apagados e partições perdidas de HD, SSD e pendrive, sempre em modo somente leitura na origem.",
- "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"]
+ "icon": [
+ "icons/32x32.png",
+ "icons/128x128.png",
+ "icons/128x128@2x.png",
+ "icons/icon.icns",
+ "icons/icon.ico"
+ ]
}
}
diff --git a/apps/gui/ui/app.css b/apps/gui/ui/app.css
index 70f6d37..cf17ae3 100644
--- a/apps/gui/ui/app.css
+++ b/apps/gui/ui/app.css
@@ -7,10 +7,10 @@
--text-2: #6e6e73;
--text-3: #8e8e93;
--line: rgba(0, 0, 0, 0.09);
- --accent: #d9541e;
- --accent-2: #ff8a3d;
+ --accent: #0f766e;
+ --accent-2: #14b8a6;
--accent-ink: #ffffff;
- --accent-soft: rgba(217, 84, 30, 0.1);
+ --accent-soft: rgba(15, 118, 110, 0.11);
--ok: #1a8f3c;
--warn: #b26a00;
--bad: #d12b2b;
@@ -34,10 +34,10 @@
--text-2: #a1a1a6;
--text-3: #7d7d82;
--line: rgba(255, 255, 255, 0.1);
- --accent: #ff7a3d;
- --accent-2: #ff9d5c;
- --accent-ink: #1a0b03;
- --accent-soft: rgba(255, 122, 61, 0.15);
+ --accent: #2dd4bf;
+ --accent-2: #5eead4;
+ --accent-ink: #042f2e;
+ --accent-soft: rgba(45, 212, 191, 0.15);
--ok: #32d74b;
--warn: #ffb340;
--bad: #ff6961;
@@ -48,6 +48,32 @@
}
}
+:root[data-theme="dark"] {
+ --bg: #000000;
+ --surface: #1c1c1e;
+ --surface-2: #232326;
+ --side: rgba(28, 28, 30, 0.8);
+ --text: #f5f5f7;
+ --text-2: #a1a1a6;
+ --text-3: #7d7d82;
+ --line: rgba(255, 255, 255, 0.1);
+ --accent: #2dd4bf;
+ --accent-2: #5eead4;
+ --accent-ink: #042f2e;
+ --accent-soft: rgba(45, 212, 191, 0.15);
+ --ok: #32d74b;
+ --warn: #ffb340;
+ --bad: #ff6961;
+ --ok-soft: rgba(50, 215, 75, 0.15);
+ --warn-soft: rgba(255, 179, 64, 0.15);
+ --bad-soft: rgba(255, 105, 97, 0.15);
+ --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
+}
+
+:root { color-scheme: light dark; }
+:root[data-theme="light"] { color-scheme: light; }
+:root[data-theme="dark"] { color-scheme: dark; }
+
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
@@ -211,7 +237,8 @@ input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px;
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; overflow-wrap: anywhere; }
-.actionbar { position: fixed; left: var(--side-w); right: 0; bottom: 0; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center; justify-content: center; background: var(--side); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-top: 1px solid var(--line); z-index: 5; animation: rise .3s; }
+.actionbar { position: fixed; left: var(--side-w); right: 0; bottom: 0; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center; justify-content: center; background: var(--side); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); border-top: 1px solid var(--line); z-index: 5; }
+.actionbar.enter { animation: rise .3s; }
.actionbar .info { color: var(--text-2); font-size: 14px; }
dialog { border: 0; border-radius: 22px; padding: 26px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
@@ -255,3 +282,53 @@ code, .mono { overflow-wrap: anywhere; font-family: var(--mono); font-size: .92e
@media (prefers-reduced-motion: reduce) {
* { animation: none !important; transition: none !important; }
}
+
+/* ------------------------------------------------------------ tema */
+.theme-switch { display: inline-flex; padding: 2px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); }
+.theme-switch button { border: 0; background: transparent; cursor: pointer; padding: 4px 10px; border-radius: 999px; font-size: 12px; color: var(--text-2); }
+.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); font-weight: 600; }
+
+/* ------------------------------------------------------------ pré-visualização */
+.viewer { position: relative; min-height: 160px; max-height: 52vh; overflow: auto; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; align-items: center; }
+.viewer.large { max-height: none; height: 100%; min-height: 0; }
+.viewer > * { max-width: 100%; }
+.pv-img { display: block; max-width: 100%; max-height: 46vh; object-fit: contain; margin: auto; }
+.viewer.large .pv-img { max-height: 100%; }
+.viewer.zoomable .pv-img { cursor: zoom-in; }
+.viewer.actual .pv-img { max-width: none; max-height: none; cursor: zoom-out; }
+.viewer.actual { align-items: flex-start; }
+.pv-video { width: 100%; max-height: 46vh; background: #000; border-radius: 12px; }
+.viewer.large .pv-video { max-height: 100%; height: 100%; }
+.pv-audio { width: calc(100% - 24px); margin: auto 12px; }
+.pv-note { width: 100%; padding: 8px 12px; font-size: 12.5px; color: var(--text-2); text-align: center; }
+.pv-note.bad { text-align: left; color: var(--text); background: var(--warn-soft); border-radius: 10px; margin: 8px; width: calc(100% - 16px); font-size: 13.5px; }
+.pv-loading { height: 160px; display: grid; place-items: center; width: 100%; }
+.pv-loading i { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
+@keyframes spin { to { transform: rotate(360deg); } }
+.pv-text, .pv-hex { margin: 0; padding: 12px 14px; width: 100%; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); text-align: left; }
+.pv-hex { white-space: pre; overflow-x: auto; overflow-wrap: normal; font-size: 12px; }
+.pv-hex .o { color: var(--text-3); } .pv-hex .a { color: var(--accent); }
+.pv-page { width: 100%; background: var(--surface); padding: 18px 22px; font-family: Georgia, "Times New Roman", serif; font-size: 14px; line-height: 1.6; text-align: left; }
+.pv-page p { margin: 0 0 .8em; white-space: pre-wrap; } .pv-page h4 { margin: 1em 0 .4em; font-family: var(--font); font-size: 16px; }
+.pv-sheet { width: 100%; overflow: auto; text-align: left; }
+.pv-sheet table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
+.pv-sheet th, .pv-sheet td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
+.pv-sheet th { background: var(--surface); color: var(--text-3); font-weight: 500; position: sticky; top: 0; }
+.pv-slide { width: calc(100% - 20px); margin: 10px; padding: 14px 16px; background: var(--surface); border-radius: 10px; box-shadow: 0 0 0 1px var(--line); text-align: left; }
+.pv-slide small { color: var(--text-3); } .pv-slide h4 { margin: 4px 0 6px; font-size: 16px; } .pv-slide p { margin: 0 0 4px; font-size: 13.5px; }
+.pv-zip { list-style: none; margin: 0; padding: 4px 0; width: 100%; text-align: left; font-size: 13px; }
+.pv-zip li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 14px; border-bottom: 1px solid var(--line); }
+.pv-zip li span { overflow-wrap: anywhere; } .pv-zip small { color: var(--text-3); flex: none; }
+.pv-pdfbar { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: center; justify-content: center; padding: 6px; width: 100%; background: var(--side); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
+.pv-pdfbar .pg { font-size: 13px; color: var(--text-2); min-width: 110px; text-align: center; }
+.pv-pdfwrap { padding: 8px; } .pv-canvas { display: block; background: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .25); }
+
+dialog.lightbox { width: min(1180px, 96vw); height: min(90vh, 920px); padding: 0; display: none; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
+dialog.lightbox[open] { display: grid; }
+.lb-head, .lb-foot { display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
+.lb-head { border-bottom: 1px solid var(--line); } .lb-foot { border-top: 1px solid var(--line); flex-wrap: wrap; justify-content: space-between; }
+.lb-head .ttl { flex: 1; min-width: 0; } .lb-head .ttl b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .lb-head .ttl small { color: var(--text-2); }
+.lb-body { padding: 12px; min-height: 0; }
+
+.hero-logo { width: min(440px, 80%); height: auto; display: block; margin: 0 0 22px -4px; }
+.pill.accent { background: var(--accent-soft); color: var(--accent); }
diff --git a/apps/gui/ui/app.js b/apps/gui/ui/app.js
index 00b26b7..71ab29a 100644
--- a/apps/gui/ui/app.js
+++ b/apps/gui/ui/app.js
@@ -1,6 +1,8 @@
// Guará — interface. Fala com o núcleo por `rpc(método, parâmetros)`:
// • app Tauri: invoke('rpc') • modo `guara ui`: POST /rpc/ com token.
+import { renderPreview, kindOf, KIND_LABEL } from './preview.js';
+
const tauri = window.__TAURI__;
const params = new URLSearchParams(location.search);
let token = params.get('token');
@@ -21,6 +23,32 @@ async function rpc(method, p = {}) {
return body;
}
+const isWin = /Windows/i.test(navigator.userAgent);
+const fileBase = tauri ? (isWin ? 'http://guara.localhost' : 'guara://localhost') : '';
+const fileUrl = (job, id) => `${fileBase}/file/${job}/${id}` + (tauri ? '' : `?t=${encodeURIComponent(token || '')}`);
+
+// Atualiza o HTML só quando mudou (evita piscar e perder o foco/hover).
+function setHTML(el, html) {
+ if (!el || el._h === html) return false;
+ el._h = html;
+ el.innerHTML = html;
+ return true;
+}
+
+// ------------------------------------------------------------------ tema
+function applyTheme(t) {
+ const root = document.documentElement;
+ if (t === 'light' || t === 'dark') root.dataset.theme = t; else delete root.dataset.theme;
+ document.querySelectorAll('[data-theme-pick]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.themePick === (t || 'auto'))));
+}
+try { applyTheme(localStorage.getItem('guara-theme') || 'auto'); } catch { applyTheme('auto'); }
+document.querySelectorAll('[data-theme-pick]').forEach((b) => (b.onclick = async () => {
+ const t = b.dataset.themePick;
+ applyTheme(t);
+ try { localStorage.setItem('guara-theme', t); } catch { /* sem armazenamento */ }
+ try { await rpc('settings_set', { theme: t }); } catch { /* segue só com o armazenamento local */ }
+}));
+
// ------------------------------------------------------------------ utilidades
const $ = (s, el = document) => el.querySelector(s);
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
@@ -173,7 +201,7 @@ function renderHome() {
S.device = null; S.job = null;
renderSide();
main.innerHTML = `
-
Encontre o que você achou que tinha perdido.
+
Encontre o que você achou que tinha perdido.
Escolha um disco, SSD ou pendrive ao lado. O Guará lê tudo — arquivos apagados, partições perdidas e espaço não particionado — sem escrever nada no disco de origem.
Uma varredura, tudo junto
Metadados do sistema de arquivos e busca por assinatura na mesma passada, sem duplicatas.
`;
- $('#selFiltered')?.addEventListener('click', () => { S.allFiltered = true; paintList(); });
- $('#recSel')?.addEventListener('click', () => recover(S.allFiltered ? { filter: currentFilter() } : { ids: [...S.selected] }));
- $('#recAll')?.addEventListener('click', () => recover({ filter: currentFilter() }));
+ ? '' : '';
+ const inner = `${n ? `${n.toLocaleString('pt-BR')} selecionado(s)` : `${S.total.toLocaleString('pt-BR')} arquivo(s) na lista`}${moreOffer}
+ ${n ? '' : ''}`;
+ let bar = host.firstElementChild;
+ if (!bar) {
+ // A barra é criada uma vez (com animação de entrada) e depois só tem o texto atualizado.
+ host.innerHTML = '';
+ bar = host.firstElementChild;
+ bar.onclick = (e) => {
+ const act = e.target.closest('[data-bar]')?.dataset.bar;
+ if (act === 'all') { S.allFiltered = true; $('#table')._h = null; paintList(); }
+ else if (act === 'sel') recover(S.allFiltered ? { filter: currentFilter() } : { ids: [...S.selected] });
+ else if (act === 'rec') recover({ filter: currentFilter() });
+ };
+ }
+ setHTML(bar, inner);
}
function currentFilter() {
@@ -540,6 +646,8 @@ async function openJobFromList(s) { openJob(s); }
const v = await rpc('version');
$('#versionTag').textContent = `v${v.version}`;
S.defaults = await rpc('defaults');
+ try { const st = await rpc('settings_get'); if (st?.theme) { applyTheme(st.theme); try { localStorage.setItem('guara-theme', st.theme); } catch { /* */ } } } catch { /* usa o local */ }
+ tauri?.event?.listen?.('elevate-failed', (e) => { toast(String(e.payload || 'Não foi possível reiniciar como administrador')); });
} catch (e) {
main.innerHTML = `
${warnSvg}
Não foi possível falar com o núcleo do Guará: ${esc(e.message)}. Se abriu esta página manualmente, use o endereço completo exibido pelo comando guara ui (ele inclui o token).