mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-17 03:13:30 -07:00
refactor(main): split main.ts into focused runtime modules (#123)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import type { MessageBoxOptions, MessageBoxReturnValue } from 'electron';
|
||||
|
||||
type ShowMessageBox = (options: MessageBoxOptions) => Promise<MessageBoxReturnValue>;
|
||||
|
||||
export async function showLogExportSuccessDialog(options: {
|
||||
zipPath: string;
|
||||
showMessageBox: ShowMessageBox;
|
||||
showItemInFolder: (path: string) => void;
|
||||
logWarn: (message: string, details?: unknown) => void;
|
||||
}): Promise<void> {
|
||||
const successDialog = await options
|
||||
.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'SubMiner logs exported',
|
||||
message: 'SubMiner log export created.',
|
||||
detail: options.zipPath,
|
||||
buttons: ['OK', 'Show in Folder'],
|
||||
defaultId: 0,
|
||||
cancelId: 0,
|
||||
})
|
||||
.catch((dialogError) => {
|
||||
options.logWarn('Failed to show log export success dialog.', dialogError);
|
||||
return undefined;
|
||||
});
|
||||
|
||||
if (successDialog?.response === 1) {
|
||||
options.showItemInFolder(options.zipPath);
|
||||
}
|
||||
}
|
||||
|
||||
export async function showLogExportErrorDialog(options: {
|
||||
message: string;
|
||||
showMessageBox: ShowMessageBox;
|
||||
logWarn: (message: string, details?: unknown) => void;
|
||||
}): Promise<void> {
|
||||
await options
|
||||
.showMessageBox({
|
||||
type: 'error',
|
||||
title: 'SubMiner log export failed',
|
||||
message: 'Could not export SubMiner logs.',
|
||||
detail: options.message,
|
||||
})
|
||||
.catch((dialogError) => {
|
||||
options.logWarn('Failed to show log export error dialog.', dialogError);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user