From d6531e2a4ce9c8515ee5ee3b31943558d8bd2726 Mon Sep 17 00:00:00 2001 From: rever-tecnologia Date: Thu, 18 Dec 2025 14:06:53 -0300 Subject: [PATCH] fix(desktop): navega para URL do app Tauri ao resetar dispositivo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usa getCurrentWebviewWindow().navigate() para voltar para a pagina inicial do app Tauri em vez de ir para o servidor web 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/desktop/src/main.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsx index 0eeb40b..a2d345a 100644 --- a/apps/desktop/src/main.tsx +++ b/apps/desktop/src/main.tsx @@ -5,6 +5,7 @@ import { invoke } from "@tauri-apps/api/core" import { listen } from "@tauri-apps/api/event" import { Store } from "@tauri-apps/plugin-store" import { appLocalDataDir, join } from "@tauri-apps/api/path" +import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow" import { ExternalLink, Eye, EyeOff, Loader2, RefreshCw } from "lucide-react" import { ConvexReactClient } from "convex/react" import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs" @@ -782,8 +783,17 @@ const handleTokenRevoked = useCallback(async () => { setCodeStatus(null) setCompanyName("") setError("Este dispositivo foi resetado. Informe o código de provisionamento para reconectar.") - // Força recarregar a página inicial do app para sair de qualquer página web - window.location.href = "/" + // Força navegar de volta para a página inicial do app Tauri (não do servidor web) + try { + const webview = getCurrentWebviewWindow() + // URL do app Tauri em produção é http://tauri.localhost/, em dev é http://localhost:1420/ + const appUrl = import.meta.env.MODE === "production" ? "http://tauri.localhost/" : "http://localhost:1420/" + await webview.navigate(appUrl) + } catch (err) { + console.error("Falha ao navegar para página inicial do app", err) + // Fallback: tenta recarregar a página + window.location.reload() + } }, [store]) useEffect(() => {