Electron 打开文件资源管理器窗口和打开文件

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);
}
    原文作者:编程课堂
    原文地址: https://blog.csdn.net/weixin_44917045/article/details/109265908
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞