feat(launcher): add logging and diagnostics export
This commit is contained in:
1 parent
fdac56a036
commit
d633280e23
11 files changed
+233
-4
No files matched your search
@@ -17,6 +17,7 @@ import { useInstallWizard } from './pages/install/useInstallWizard.ts';
|
||||
import { WizardMain } from './pages/install/WizardMain.tsx';
|
||||
import { WizardSide } from './pages/install/WizardSide.tsx';
|
||||
import { wizardBar } from './pages/install/wizard-bar.ts';
|
||||
import { DiagnosticsSettings } from './pages/settings/DiagnosticsSettings.tsx';
|
||||
import { GeneralSettings } from './pages/settings/GeneralSettings.tsx';
|
||||
import { Background } from './shell/Background.tsx';
|
||||
import { BottomBar } from './shell/BottomBar.tsx';
|
||||
@@ -92,7 +93,9 @@ export function App({ info, initialSettings, initialRecord, defaultDataPath }: A
|
||||
case 'settings':
|
||||
return {
|
||||
side: <SubNav sections={SETTINGS_SECTIONS} active={route.settings} label={(section) => t(`settings.sections.${section}`)} onSelect={(section) => go({ page: 'settings', section })} />,
|
||||
main: <GeneralSettings settings={settings} pictures={backgrounds.pictures} onError={report} />,
|
||||
main: route.settings === 'diag'
|
||||
? <DiagnosticsSettings onError={report} />
|
||||
: <GeneralSettings settings={settings} pictures={backgrounds.pictures} onError={report} />,
|
||||
bar: home,
|
||||
};
|
||||
case 'copies': {
|
||||
|
||||
@@ -198,7 +198,17 @@
|
||||
},
|
||||
"settings": {
|
||||
"sections": {
|
||||
"general": "General"
|
||||
"general": "General",
|
||||
"diag": "Diagnostics"
|
||||
},
|
||||
"diagnostics": {
|
||||
"logs": "Logs",
|
||||
"logsHint": "Logs recorded by the launcher",
|
||||
"openLogs": "Open log folder",
|
||||
"export": "Export diagnostics",
|
||||
"exportHint": "Save logs, settings and the installation record to a ZIP file",
|
||||
"save": "Export…",
|
||||
"saved": "Diagnostics saved to {{path}}."
|
||||
},
|
||||
"language": "Language",
|
||||
"languageHint": "Display language of the launcher"
|
||||
@@ -269,6 +279,8 @@
|
||||
},
|
||||
"errors": {
|
||||
"internal_error": "An internal launcher error occurred.",
|
||||
"logs_folder_open_failed": "The launcher log folder could not be opened.",
|
||||
"diagnostics_export_failed": "The diagnostics archive could not be saved.",
|
||||
"settings_write_failed": "The settings could not be saved.",
|
||||
"folder_unreadable": "The folder cannot be read: {{path}}",
|
||||
"not_a_game_folder": "The selected folder is not a War Thunder installation: {{path}}",
|
||||
|
||||
@@ -198,7 +198,17 @@
|
||||
},
|
||||
"settings": {
|
||||
"sections": {
|
||||
"general": "常规"
|
||||
"general": "常规",
|
||||
"diag": "诊断"
|
||||
},
|
||||
"diagnostics": {
|
||||
"logs": "日志",
|
||||
"logsHint": "启动器运行日志",
|
||||
"openLogs": "打开日志文件夹",
|
||||
"export": "导出诊断信息",
|
||||
"exportHint": "导出包含日志、设置和安装记录的 ZIP 文件",
|
||||
"save": "导出…",
|
||||
"saved": "诊断信息已保存到 {{path}}。"
|
||||
},
|
||||
"language": "语言",
|
||||
"languageHint": "启动器界面的显示语言"
|
||||
@@ -269,6 +279,8 @@
|
||||
},
|
||||
"errors": {
|
||||
"internal_error": "启动器内部错误。",
|
||||
"logs_folder_open_failed": "无法打开启动器日志文件夹。",
|
||||
"diagnostics_export_failed": "无法保存诊断信息。",
|
||||
"settings_write_failed": "无法保存设置。",
|
||||
"folder_unreadable": "无法读取文件夹:{{path}}",
|
||||
"not_a_game_folder": "所选文件夹不是战争雷霆的安装文件夹:{{path}}",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
import { ipcInvoke } from '../../ipc.ts';
|
||||
|
||||
interface DiagnosticsSettingsProps {
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
export function DiagnosticsSettings({ onError }: DiagnosticsSettingsProps) {
|
||||
const { t } = useTranslation();
|
||||
const [exporting, setExporting] = useState(false);
|
||||
const [savedPath, setSavedPath] = useState<string | null>(null);
|
||||
|
||||
async function save(): Promise<void> {
|
||||
setExporting(true);
|
||||
setSavedPath(null);
|
||||
try {
|
||||
const result = await ipcInvoke('app:exportDiagnostics');
|
||||
setSavedPath(result.path);
|
||||
} catch (error) {
|
||||
onError(error);
|
||||
} finally {
|
||||
setExporting(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Sheet title={t('settings.sections.diag')}>
|
||||
<Row label={t('settings.diagnostics.logs')} hint={t('settings.diagnostics.logsHint')}>
|
||||
<button type="button" className="button" onClick={() => ipcInvoke('app:openLogsFolder').catch(onError)}>
|
||||
{t('settings.diagnostics.openLogs')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('settings.diagnostics.export')} hint={t('settings.diagnostics.exportHint')}>
|
||||
<button type="button" className="button" disabled={exporting} onClick={() => { void save(); }}>
|
||||
{t('settings.diagnostics.save')}
|
||||
</button>
|
||||
</Row>
|
||||
{savedPath && <p className="small" role="status">{t('settings.diagnostics.saved', { path: savedPath })}</p>}
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export type PageId = (typeof PAGES)[number];
|
||||
export const COPY_SECTIONS = ['summary', 'features'] as const;
|
||||
export type CopySection = (typeof COPY_SECTIONS)[number];
|
||||
|
||||
export const SETTINGS_SECTIONS = ['general'] as const;
|
||||
export const SETTINGS_SECTIONS = ['general', 'diag'] as const;
|
||||
export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
|
||||
|
||||
export interface Route {
|
||||
|
||||
Reference in new issue
Block a user