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


TypeScript electron.remote.BrowserWindow类代码示例

本文整理汇总了TypeScript中electron.remote.BrowserWindow的典型用法代码示例。如果您正苦于以下问题:TypeScript remote.BrowserWindow类的具体用法?TypeScript remote.BrowserWindow怎么用?TypeScript remote.BrowserWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Notification

services.jobs.onFinish.subscribe(job => {
    const electronWindow = remote.BrowserWindow.getAllWindows()[0];

    if (remote.app.dock && !electronWindow.isFocused()) {
        remote.app.dock.bounce("informational");
        remote.app.dock.setBadge(job.status === Status.Success ? "1" : "✕");

        const title = job.status === Status.Success ? "Completed" : "Failed";

        /* tslint:disable:no-unused-expression */
        new Notification(title, {body: job.prompt.value});
    }
});
开发者ID:sunyton,项目名称:upterm,代码行数:13,代码来源:JobFinishedNotifications.ts

示例2: sanitizeFilename

 r.onloadend = () => {
   const data = {
     name: sanitizeFilename(self.visState.title.toLowerCase().replace(/\s/g, '-')),
     image: r.result,
     format: 'png'
   };
   remote.dialog.showSaveDialog(
     remote.BrowserWindow.getAllWindows()[0],
     {
       title: 'Export to Image',
       defaultPath: sanitizeFilename(data.name + '.' + data.format)
     },
     (name: string) => {
       name && writeFileSync(name, arrayBufferToBuffer(data.image));
     }
   );
 };
开发者ID:chauey,项目名称:ngrev,代码行数:17,代码来源:export-to-image.service.ts

示例3: getData

function getData(): [Electron.BrowserWindow, MessageServerChannel<'log'>] {
	let win: Electron.BrowserWindow = null;
	if (!BrowserWindow) {
		win = remote.BrowserWindow.getAllWindows()[0];
	} else {
		win = BrowserWindow.getAllWindows()[0];
	}

	if (!logChannel && win) {
		logChannel = new MessageServer({
			activeWindow: win,
			activeWindowPromise: new Promise((resolve) => {
				resolve(win);
			}),
			idGenerator: -1
		}).channel('log');
	}

	return [win, logChannel];
}
开发者ID:SanderRonde,项目名称:youtube-music-app,代码行数:20,代码来源:log.ts

示例4: dispatchPublishGist

export function dispatchPublishGist(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore,
  _event: Event
) {
  const state = store.getState();
  const githubToken = state.app.get("githubToken");

  // The simple case -- we have a token and can publish
  if (githubToken != null) {
    store.dispatch(actions.publishGist(ownProps));
    return;
  }

  // If the Github Token isn't set, use our oauth server to acquire a token

  // Because the remote object from Electron main <--> renderer can be "cleaned up"
  // we re-require electron here and get the remote object
  const remote = require("electron").remote;

  // Create our oauth window
  const win = new remote.BrowserWindow({
    show: false,
    webPreferences: { zoomFactor: 0.75 }
  });

  // TODO: This needs to be moved to an epic
  win.webContents.on("dom-ready", () => {
    // When we're at our callback code page, keep the page hidden
    if (win.webContents.getURL().indexOf("callback?code=") !== -1) {
      // Extract the text content
      win.webContents.executeJavaScript(
        "require('electron').ipcRenderer.send('auth', document.body.textContent);"
      );
      remote.ipcMain.on("auth", (_event: Event, auth: string) => {
        try {
          const accessToken = JSON.parse(auth).access_token;
          store.dispatch(actions.setGithubToken(accessToken));

          const notificationSystem = selectors.notificationSystem(state);

          notificationSystem.addNotification({
            title: "Authenticated",
            message: "🔒",
            level: "info"
          });

          // We are now authenticated and can finally publish
          store.dispatch(actions.publishGist(ownProps));
        } catch (e) {
          store.dispatch(actions.coreError(e));
        } finally {
          win.close();
        }
      });
    } else {
      win.show();
    }
  });
  win.loadURL("https://oauth.nteract.io/github");
}
开发者ID:nteract,项目名称:nteract,代码行数:61,代码来源:menu.ts

示例5: isInProgress

            if (isKeybindingForEvent(event, KeyboardAction.cliHistoryPrevious)) {
                prompt.setPreviousHistoryItem();

                event.stopPropagation();
                event.preventDefault();
                return;
            }

            if (isKeybindingForEvent(event, KeyboardAction.cliHistoryNext)) {
                prompt.setNextHistoryItem();

                event.stopPropagation();
                event.preventDefault();
                return;
            }
        }
    }

    prompt.setPreviousKeyCode(event);
};

function isInProgress(job: JobComponent): boolean {
    return job.props.job.status === Status.InProgress;
}

const app = remote.app;
const browserWindow = remote.BrowserWindow.getAllWindows()[0];
const template = buildMenuTemplate(app, browserWindow);

remote.Menu.setApplicationMenu(remote.Menu.buildFromTemplate(template));
开发者ID:fabricionaweb,项目名称:black-screen,代码行数:30,代码来源:UserEventsHander.ts


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