diff options
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl')
-rw-r--r-- | packages/main/src/infrastructure/electron/impl/electronShell.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/electronShell.ts b/packages/main/src/infrastructure/electron/impl/electronShell.ts index be1cbe3..f7f7001 100644 --- a/packages/main/src/infrastructure/electron/impl/electronShell.ts +++ b/packages/main/src/infrastructure/electron/impl/electronShell.ts | |||
@@ -18,7 +18,9 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { app, shell } from 'electron'; | 21 | import { writeFile } from 'node:fs/promises'; |
22 | |||
23 | import { app, dialog, shell } from 'electron'; | ||
22 | import { getLogger } from 'loglevel'; | 24 | import { getLogger } from 'loglevel'; |
23 | 25 | ||
24 | import type MainEnv from '../../../stores/MainEnv'; | 26 | import type MainEnv from '../../../stores/MainEnv'; |
@@ -34,6 +36,17 @@ const electronShell: MainEnv = { | |||
34 | openAboutDialog(): void { | 36 | openAboutDialog(): void { |
35 | app.showAboutPanel(); | 37 | app.showAboutPanel(); |
36 | }, | 38 | }, |
39 | async saveTextFile(filename: string, value: string): Promise<void> { | ||
40 | const result = await dialog.showSaveDialog({ | ||
41 | defaultPath: filename, | ||
42 | }); | ||
43 | if (result.canceled || result.filePath === undefined) { | ||
44 | log.debug('Saving file', filename, 'canceled'); | ||
45 | return; | ||
46 | } | ||
47 | await writeFile(result.filePath, value, 'utf8'); | ||
48 | log.debug('Saved file', filename, 'to', result.filePath); | ||
49 | }, | ||
37 | }; | 50 | }; |
38 | 51 | ||
39 | export default electronShell; | 52 | export default electronShell; |