示例工程 11-main-process-services
11-main-process-services/app/.tsc/main/services/index.js
import { dialog, shell } from "electron";
import { createDialogService } from "./dialog-service";
import { createNotesService } from "./notes-service";
import { createShellService } from "./shell-service";
export const SHELL_ALLOWLIST = ["example.com", "www.electronjs.org"];
export function createServices(options) {
return {
notes: createNotesService({ dir: options.dir }),
shell: createShellService({
allowlist: SHELL_ALLOWLIST,
openExternal: (url) => shell.openExternal(url),
dryRun: options.dryRun,
}),
dialog: createDialogService({
showOpenDialog: async () => dialog.showOpenDialog({
properties: ["openFile"],
filters: [{ name: "Notes", extensions: ["md", "txt"] }],
}),
dryRun: options.dryRun,
}),
};
}
//# sourceMappingURL=index.js.map