當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript remote.dialog.showOpenDialog方法代碼示例

本文整理匯總了TypeScript中electron.remote.dialog.showOpenDialog方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript remote.dialog.showOpenDialog方法的具體用法?TypeScript remote.dialog.showOpenDialog怎麽用?TypeScript remote.dialog.showOpenDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.remote.dialog的用法示例。


在下文中一共展示了remote.dialog.showOpenDialog方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

$('body').on('click', '.button#load-template', function(event) {
  dialog.showOpenDialog(
  {
    title: 'Open New Email Template',
    filters: [
      {name: 'Templates', extensions: ['html']},
      {name: 'All Files', extensions: ['*']}
    ]
  }, function(fileNames: string[]) {
    if (fileNames !== undefined) {
      storage.get('templates', function(error, templates) {
        if (_.isEmpty(templates)) {
          templates = [];
        }
        if (! _.contains(templates, fileNames[0])) {
          templates.push(fileNames[0]);
          storage.set('templates', templates, function(error) {
            if (error) {
              console.error(error);
            }
          });
        }
      });
      openTemplate(fileNames[0]);
    }
  });
});
開發者ID:hack-rpi,項目名稱:Email-Board,代碼行數:27,代碼來源:email.ts

示例2: chooseFileOrDirWithDialog

 function chooseFileOrDirWithDialog() {
     const filters = [
         {
             name: 'Markdown',
             extensions: config.file_ext.markdown,
         },
         {
             name: 'HTML',
             extensions: config.file_ext.html,
         },
     ];
     const properties = ['openFile'] as ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[];
     if (on_darwin) {
         // Note:
         // On Windows and Linux an open dialog can not be both a file selector
         // and a directory selector, so if you set properties to
         // ['openFile', 'openDirectory'] on these platforms, a directory
         // selector will be shown.
         properties.push('openDirectory');
     }
     const paths = remote.dialog.showOpenDialog({
         title: 'Choose file or directory to watch',
         defaultPath: getDialogDefaultPath(),
         filters,
         properties,
     });
     if (!paths || paths.length === 0) {
         return '';
     }
     return paths[0];
 }
開發者ID:WondermSwift,項目名稱:Shiba,代碼行數:31,代碼來源:index.ts

示例3: directoryChooser

export function directoryChooser(title?: string, defaultPath?: string) {

    return remote.dialog.showOpenDialog({
        defaultPath,
        title,
        properties: [
            "openDirectory",
        ],
    })[0];
}
開發者ID:atrauzzi,項目名稱:Gerty,代碼行數:10,代碼來源:DirectoryChooser.ts

示例4: add

 /**
  * Display a dialog for selecting the library dir.
  */
 add() {
     dialog.showOpenDialog({
         title: 'Select Visualization Folder(s)',
         defaultPath: this.state.lastPath.value || DEFAULT_LIBRARY_PATH,
         properties: ['openDirectory', 'multiSelections']
     }, (paths: string[]) => {
         const entries = this.loadFromPaths(paths);
         if (0 < entries.length) {
             this.state.update('activeId', entries[0].id);
         }
     });
 }
開發者ID:michaelbromley,項目名稱:skqw,代碼行數:15,代碼來源:v-selector.component.ts

示例5: fileChooser

export function fileChooser(multi: boolean, title?: string, defaultPath?: string) {

    const properties: OpenDialogOptions["properties"] = [
        "openFile",
    ];

    if (multi) {

        properties.push("multiSelections");
    }

    return remote.dialog.showOpenDialog({
        defaultPath,
        title,
        properties,
    });
}
開發者ID:atrauzzi,項目名稱:Gerty,代碼行數:17,代碼來源:FileChooser.ts

示例6: function

{
    const opened: boolean = webview.isDevToolsOpened();
    const focused: boolean = webview.isDevToolsFocused();
    const focused2: boolean = webview.getWebContents().isFocused();
}

// In guest page.
ipcRenderer.on('ping', function() {
	ipcRenderer.sendToHost('pong');
});


// showOpenDialog
// https://electron.atom.io/docs/api/dialog/#dialogshowopendialogbrowserwindow-options-callback

remote.dialog.showOpenDialog(win);
remote.dialog.showOpenDialog(win, {}, fileNames => fileNames);
remote.dialog.showOpenDialog(win, {
	title: 'foo',
	defaultPath: '/bar',
	buttonLabel: 'foo bar',
	filters: [
		{name: 'Images', extensions: ['jpg', 'png', 'gif']},
		{name: 'Movies', extensions: ['mkv', 'avi', 'mp4']},
		{name: 'Custom File Type', extensions: ['as']},
		{name: 'All Files', extensions: ['*']}
	],
	properties: ['openFile', 'openDirectory', 'multiSelections', 'showHiddenFiles', 'createDirectory', 'promptToCreate', 'noResolveAliases'],
	normalizeAccessKeys: true,
	message: 'foo message',
});
開發者ID:YousefED,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:renderer.ts


注:本文中的electron.remote.dialog.showOpenDialog方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。