feat: add emoji-regex and remove-accents dependencies; enhance chat and setup pages
- Added `emoji-regex` and `remove-accents` packages to improve text processing capabilities. - Implemented automatic Ollama startup in the chat page for better user experience. - Enhanced setup page to include GPU selection based on hardware specifications. - Updated chat input to support real-time validation and improved user feedback. - Refactored message handling in chat to incorporate new processing features.
This commit is contained in:
1 parent
4275295e4f
commit
84ea2dec19
51 files changed
+7857
-573
No files matched your search
@@ -0,0 +1,56 @@
|
||||
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 };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user