feat(desktop): add Tauri updater (GitHub Releases), updater UI button, hide PowerShell windows; fix Windows inventory arrays and activation; improve metrics parsing; branding rename to Raven across app; avoid localhost fallback in auth-server; inject APP_URL/AUTH_URL in stack

This commit is contained in:
Esdras Renan 2025-10-10 20:39:39 -03:00
parent eb5f39100f
commit 418599ef62
18 changed files with 127 additions and 34 deletions

View file

@ -2,7 +2,7 @@ import { useEffect, useState } from "react"
import { createRoot } from "react-dom/client"
import { invoke } from "@tauri-apps/api/core"
import { Store } from "@tauri-apps/plugin-store"
import { ExternalLink, Eye, EyeOff } from "lucide-react"
import { ExternalLink, Eye, EyeOff, GalleryVerticalEnd, RefreshCw } from "lucide-react"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs"
import { cn } from "./lib/utils"
@ -127,6 +127,7 @@ function App() {
const [company, setCompany] = useState("")
const [collabEmail, setCollabEmail] = useState("")
const [collabName, setCollabName] = useState("")
const [updating, setUpdating] = useState(false)
useEffect(() => {
(async () => {
@ -241,13 +242,38 @@ function App() {
}
}
async function checkForUpdates() {
try {
setUpdating(true)
const { check } = await import("@tauri-apps/plugin-updater")
const update = await check()
if (update && (update as any).available) {
// download and install then relaunch
await (update as any).downloadAndInstall()
const { relaunch } = await import("@tauri-apps/plugin-process")
await relaunch()
} else {
alert("Nenhuma atualização disponível.")
}
} catch (error) {
console.error("Falha ao verificar atualizações", error)
alert("Falha ao verificar atualizações.")
} finally {
setUpdating(false)
}
}
return (
<div className="min-h-screen grid place-items-center p-6">
<div className="w-full max-w-[720px] rounded-2xl border border-slate-200 bg-white p-6 shadow-sm">
<div className="flex items-start justify-between gap-3">
<h1 className="text-xl font-semibold">Sistema de Chamados Agente Desktop</h1>
<div className="mb-2 flex items-center justify-between gap-3">
<div className="flex items-center gap-2 text-xl font-semibold text-neutral-900">
<span className="flex size-6 items-center justify-center rounded-md bg-black text-white"><GalleryVerticalEnd className="size-4" /></span>
Sistema de chamados
</div>
<StatusBadge status={status} />
</div>
<h1 className="text-base font-semibold text-slate-800">Agente Desktop</h1>
{error ? <p className="mt-3 rounded-md bg-rose-50 p-2 text-sm text-rose-700">{error}</p> : null}
{!token ? (
<div className="mt-4 space-y-3">
@ -263,7 +289,7 @@ function App() {
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">Empresa (slug opcional)</label>
<input className="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm" placeholder="ex.: tenant-atlas" value={company} onChange={(e)=>setCompany(e.target.value)} />
<input className="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm" placeholder="ex.: atlas-engenharia" value={company} onChange={(e)=>setCompany(e.target.value)} />
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">Colaborador (e-mail)</label>
@ -360,11 +386,21 @@ function App() {
<label className="label">Nome do colaborador (opcional)</label>
<input className="input" placeholder="Nome completo" value={collabName} onChange={(e)=>setCollabName(e.target.value)} />
</div>
<div className="grid gap-2">
<label className="label">Atualizações</label>
<button onClick={checkForUpdates} disabled={updating} className={cn("btn btn-outline inline-flex items-center gap-2", updating && "opacity-60")}>
<RefreshCw className="size-4" /> Verificar atualizações
</button>
</div>
</TabsContent>
</Tabs>
</div>
)}
</div>
<div className="mt-6 flex justify-center">
<img src={`${appUrl}/rever-8.png`} alt="Logotipo Rever Tecnologia" width={110} height={110} className="h-[3.45rem] w-auto" />
</div>
</div>
</div>
)
}