import { useState, useEffect } from 'react'; import { Copy, Check, Download } from 'lucide-react'; import { invoke } from '@tauri-apps/api/core'; import { getVersion } from '@tauri-apps/api/app'; interface AppInfo { version: string; app_data_dir: string | null; app_config_dir: string | null; } export function Diagnostics() { const [appInfo, setAppInfo] = useState(null); const [tauriVersion, setTauriVersion] = useState('—'); const [copied, setCopied] = useState(false); useEffect(() => { (async () => { try { const info = await invoke('get_app_info'); setAppInfo(info); } catch (_) { setAppInfo(null); } try { const v = await getVersion(); setTauriVersion(v); } catch (_) {} })(); }, []); const buildDiagnosticsText = () => { const lines = [ `PAPA YU Diagnostics — ${new Date().toISOString()}`, '', 'Версии:', ` App (package): ${appInfo?.version ?? '—'}`, ` Tauri (getVersion): ${tauriVersion}`, '', 'Пути (системные директории Tauri/OS):', ` app_data_dir: ${appInfo?.app_data_dir ?? '—'}`, ` app_config_dir: ${appInfo?.app_config_dir ?? '—'}`, '', 'Updater:', ' endpoint: https://github.com/yrippert-maker/papayu/releases/latest/download/latest.json', ' подпись: требуется (pubkey в tauri.conf.json)', '', ]; return lines.join('\n'); }; const handleCopy = async () => { const text = buildDiagnosticsText(); await navigator.clipboard.writeText(text); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const handleExport = () => { const text = buildDiagnosticsText(); const blob = new Blob([text], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `papayu-diagnostics-${new Date().toISOString().slice(0, 10)}.txt`; a.click(); URL.revokeObjectURL(url); }; return (

Диагностика

Версии

Приложение:
{appInfo?.version ?? tauriVersion ?? '—'}
Tauri:
{tauriVersion}

Пути данных

Используются системные директории (не зависят от $HOME):

app_data_dir:
{appInfo?.app_data_dir ?? '—'}
app_config_dir:
{appInfo?.app_config_dir ?? '—'}

Состояние обновлений

Endpoint: …/releases/latest/download/latest.json

Подпись обязательна; pubkey задаётся в tauri.conf.json. Если ключ не настроен — проверка обновлений вернёт ошибку.

); }