当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript dialog.showOpenDialog方法代码示例

本文整理汇总了TypeScript中electron.dialog.showOpenDialog方法的典型用法代码示例。如果您正苦于以下问题:TypeScript dialog.showOpenDialog方法的具体用法?TypeScript dialog.showOpenDialog怎么用?TypeScript dialog.showOpenDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.dialog的用法示例。


在下文中一共展示了dialog.showOpenDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 click: (item: Electron.MenuItem, focusedWindow: Electron.BrowserWindow) => {
     const options: Electron.OpenDialogOptions = { properties: ["openDirectory"] };
     dialog.showOpenDialog(options, (dirnames) => {
         if (dirnames) {
             focusedWindow.webContents.send("openDir", dirnames[0]);
         }
     });
 }
开发者ID:Zzzen,项目名称:YAP,代码行数:8,代码来源:menuTemplate.ts

示例2: function

 ipcMain.on("open-output-directory-dialog", (event: Electron.IpcMessageEvent) => {
         dialog.showOpenDialog({
             properties: ["openDirectory"]
         }, function (dirs:string[]) {
             if (dirs) {
                 event.sender.send("selected-output-directory", dirs[0]);
             }
         });
     }
开发者ID:zlepper,项目名称:go-modpack-packer,代码行数:9,代码来源:IpcHandlers.ts

示例3: resolve

    const promise = new ItchPromise<string>((resolve, reject) => {
      const callback = (response: string[]) => {
        if (!response) {
          return resolve();
        }

        return resolve(response[0]);
      };
      dialog.showOpenDialog(nativeWindow, dialogOpts, callback);
    });
开发者ID:HorrerGames,项目名称:itch,代码行数:10,代码来源:install-locations.ts

示例4:

ipcMain.on('open-project', (event) => {
    dialog.showOpenDialog({
        title: 'Open Project',
        properties: ['openDirectory', 'createDirectory']
    }, folders => {
        if (folders && folders.length > 0) {
            event.sender.send('open-project', folders);
        }
    });
});
开发者ID:TheColorRed,项目名称:game-engine,代码行数:10,代码来源:main.ts

示例5: showOpenDialog

export function showOpenDialog() {
  dialog.showOpenDialog({
    title: 'Open Fiddle',
    properties: ['openDirectory']
  }, (filePaths) => {
    if (!filePaths || filePaths.length < 1) {
      return;
    }

    ipcMainManager.send(IpcEvents.FS_OPEN_FIDDLE, [ filePaths[0] ]);
  });
}
开发者ID:cocoflan,项目名称:fiddle-electron,代码行数:12,代码来源:files.ts

示例6: openScheduleFileDialog

function openScheduleFileDialog() {
  if (window) {
    dialog.showOpenDialog(mainWindow, {
      filters: [{ name: 'Schedules', extensions: ['json']}],
      properties: ['openFile'],
    }, (filenames: string[]) => {
      if (filenames && filenames[0]) {
        openScheduleFromFile(filenames[0]);
      }
    });
  }
}
开发者ID:molisani,项目名称:fcp-schedule,代码行数:12,代码来源:electron-main.ts

示例7: function

    open: function () {
        var options = {
            title: 'Message from callback',
            type: 'info',
            buttons: ['OK', 'Cancel'],
            message: 'Callback passs',
            detail: "ssss"
        };

        const {dialog} = require('electron');
        dialog.showOpenDialog(BrowserWindow,options);
    }
开发者ID:7thCode,项目名称:electron-material,代码行数:12,代码来源:index.ts

示例8: onChooseFolder

function onChooseFolder(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string) {
  if (secretKeys.get(event.sender) !== secretKey) return;

  electron.dialog.showOpenDialog({ properties: [ "openDirectory" ] }, (directory: string[]) => {
    if (directory == null) { event.sender.send("choose-folder-callback", ipcId, null); return; }

    const normalizedPath = path.normalize(directory[0]);
    getAuthorizationsForOrigin(origin).folders.push(normalizedPath);

    event.sender.send("choose-folder-callback", ipcId, normalizedPath);
  });
}
开发者ID:nitpum,项目名称:superpowers-app,代码行数:12,代码来源:ipc.ts

示例9:

 ipcMain.on('open-file', (event) => {
     dialog.showOpenDialog(mainWindow, {
         title: "Open Image",
         filters: [
             { name: 'Images', extensions: ['png', 'jpg', 'gif', 'pdd'] },
         ],
         properties: ["multiSelections", "openFile"]
     }, files => {
         if (files && files.length > 0) {
             event.sender.send('opened-files', files);
         }
     });
 });
开发者ID:TheColorRed,项目名称:photo-editor,代码行数:13,代码来源:open.ts

示例10: onChooseExportFolder

function onChooseExportFolder(event: Electron.IPCMainEvent) {
  electron.dialog.showOpenDialog({ properties: ["openDirectory"] }, (directory: string[]) => {
    if (directory == null) return;

    const outputFolder = directory[0];
    let isFolderEmpty = false;
    try { isFolderEmpty = fs.readdirSync(outputFolder).length === 0; }
    catch (e) { event.sender.send("export-folder-failed", `Error while checking if folder was empty: ${e.message}`); return; }
    if (!isFolderEmpty) { event.sender.send("export-folder-failed", "Output folder must be empty."); return; }

    event.sender.send("export-folder-success", outputFolder);
  });
}
开发者ID:mk-pmb,项目名称:superpowers-app,代码行数:13,代码来源:export.ts

示例11: onChooseFolder

function onChooseFolder(event: Electron.IpcMainEvent) {
  electron.dialog.showOpenDialog({ properties: [ "openDirectory" ] }, (directory: string[]) => {
    if (directory == null) { event.sender.send("choose-folder-callback", null, null); return; }

    const outputFolder = directory[0];
    let isFolderEmpty = false;
    try { isFolderEmpty = fs.readdirSync(outputFolder).length === 0; }
    catch (e) { event.sender.send("choose-folder-callback", `Error while checking if folder is empty: ${e.message}`, null); return; }
    if (!isFolderEmpty) { event.sender.send("choose-folder-callback", "Folder must be empty.", null); return; }

    event.sender.send("choose-folder-callback", null, outputFolder);
  });
}
开发者ID:AgileJoshua,项目名称:superpowers-app,代码行数:13,代码来源:ipc.ts

示例12: onChooseFile

function onChooseFile(event: Electron.IpcMainEvent, secretKey: string, ipcId: string, origin: string, access: "readWrite"|"execute") {
  if (secretKeys.get(event.sender) !== secretKey) return;

  electron.dialog.showOpenDialog({ properties: [ "openFile" ] }, (file: string[]) => {
    if (file == null) { event.sender.send("choose-file-callback", ipcId, null); return; }

    const normalizedPath = path.normalize(file[0]);
    const auths = getAuthorizationsForOrigin(origin);

    if (access === "execute") auths.exeFiles.push(normalizedPath);
    else auths.rwFiles.push(normalizedPath);

    event.sender.send("choose-file-callback", ipcId, normalizedPath);
  });
}
开发者ID:nitpum,项目名称:superpowers-app,代码行数:15,代码来源:ipc.ts

示例13:

export const openVideoDialog = (webContents: Electron.WebContents) => {
  const paths = dialog.showOpenDialog({
    filters: videoFilters,
    properties: ['openFile'],
  });

  if (!Array.isArray(paths) || paths.length === 0) {
    return;
  }

  if (paths.length > 1) {
    console.log('only support one file');
  }

  webContents.send('open-video', paths[0]);
};
开发者ID:Heeryong-Kang,项目名称:jamak,代码行数:16,代码来源:fileDialogs.ts

示例14: download

ipcMain.on('download-file-message', (event, args) => {
  console.log(args)  // prints "ping"
  event.sender.send('download-file-reply', 'pong');

  var folderPaths = dialog.showOpenDialog({ properties: ['openDirectory'] });
  console.log(folderPaths);

  if (folderPaths.length > 0) {
    download(BrowserWindow.getFocusedWindow(), args.url, {
      directory: folderPaths[0],
      filename: args.fileName
    })
      .then(dl => console.log(dl.getSavePath()))
      .catch(console.error);
  }
})
开发者ID:mangabot,项目名称:mangabot,代码行数:16,代码来源:main.ts

示例15: switch

ipcMain.on('action', (event: any, args: [AppState, AppAction]) => {
    const action = args[1];

    switch (action.type) {
        case FolderActionType.BrowseForFolder:
            dialog.showOpenDialog(mainWindow!, { properties: ['openDirectory', 'createDirectory'] }, paths => {
                event.sender.send('action', setFolderPath(paths[0]));
            });
            break;
        case FolderFormActionType.SetFolderPath:
        case FolderFormActionType.SetRemotePath:
        case FolderActionType.AddFolder:
        case FolderActionType.DeleteFolder:
        case FolderActionType.UpdateFolderStatus:
            saveStore(args[0]);
            break;
    }
});
开发者ID:istvan-antal,项目名称:copycat,代码行数:18,代码来源:main.ts


注:本文中的electron.dialog.showOpenDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。