- Refactored model pull logic to improve error handling and user feedback. - Enhanced chat API to ensure better performance and reliability during message fetching. - Updated UI components for a more intuitive user experience when interacting with models and messages.
29 lines
771 B
TypeScript
29 lines
771 B
TypeScript
import { useState, useEffect } from 'react';
|
|
import { invoke } from '@tauri-apps/api/core';
|
|
import { SystemSpecs } from '@/lib/recommendation';
|
|
|
|
export function useHardware() {
|
|
const [specs, setSpecs] = useState<SystemSpecs | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
async function fetchSpecs() {
|
|
try {
|
|
const data = await invoke<SystemSpecs>('get_system_specs');
|
|
// Simulate a small delay for the "scanning" effect
|
|
setTimeout(() => {
|
|
setSpecs(data);
|
|
setLoading(false);
|
|
}, 1500);
|
|
} catch (error) {
|
|
console.error("Failed to get system specs:", error);
|
|
setLoading(false);
|
|
}
|
|
}
|
|
fetchSpecs();
|
|
}, []);
|
|
|
|
return { specs, loading };
|
|
}
|
|
|