Files
OllaHub/hooks/use-operating-system.ts
Evandro Fonseca Junior e5f062040c feat: enhance UI and functionality across chat and settings
- Added custom scrollbar styles for improved aesthetics and usability across the interface.
- Implemented responsive adjustments for chat sidebar and input components to enhance mobile experience.
- Integrated tooltip components in select elements for better user guidance and information display.
- Updated chat input and message components for improved styling and functionality.
- Enhanced settings page with semantic query expansion options and improved model selection UI.
- Refactored sidebar list to include better date formatting and tooltip support for session titles.
- Introduced GPU stats monitoring in the system panel for better hardware insights.
2025-11-26 19:04:46 -03:00

59 lines
1.6 KiB
TypeScript

import { useState, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core';
import type { OS } from '@/lib/download-utils';
export function useOperatingSystem() {
const [os, setOs] = useState<OS | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const detectOS = async () => {
try {
const detectedOS = await invoke<string>('get_operating_system');
// Mapear para o tipo OS
if (detectedOS === 'windows' || detectedOS === 'mac' || detectedOS === 'linux') {
setOs(detectedOS as OS);
} else {
// Fallback: tentar detectar via user agent
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.includes('win')) {
setOs('windows');
} else if (userAgent.includes('mac')) {
setOs('mac');
} else if (userAgent.includes('linux')) {
setOs('linux');
} else {
setOs('windows'); // Default fallback
}
}
} catch (error) {
console.error('Failed to detect OS:', error);
// Fallback: detectar via user agent
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.includes('win')) {
setOs('windows');
} else if (userAgent.includes('mac')) {
setOs('mac');
} else if (userAgent.includes('linux')) {
setOs('linux');
} else {
setOs('windows'); // Default fallback
}
} finally {
setLoading(false);
}
};
detectOS();
}, []);
return { os, loading };
}