refactor: remove unnecessary setupDialogProperties (#28982)
This commit is contained in:
parent
961b74b2ac
commit
42e5421276
1 changed files with 2 additions and 17 deletions
|
@ -2,11 +2,6 @@ import { app, BrowserWindow } from 'electron/main';
|
||||||
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
|
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
|
||||||
const dialogBinding = process._linkedBinding('electron_browser_dialog');
|
const dialogBinding = process._linkedBinding('electron_browser_dialog');
|
||||||
|
|
||||||
enum DialogType {
|
|
||||||
OPEN = 'OPEN',
|
|
||||||
SAVE = 'SAVE'
|
|
||||||
}
|
|
||||||
|
|
||||||
enum SaveFileDialogProperties {
|
enum SaveFileDialogProperties {
|
||||||
createDirectory = 1 << 0,
|
createDirectory = 1 << 0,
|
||||||
showHiddenFiles = 1 << 1,
|
showHiddenFiles = 1 << 1,
|
||||||
|
@ -72,16 +67,6 @@ const setupSaveDialogProperties = (properties: (keyof typeof SaveFileDialogPrope
|
||||||
return dialogProperties;
|
return dialogProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupDialogProperties = (type: DialogType, properties: string[]): number => {
|
|
||||||
if (type === DialogType.OPEN) {
|
|
||||||
return setupOpenDialogProperties(properties as (keyof typeof OpenFileDialogProperties)[]);
|
|
||||||
} else if (type === DialogType.SAVE) {
|
|
||||||
return setupSaveDialogProperties(properties as (keyof typeof SaveFileDialogProperties)[]);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveDialog = (sync: boolean, window: BrowserWindow | null, options?: SaveDialogOptions) => {
|
const saveDialog = (sync: boolean, window: BrowserWindow | null, options?: SaveDialogOptions) => {
|
||||||
checkAppInitialized();
|
checkAppInitialized();
|
||||||
|
|
||||||
|
@ -115,7 +100,7 @@ const saveDialog = (sync: boolean, window: BrowserWindow | null, options?: SaveD
|
||||||
nameFieldLabel,
|
nameFieldLabel,
|
||||||
showsTagField,
|
showsTagField,
|
||||||
window,
|
window,
|
||||||
properties: setupDialogProperties(DialogType.SAVE, properties)
|
properties: setupSaveDialogProperties(properties)
|
||||||
};
|
};
|
||||||
|
|
||||||
return sync ? dialogBinding.showSaveDialogSync(settings) : dialogBinding.showSaveDialog(settings);
|
return sync ? dialogBinding.showSaveDialogSync(settings) : dialogBinding.showSaveDialog(settings);
|
||||||
|
@ -156,7 +141,7 @@ const openDialog = (sync: boolean, window: BrowserWindow | null, options?: OpenD
|
||||||
message,
|
message,
|
||||||
securityScopedBookmarks,
|
securityScopedBookmarks,
|
||||||
window,
|
window,
|
||||||
properties: setupDialogProperties(DialogType.OPEN, properties)
|
properties: setupOpenDialogProperties(properties)
|
||||||
};
|
};
|
||||||
|
|
||||||
return (sync) ? dialogBinding.showOpenDialogSync(settings) : dialogBinding.showOpenDialog(settings);
|
return (sync) ? dialogBinding.showOpenDialogSync(settings) : dialogBinding.showOpenDialog(settings);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue