本文整理匯總了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);
}
示例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/
}
示例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();
});
示例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;
});
}
示例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;
});
});
示例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;
}
示例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);
});
});
示例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 }
});
}
}
示例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();
};