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


TypeScript BrowserWindow.setMenuBarVisibility方法代码示例

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


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

示例1: onExport

function onExport(event: Electron.IPCMainEvent, data: ExportData) {
  const exportWindow = new electron.BrowserWindow({
    title: "Superpowers", icon: `${__dirname}/public/images/icon.png`,
    width: 1000, height: 600,
    minWidth: 800, minHeight: 480,
    useContentSize: true
  });
  exportWindow.setMenuBarVisibility(false);
  exportWindow.loadURL(`${data.baseURL}:${data.mainPort}/build.html`);

  const doExport = () => {
    exportWindow.webContents.removeListener("did-finish-load", doExport);
    exportWindow.webContents.send("setText", { title: "Superpowers — Exporting...", text: "Exporting..." });

    exportWindow.setProgressBar(0);
    let progress = 0;
    const progressMax = data.files.length;
    const buildPath = `/builds/${data.projectId}/${data.buildId}`;
    const systemsPath = "/systems/";

    async.eachLimit(data.files, 10, (file: string, cb: (err: Error) => any) => {

      let outputFilename = file;
      if (startsWith(outputFilename, buildPath)) {
        // Project build files are served on the build port
        outputFilename = outputFilename.substr(buildPath.length);
        file = `${data.baseURL}:${data.buildPort}${file}`;
      } else {
        // Other files are served on the main port
        file = `${data.baseURL}:${data.mainPort}${file}`;

        if (startsWith(outputFilename, systemsPath)) {
          // Output system files at the root
          outputFilename = outputFilename.substr(outputFilename.indexOf("/", systemsPath.length));
        }
      }
      outputFilename = outputFilename.replace(/\//g, path.sep);

      const outputPath = `${data.outputFolder}${outputFilename}`;
      exportWindow.webContents.send("setText", { text: outputPath });

      http.get(file, (response) => {
        mkdirp(path.dirname(outputPath), (err: Error) => {
          const localFile = fs.createWriteStream(outputPath);
          localFile.on("finish", () => {
            progress++;
            exportWindow.setProgressBar(progress / progressMax);
            cb(null);
          });
          response.pipe(localFile);
        });
      }).on("error", cb);
    } , (err: Error) => {
      exportWindow.setProgressBar(-1);
      if (err != null) { alert(err); return; }
      exportWindow.webContents.send("setText", { title: "Superpowers — Exported", text: "Exported to ", showItemInFolder: { text: data.outputFolder, target: data.outputFolder } } );
    });
  };
  exportWindow.webContents.addListener("did-finish-load", doExport);
}
开发者ID:mk-pmb,项目名称:superpowers-app,代码行数:60,代码来源:export.ts

示例2: openWin

function openWin(serverConf?:any) {
    ipcMain.on('open-devtool', (event:any, status:any) => {
        win.toggleDevTools({mode: 'detach'});
    });

    ipcMain.on('devWatch', (event:any, arg:any) => {
        sender = event.sender;
        devWatch();
    });

    win = new BrowserWindow({
        width: 950, height: 540,
        // width: 500, height: 540,
        resizable: false,
        frame: true,
        autoHideMenuBar: false,
        webaudio: false
    });
    // win.setMenu(null);
    win.setMenuBarVisibility(false);
    // win.loadURL('http://127.0.0.1');
    if (isDev)
        win.loadURL(`file://${__dirname}app/reload.html`);
    else
        win.loadURL(`file:///resources/app/reload.html`);
    // win.loadURL(`file:///app/reload.html`);
    win.on('closed', function () {
        win = null;
    });

    
    //todo print
    // http://electron.atom.io/docs/api/web-contents/
}
开发者ID:solpie,项目名称:yqbe,代码行数:34,代码来源:main.ts

示例3: BrowserWindow

	app.on('ready', () => {
		// win = new BrowserWindow({ width: 800, height: 600, show: false ,autoHideMenuBar: true});
		win = new BrowserWindow();
		win.setMenuBarVisibility(false);
		win.webContents.openDevTools();
		// win.setVisibleOnAllWorkspaces(false);
		win.on('closed', () => {
			win = null;
		});
		win.loadURL('file:///' + path.join(__dirname, '../pages/index.html'));
		// win.show();
	});
开发者ID:taoqf,项目名称:fd,代码行数:12,代码来源:main.ts

示例4: createWindow

function createWindow() {
    win = new BrowserWindow({ width: 800, height: 600, show: false });
    win.setMenu(null);
    win.setMenuBarVisibility(false);
    win.maximize();
    win.loadURL("http://localhost:8080");

    win.once('ready-to-show', () => {
        win && win.show()
    });

    win.on("closed", () => {
        win = null;
    });
}
开发者ID:remipassmoilesel,项目名称:Abcmap,代码行数:15,代码来源:electron-main.ts

示例5: BrowserWindow

app.on('ready', () => {

    mainWindow = new BrowserWindow({
        width: 800,
        height: 600,
        backgroundColor: '#009688',
        minWidth: 300
    });

    mainWindow.setMenuBarVisibility(false);
    mainWindow.loadURL(`file://${__dirname.slice(0, Math.max(__dirname.lastIndexOf('/'), __dirname.lastIndexOf('\\')))}/index.html`);

    mainWindow.on('closed', () => {
        mainWindow = null;
    });

});
开发者ID:qsctr,项目名称:java-editor,代码行数:17,代码来源:main.ts

示例6: startMainWindow

function startMainWindow() {
    'use strict';

    const index_html = 'file://' + join(__dirname, '..', 'renderer', 'main.html');

    const default_config = {
        width: 800,
        height: 600,
        useContentSize: true,
        webPreferences: {
            blinkFeatures: 'KeyboardEventKey',
        },
        icon: nativeImage.createFromPath(join(__dirname, '..', 'resources', 'icon', 'nyaovim-logo.png')),
    } as Electron.BrowserWindowOptions;

    const user_config = browser_config.applyToOptions(default_config);

    let win = new BrowserWindow(user_config);

    const already_exists = browser_config.configSingletonWindow(win);
    if (already_exists) {
        app.quit();
        return null;
    }

    browser_config.setupWindowState(win);
    if (browser_config.loaded_config !== null && browser_config.loaded_config.show_menubar === false) {
        win.setMenuBarVisibility(false);
    }

    win.once('closed', function() {
        win = null;
    });

    win.loadURL(index_html);
    if (process.env.NODE_ENV !== 'production' && is_run_from_npm_package_on_darwin) {
        win.webContents.openDevTools({mode: 'detach'});
    }

    return win;
}
开发者ID:haifengkao,项目名称:NyaoVim-Unofficial,代码行数:41,代码来源:main.ts

示例7: BrowserWindow

	bus.addListener('git:askpass', (context: ICredentialsContext) => {
		var cachedResult = cache[context.id];

		if (typeof cachedResult !== 'undefined') {
			bus.emit('git:askpass:' + context.id, cachedResult.credentials);
			return;
		}

		if (context.command === 'fetch') {
			bus.emit('git:askpass:' + context.id, { id: context.id, credentials: { username: '', password: '' }});
			return;
		}

		var win = new BrowserWindow({
			alwaysOnTop: true,
			skipTaskbar: true,
			resizable: false,
			width: 450,
			height: platform.isWindows ? 280 : 260,
			show: true,
			title: env.product.nameLong
		});

		win.setMenuBarVisibility(false);

		cache[context.id] = {
			window: win,
			credentials: null
		};

		win.loadURL(require.toUrl('vs/workbench/parts/git/electron-main/index.html'));
		win.webContents.executeJavaScript('init(' + JSON.stringify(context) + ')');

		win.once('closed', () => {
			bus.emit('git:askpass:' + context.id, cache[context.id].credentials);

			setTimeout(function () {
				delete cache[context.id];
			}, 1000 * 10);
		});
	});
开发者ID:1833183060,项目名称:vscode,代码行数:41,代码来源:index.ts

示例8: onPublishProject

function onPublishProject(event: Electron.IpcMainEvent, options: PublishOptions) {
  const exportWindow = new electron.BrowserWindow({
    title: "Superpowers", icon: `${__dirname}/public/images/icon.png`,
    width: 1000, height: 600, minWidth: 800, minHeight: 480, useContentSize: true,
    webPreferences: { nodeIntegration: false, preload: `${__dirname}/SupApp/index.js` }
  });

  exportWindow.setMenuBarVisibility(false);
  exportWindow.loadURL(`${options.baseURL}:${options.mainPort}/build.html`);
  exportWindow.webContents.addListener("did-finish-load", startExport);

  function startExport() {
    exportWindow.webContents.removeListener("did-finish-load", startExport);
    exportWindow.webContents.send("set-export-status", { title: "Superpowers — Exporting...", text: "Exporting..." });

    let isFolderEmpty = false;
    try { isFolderEmpty = fs.readdirSync(options.outputFolder).length === 0; }
    catch (e) { exportWindow.webContents.send("set-export-status", { text: `Error while checking if output folder is empty: ${e.message}` }); return; }
    if (!isFolderEmpty) { exportWindow.webContents.send("set-export-status", { text: "Output folder must be empty." }); return; }

    exportWindow.setProgressBar(0);
    let progress = 0;
    const progressMax = options.files.length;
    const buildPath = `/builds/${options.projectId}/${options.buildId}`;
    const systemsPath = "/systems/";

    async.eachLimit(options.files, 10, processFile, onExportFinished);

    function processFile(file: string, cb: (err: Error) => any) {
      let outputFilename = file;
      if (startsWith(outputFilename, buildPath)) {
        // Project build files are served on the build port
        outputFilename = outputFilename.substr(buildPath.length);
        file = `${options.baseURL}:${options.buildPort}${file}`;
      } else {
        // Other files are served on the main port
        file = `${options.baseURL}:${options.mainPort}${file}`;

        if (startsWith(outputFilename, systemsPath)) {
          // Output system files at the root
          outputFilename = outputFilename.substr(outputFilename.indexOf("/", systemsPath.length));
        }
      }
      outputFilename = outputFilename.replace(/\//g, path.sep);

      const outputPath = `${options.outputFolder}${outputFilename}`;
      exportWindow.webContents.send("set-export-status", { text: outputPath });

      http.get(file, (response) => {
        mkdirp(path.dirname(outputPath), (err: Error) => {
          const localFile = fs.createWriteStream(outputPath);
          localFile.on("finish", () => { progress++; exportWindow.setProgressBar(progress / progressMax); cb(null); });
          response.pipe(localFile);
        });
      }).on("error", cb);
    }
  }

  function onExportFinished(err: Error) {
    exportWindow.setProgressBar(-1);
    if (err != null) { alert(err); return; }
    exportWindow.webContents.send("set-export-status", {
      title: "Superpowers — Exported",
      text: "Exported to ",
      showItemInFolder: { text: options.outputFolder, target: options.outputFolder }
    });
  }
}
开发者ID:AgileJoshua,项目名称:superpowers-app,代码行数:68,代码来源:ipc.ts

示例9: BrowserWindow

const showWindow = () => {
  let aboutWindow: BrowserWindow | undefined;

  if (!aboutWindow) {
    aboutWindow = new BrowserWindow({
      alwaysOnTop: true,
      backgroundColor: '#ececec',
      fullscreen: false,
      height: WINDOW_SIZE.HEIGHT,
      maximizable: false,
      minimizable: false,
      resizable: false,
      show: false,
      title: config.NAME,
      webPreferences: {
        javascript: false,
        nodeIntegration: false,
        nodeIntegrationInWorker: false,
        preload: PRELOAD_JS,
        session: session.fromPartition('about-window'),
        webviewTag: false,
      },
      width: WINDOW_SIZE.WIDTH,
    });
    aboutWindow.setMenuBarVisibility(false);

    // Prevent any kind of navigation
    // will-navigate is broken with sandboxed env, intercepting requests instead
    // see https://github.com/electron/electron/issues/8841
    aboutWindow.webContents.session.webRequest.onBeforeRequest(
      {
        urls: ['*'],
      },
      (details, callback) => {
        const url = details.url;

        // Only allow those URLs to be opened within the window
        if (ABOUT_WINDOW_WHITELIST.includes(url)) {
          return callback({cancel: false});
        }

        // Open HTTPS links in browser instead
        if (url.startsWith('https://')) {
          shell.openExternal(url);
        } else {
          console.log('Attempt to open URL in window prevented, url: %s', url);
        }

        callback({redirectURL: ABOUT_HTML});
      }
    );

    // Locales
    ipcMain.on(EVENT_TYPE.ABOUT.LOCALE_VALUES, (event: IpcMessageEvent, labels: i18nLanguageIdentifier[]) => {
      if (aboutWindow) {
        const isExpected = event.sender.id === aboutWindow.webContents.id;
        if (isExpected) {
          const resultLabels: {[index: string]: string} = {};
          labels.forEach(label => (resultLabels[label] = locale.getText(label)));
          event.sender.send(EVENT_TYPE.ABOUT.LOCALE_RENDER, resultLabels);
        }
      }
    });

    // Close window via escape
    aboutWindow.webContents.on('before-input-event', (event, input) => {
      if (input.type === 'keyDown' && input.key === 'Escape') {
        if (aboutWindow) {
          aboutWindow.close();
        }
      }
    });

    aboutWindow.on('closed', () => (aboutWindow = undefined));

    aboutWindow.loadURL(ABOUT_HTML);

    aboutWindow.webContents.on('dom-ready', () => {
      if (aboutWindow) {
        aboutWindow.webContents.send(EVENT_TYPE.ABOUT.LOADED, {
          copyright: pkg.copyright,
          electronVersion: pkg.version,
          environment: pkg.environment,
          productName: pkg.productName,
          webappVersion: webappVersion,
        });
      }
    });
  }

  aboutWindow.show();
};
开发者ID:wireapp,项目名称:wire-desktop,代码行数:92,代码来源:AboutWindow.ts


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