electron-vue 打开文件目录,打开文件夹,

electron-vue 打开文件目录,打开文件夹,
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说electron-vue 打开文件目录,打开文件夹,,希望能够帮助大家进步!!!

1.打开父子模态创建,

<button @click="showModalHandler">父子模态窗口</button>

//renderer渲染器中主注册事件
showModalHandler() {
      ipcRenderer.send("child-down-modal");
    }

electron-vue 打开文件目录,打开文件夹,
electron-vue 打开文件目录,打开文件夹,

//主进程中触发事件
  /**
   * 父子模态窗口
   */
  let childDownModal;
  ipcMain.on('child-down-modal', () => {
    childDownModal = new BrowserWindow({
      parent: mainWindow,
      modal: true,
      show: false,
      width: 300,
      height: 300,
      resizable: false,
      backgroundColor: "#fff",
      frame: false,
      hasShadow: true,
      closable: true,
      webPreferences: {
        devTools: false
      }
    })
    childDownModal.once('ready-to-show', () => {
      childDownModal.show();
    })
    childDownModal.loadURL(winURL + '#/downloadModal')
  })
  //关闭模态窗口
  ipcMain.on('close-down-modal', () => {
    childDownModal.hide();
  })

View Code

2、打开文件目录

const {shell}  = require('electron').remote //渲染器中

shell模块提供与桌面集成相关的功能。

<template>
  <div class="download-container sureDrag">
    <button @click="openFileHandler">打开文件目录</button>
  </div>
</template>

<script>
const ipcRenderer = require("electron").ipcRenderer;
export default {
  methods: {
    openFileHandler() {
      const { shell } = require("electron").remote;
      shell.showItemInFolder("D:CloudMusic");
    }
  }
};
</script>

3.对话框打开文件

const {dialog} = require('electron').remote;

dialog.showOpenDialog()//可默认打开文件

转载于:https://www.cnblogs.com/huangmin1992/p/10843026.html

本文来源weixin_30595035,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/29842

发表评论