import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { invoke } from '@tauri-apps/api/core'; import { save as saveDialog } from '@tauri-apps/plugin-dialog'; import { open as openUrl } from '@tauri-apps/plugin-shell'; import { AppWindow, ChevronDown, Download, ExternalLink, Globe, HardDrive, Info, Scale, Sliders, Users } from 'lucide-react'; import { version as appVersion } from '../../../package.json'; import i18n from '../../i18n'; import { useAuthStore } from '../../store/authStore'; import type { ClockFormat, LinuxWaylandTextRenderProfile, LoggingMode } from '../../store/authStoreTypes'; import { IS_LINUX } from '../../utils/platform'; import { showToast } from '../../utils/ui/toast'; import { AboutPsysonicBrandHeader } from '../AboutPsysonicLol'; import CustomSelect from '../CustomSelect'; import LicensesPanel from '../LicensesPanel'; import SettingsSubSection from '../SettingsSubSection'; import { SettingsGroup } from './SettingsGroup'; import { SettingsToggle } from './SettingsToggle'; import { BackupSection } from './BackupSection'; import { CONTRIBUTORS, MAINTAINERS } from '../../config/settingsCredits'; export function SystemTab() { const { t } = useTranslation(); const navigate = useNavigate(); const auth = useAuthStore(); const [waylandTextRenderAvailable, setWaylandTextRenderAvailable] = useState(false); useEffect(() => { if (!IS_LINUX) return; invoke('linux_wayland_text_render_settings_available') .then(setWaylandTextRenderAvailable) .catch(() => {}); }, []); const exportRuntimeLogs = async () => { const suggestedName = `psysonic-logs-${new Date().toISOString().replace(/[:.]/g, '-')}.log`; const selected = await saveDialog({ defaultPath: suggestedName, filters: [{ name: 'Log files', extensions: ['log', 'txt'] }], title: t('settings.loggingExport'), }); if (!selected || Array.isArray(selected)) return; try { const lines = await invoke('export_runtime_logs', { path: selected }); showToast(t('settings.loggingExportSuccess', { count: lines }), 3500, 'info'); } catch (e) { console.error(e); showToast(t('settings.loggingExportError'), 4500, 'error'); } }; return ( <> } >
i18n.changeLanguage(v)} options={[ { value: 'en', label: t('settings.languageEn') }, { value: 'de', label: t('settings.languageDe') }, { value: 'es', label: t('settings.languageEs') }, { value: 'fr', label: t('settings.languageFr') }, { value: 'nl', label: t('settings.languageNl') }, { value: 'nb', label: t('settings.languageNb') }, { value: 'ru', label: t('settings.languageRu') }, { value: 'zh', label: t('settings.languageZh') }, { value: 'ro', label: t('settings.languageRo') }, { value: 'ja', label: t('settings.languageJa') }, { value: 'hu', label: t('settings.languageHu') }, ]} />
{/* App-Verhalten (aus altem library/general Behavior-Block) */} } >
{IS_LINUX && (
{waylandTextRenderAvailable && ( <>
{t('settings.linuxWaylandTextRender')}
{t('settings.linuxWaylandTextRenderDesc')}
auth.setLinuxWaylandTextRenderProfile(v as LinuxWaylandTextRenderProfile)} options={[ { value: 'balanced', label: t('settings.linuxWaylandTextRenderBalanced') }, { value: 'sharp', label: t('settings.linuxWaylandTextRenderSharp') }, { value: 'gpu', label: t('settings.linuxWaylandTextRenderGpu') }, { value: 'minimal', label: t('settings.linuxWaylandTextRenderMinimal') }, ]} />
)} )}
{t('settings.clockFormat')}
{t('settings.clockFormatDesc')}
auth.setClockFormat(v as ClockFormat)} options={[ { value: 'auto', label: t('settings.clockFormatAuto') }, { value: '24h', label: t('settings.clockFormatTwentyFour') }, { value: '12h', label: t('settings.clockFormatTwelve') }, ]} />
} > } >
{t('settings.loggingModeDesc')}
auth.setLoggingMode(v as LoggingMode)} options={[ { value: 'off', label: t('settings.loggingModeOff') }, { value: 'normal', label: t('settings.loggingModeNormal') }, { value: 'debug', label: t('settings.loggingModeDebug') }, ]} /> {auth.loggingMode === 'debug' && (
)}
} >

{t('settings.aboutDesc')}

{t('settings.aboutLicense')} {t('settings.aboutLicenseText')}
Stack {t('settings.aboutBuiltWith')}
{t('settings.aboutMaintainersLabel')}
{MAINTAINERS.map(m => (
{m.github}
))}
{t('settings.aboutReleaseNotesLabel')}
} >
{CONTRIBUTORS.map(c => (
{c.github}
{ e.stopPropagation(); openUrl(`https://github.com/${c.github}`); }} onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.stopPropagation(); e.preventDefault(); openUrl(`https://github.com/${c.github}`); } }} > @{c.github} v{c.since} ยท {t('settings.aboutContributorsCount', { count: c.contributions.length })}
    {c.contributions.map(item =>
  • {item}
  • )}
))}
} > ); }