zoukankan      html  css  js  c++  java
  • electron-vue 打开文件目录,打开文件夹,

    1.打开父子模态创建,

    <button @click="showModalHandler">父子模态窗口</button>
    //renderer渲染器中主注册事件
    showModalHandler() {
          ipcRenderer.send("child-down-modal");
        }
    //主进程中触发事件
      /**
       * 父子模态窗口
       */
      let childDownModal;
      ipcMain.on('child-down-modal', () => {
        childDownModal = new BrowserWindow({
          parent: mainWindow,
          modal: true,
          show: false,
           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()//可默认打开文件

  • 相关阅读:
    【leetcode】面试题 01.04. 回文排列
    【leetcode】将数组分成和相等的三个部分
    【leetcode】杨辉三角
    【leetcode】杨辉三角 II
    【leetcode】判断路径是否相交
    【leetcode】路径总和
    【leetcode】山脉数组的峰顶索引
    053-4
    053-151
    053-272
  • 原文地址:https://www.cnblogs.com/huangmin1992/p/10843026.html
Copyright © 2011-2022 走看看