1、引入相关模块:
imports = { };
imports.remote = require('electron').remote;
imports.shell = require('electron').shell;
window.imports = imports;
2、打开文件资源管理器窗口:
onOpenFilePositionButtonClick(): void {
let window = this.imports.remote.getCurrentWindow();
let options = {
title: '标题',
defaultPath: this.filePath,
properties: ['openFile', 'multiSelections']
};
this.imports.remote.dialog.showOpenDialog(window, options);
}
3、打开文件
onOpenFileButtonClick(): void {
this.imports.shell.openPath(this.filePath);
}