Origem: D:/Documents/Github/OllaHub Arquivos omitidos (segredos, bancos de dados, logs, >50 MB): 0
This commit is contained in:
1 parent
a7cbd1a3b4
commit
861af0bb9f
217 files changed
+39421
-1340
No files matched your search
+724
-751
File diff suppressed because it is too large.
Load diff
@@ -4,13 +4,10 @@ import "./globals.css";
|
||||
import { ThemeProvider } from "@/components/theme-provider";
|
||||
import { AppUpdaterProvider } from "@/components/app-updater-provider";
|
||||
import { KeyboardShortcuts } from "@/components/keyboard-shortcuts";
|
||||
<<<<<<< HEAD
|
||||
import { DownloadProvider } from "@/contexts/download-context";
|
||||
import { GlobalDownloadStatusBar } from "@/components/global-download-status-bar";
|
||||
import { OllamaHealthProvider } from "@/contexts/ollama-health-context";
|
||||
import { ServiceInterruptionOverlay } from "@/components/ui/service-interruption-overlay";
|
||||
=======
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -47,7 +44,6 @@ export default function RootLayout({
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
>
|
||||
<<<<<<< HEAD
|
||||
<OllamaHealthProvider>
|
||||
<DownloadProvider>
|
||||
<KeyboardShortcuts />
|
||||
@@ -57,11 +53,6 @@ export default function RootLayout({
|
||||
<ServiceInterruptionOverlay />
|
||||
</DownloadProvider>
|
||||
</OllamaHealthProvider>
|
||||
=======
|
||||
<KeyboardShortcuts />
|
||||
{children}
|
||||
<AppUpdaterProvider />
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+22
-130
@@ -1,6 +1,5 @@
|
||||
'use client';
|
||||
|
||||
<<<<<<< HEAD
|
||||
import { TitleBar } from "@/components/titlebar";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -9,29 +8,15 @@ import { useSettingsStore } from "@/store/settings-store";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export default function Home() {
|
||||
=======
|
||||
import { useSetupCheck } from "@/hooks/use-setup-check";
|
||||
import { Hero } from "@/components/landing/hero";
|
||||
import { InstallModal } from "@/components/modals/install-modal";
|
||||
import { StoppedCard } from "@/components/landing/stopped-card";
|
||||
import { WelcomeNotification } from "@/components/notifications/welcome-notification";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, startTransition } from "react";
|
||||
|
||||
export default function Home() {
|
||||
const { status, ollamaStatus, checkingStep, recheck } = useSetupCheck();
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
const router = useRouter();
|
||||
const { setSetupCompleted } = useSettingsStore();
|
||||
const [isHydrated, setIsHydrated] = useState(false);
|
||||
const [isChecking, setIsChecking] = useState(true);
|
||||
|
||||
|
||||
// Refs para evitar loops e execuções múltiplas
|
||||
const hasCheckedRef = useRef(false);
|
||||
const isRedirectingRef = useRef(false);
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Hydration check: aguardar Zustand carregar do localStorage
|
||||
useEffect(() => {
|
||||
setIsHydrated(true);
|
||||
@@ -45,48 +30,48 @@ export default function Home() {
|
||||
|
||||
const performCheck = async () => {
|
||||
if (isRedirectingRef.current) return; // Evitar múltiplos redirecionamentos
|
||||
|
||||
|
||||
setIsChecking(true);
|
||||
|
||||
|
||||
try {
|
||||
// 1. Verificação Real do Sistema (Fonte da Verdade)
|
||||
const isOllamaIntact = await invoke<boolean>('verify_ollama_integrity_command');
|
||||
|
||||
|
||||
// Ler isSetupCompleted diretamente do store (não usar como dependência)
|
||||
const currentSetupStatus = useSettingsStore.getState().isSetupCompleted;
|
||||
|
||||
|
||||
if (!isOllamaIntact) {
|
||||
// Se o motor não existe, força o setup, não importa o que o storage diga
|
||||
console.warn("Integridade do Ollama falhou. Redirecionando para Setup.");
|
||||
|
||||
|
||||
if (!isRedirectingRef.current) {
|
||||
isRedirectingRef.current = true;
|
||||
// Resetar flag de setup se Ollama não está íntegro (ANTES de redirecionar)
|
||||
setSetupCompleted(false);
|
||||
|
||||
|
||||
// Pequeno delay para garantir que o estado seja persistido no localStorage
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
startTransition(() => {
|
||||
|
||||
startTransition(() => {
|
||||
router.replace('/setup');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Verificação de Fluxo de UI (apenas se Ollama está OK)
|
||||
if (!isRedirectingRef.current) {
|
||||
isRedirectingRef.current = true;
|
||||
|
||||
|
||||
if (currentSetupStatus) {
|
||||
startTransition(() => {
|
||||
startTransition(() => {
|
||||
router.replace('/chat');
|
||||
});
|
||||
} else {
|
||||
startTransition(() => {
|
||||
});
|
||||
} else {
|
||||
startTransition(() => {
|
||||
router.replace('/setup');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Falha crítica no check de inicialização", e);
|
||||
@@ -97,7 +82,7 @@ export default function Home() {
|
||||
|
||||
// Pequeno delay para garantir que o estado seja persistido no localStorage
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
|
||||
startTransition(() => {
|
||||
router.replace('/setup');
|
||||
});
|
||||
@@ -125,49 +110,6 @@ export default function Home() {
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">Aguarde um momento...</span>
|
||||
</div>
|
||||
=======
|
||||
// Redirecionar automaticamente se tudo estiver pronto
|
||||
useEffect(() => {
|
||||
if (status === 'ready') {
|
||||
const setupComplete = localStorage.getItem("ollahub_setup_complete");
|
||||
|
||||
// Se setup não foi marcado como completo, marcar agora
|
||||
if (!setupComplete) {
|
||||
localStorage.setItem("ollahub_setup_complete", "true");
|
||||
}
|
||||
|
||||
// Redirecionar para chat imediatamente (startTransition já garante não-bloqueio)
|
||||
startTransition(() => {
|
||||
router.push("/chat");
|
||||
});
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [status, router]);
|
||||
|
||||
const handleStart = () => {
|
||||
const setupComplete = localStorage.getItem("ollahub_setup_complete");
|
||||
if (setupComplete) {
|
||||
startTransition(() => {
|
||||
router.push("/chat");
|
||||
});
|
||||
} else {
|
||||
startTransition(() => {
|
||||
router.push("/setup");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Mostrar loading durante verificação
|
||||
if (status === 'checking') {
|
||||
return (
|
||||
<div className="flex h-screen w-full items-center justify-center bg-background">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<span className="text-sm font-medium text-foreground">{checkingStep}</span>
|
||||
<span className="text-xs text-muted-foreground">Aguarde um momento...</span>
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -176,67 +118,17 @@ export default function Home() {
|
||||
|
||||
// Após verificação, mostrar loading de redirecionamento (não deve aparecer por muito tempo)
|
||||
return (
|
||||
<<<<<<< HEAD
|
||||
<div className="h-screen w-full bg-background overflow-hidden flex flex-col">
|
||||
<TitleBar />
|
||||
<div className="flex-1 flex items-center justify-center pt-8">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<span className="text-sm font-medium text-foreground">Redirecionando...</span>
|
||||
<span className="text-xs text-muted-foreground">Aguarde um momento...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
=======
|
||||
<main className="flex min-h-screen flex-col items-center justify-center p-4 bg-background text-foreground transition-colors duration-300">
|
||||
{/* Notificação de boas-vindas */}
|
||||
<WelcomeNotification />
|
||||
|
||||
{/* Layout for Ready State - Redirecionamento automático */}
|
||||
{status === 'ready' && (
|
||||
<div className="flex h-screen w-full items-center justify-center bg-background">
|
||||
<div className="flex flex-col items-center gap-4 animate-in fade-in duration-300">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<span className="text-sm font-medium text-foreground">Tudo pronto!</span>
|
||||
<span className="text-xs text-muted-foreground">Redirecionando para o chat...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Layout for Needs Setup State */}
|
||||
{status === 'needs_setup' && ollamaStatus === 'running' && (
|
||||
<Hero onStart={handleStart} />
|
||||
)}
|
||||
|
||||
{/* Layout for Stopped State */}
|
||||
{status === 'needs_setup' && ollamaStatus === 'installed_stopped' && (
|
||||
<div className="flex flex-col items-center gap-8 animate-in fade-in slide-in-from-bottom-4 duration-500">
|
||||
<div className="text-center space-y-2">
|
||||
<h1 className="text-3xl font-bold tracking-tighter">OllaHub</h1>
|
||||
<p className="text-muted-foreground">Detectamos o Ollama, mas ele não está rodando.</p>
|
||||
</div>
|
||||
<StoppedCard onCheckAgain={recheck} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Layout for Not Installed State (Background + Modal) */}
|
||||
{status === 'needs_ollama' && (
|
||||
<>
|
||||
<div className="opacity-20 pointer-events-none blur-sm">
|
||||
<Hero onStart={() => {}} />
|
||||
</div>
|
||||
{/* Hero is shown in background, modal is open */}
|
||||
<InstallModal
|
||||
open={true}
|
||||
onCheckAgain={recheck}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, lazy, Suspense } from 'react';
|
||||
import { useState, useEffect, lazy, Suspense } from 'react';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
@@ -37,8 +36,6 @@ import { SourcesConfig, SourceCategory } from '@/lib/types';
|
||||
import { TitleBar } from '@/components/titlebar';
|
||||
import { useAppUpdater } from '@/hooks/use-app-updater';
|
||||
import { getVersion } from '@tauri-apps/api/app';
|
||||
import { useAppUpdater } from '@/hooks/use-app-updater';
|
||||
import { getVersion } from '@tauri-apps/api/app';
|
||||
|
||||
interface Model {
|
||||
name: string;
|
||||
@@ -67,10 +64,6 @@ export default function SettingsPage() {
|
||||
const [appVersion, setAppVersion] = useState<string>('');
|
||||
const [activeTab, setActiveTab] = useState<string>('overview');
|
||||
|
||||
const updater = useAppUpdater();
|
||||
const [appVersion, setAppVersion] = useState<string>('');
|
||||
const [activeTab, setActiveTab] = useState<string>('overview');
|
||||
|
||||
const updater = useAppUpdater();
|
||||
|
||||
// Load models, storage path, and sources config on mount
|
||||
@@ -83,11 +76,6 @@ export default function SettingsPage() {
|
||||
getVersion()
|
||||
.then(setAppVersion)
|
||||
.catch(() => setAppVersion('0.1.0'));
|
||||
|
||||
// Load app version
|
||||
getVersion()
|
||||
.then(setAppVersion)
|
||||
.catch(() => setAppVersion('0.1.0'));
|
||||
}, [settings.ollamaUrl]);
|
||||
|
||||
// Load logs periodically
|
||||
@@ -356,30 +344,6 @@ export default function SettingsPage() {
|
||||
<HardwareDashboard />
|
||||
</Suspense>
|
||||
)}
|
||||
{activeTab === 'overview' && (
|
||||
<Suspense fallback={
|
||||
<div className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{[1, 2, 3, 4].map((i) => (
|
||||
<Card key={i}>
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="h-4 w-16 bg-muted animate-pulse rounded" />
|
||||
<div className="h-5 w-12 bg-muted animate-pulse rounded" />
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="h-2 w-full bg-muted animate-pulse rounded" />
|
||||
<div className="h-3 w-24 bg-muted animate-pulse rounded" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
}>
|
||||
<HardwareDashboard />
|
||||
</Suspense>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
@@ -1,36 +1,9 @@
|
||||
'use client';
|
||||
|
||||
<<<<<<< HEAD
|
||||
import { SetupWizard } from '@/components/setup/setup-wizard';
|
||||
import { TitleBar } from '@/components/titlebar';
|
||||
|
||||
export default function SetupPage() {
|
||||
=======
|
||||
import { useHardware } from "@/hooks/use-hardware";
|
||||
import { HardwareScan } from "@/components/setup/hardware-scan";
|
||||
import { GpuSelector } from "@/components/setup/gpu-selector";
|
||||
import { ModelSelector } from "@/components/setup/model-selector";
|
||||
import { getRecommendation } from "@/lib/recommendation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { startTransition, useState } from "react";
|
||||
|
||||
export default function SetupPage() {
|
||||
const { specs, loading, gpus } = useHardware();
|
||||
const router = useRouter();
|
||||
const [isNavigating, setIsNavigating] = useState(false);
|
||||
|
||||
const handleComplete = () => {
|
||||
setIsNavigating(true);
|
||||
// Save setup state if needed
|
||||
localStorage.setItem("ollahub_setup_complete", "true");
|
||||
|
||||
// Usar startTransition para navegação não-bloqueante
|
||||
startTransition(() => {
|
||||
router.push("/chat");
|
||||
});
|
||||
};
|
||||
|
||||
>>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5
|
||||
return (
|
||||
<div className="h-screen w-full bg-background overflow-hidden flex flex-col">
|
||||
<TitleBar />
|
||||
@@ -38,4 +11,3 @@ export default function SetupPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user