當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。