本文整理汇总了TypeScript中electron.BrowserWindow.addDevToolsExtension方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserWindow.addDevToolsExtension方法的具体用法?TypeScript BrowserWindow.addDevToolsExtension怎么用?TypeScript BrowserWindow.addDevToolsExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.BrowserWindow
的用法示例。
在下文中一共展示了BrowserWindow.addDevToolsExtension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: windowBounds
app.on("ready", () => {
const bounds = windowBounds();
let options: Electron.BrowserWindowOptions = {
webPreferences: {
experimentalFeatures: true,
experimentalCanvasFeatures: true,
},
titleBarStyle: "hidden",
resizable: true,
minWidth: 500,
minHeight: 300,
width: bounds.width,
height: bounds.height,
x: bounds.x,
y: bounds.y,
show: false,
};
const browserWindow = new BrowserWindow(options);
if (process.env.REACT_EXTENSION_PATH) {
BrowserWindow.addDevToolsExtension(process.env.REACT_EXTENSION_PATH);
}
browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
browserWindow.on("focus", () => app.dock && app.dock.setBadge(""));
browserWindow.webContents.on("did-finish-load", () => {
browserWindow.show();
browserWindow.focus();
});
app.on("open-file", (event, file) => browserWindow.webContents.send("change-working-directory", file));
});
示例2: findReact
app.on("ready", () => {
// Remove all extensions that were added in previous runs in case they are outdated or not needed.
_.forEach(BrowserWindow.getDevToolsExtensions(), extension => BrowserWindow.removeDevToolsExtension(extension.name));
if (isDevelopment) {
app.on("browser-window-created", (err, win) => {
win.webContents.toggleDevTools();
});
let react = findReact(process);
if (react.exists()) {
console.info("Loading React dev tools from", react.path);
BrowserWindow.addDevToolsExtension(react.path);
}
}
let window: Electron.BrowserWindow | null = new BrowserWindow({
alwaysOnTop: true,
webPreferences: {
nodeIntegration: false,
partition: "persist:session",
plugins: true,
allowDisplayingInsecureContent: true,
allowRunningInsecureContent: true
}
});
window.on("closed", () => {
window = null;
});
(window as any).setMenu(null);
window.loadURL("https://www.netflix.com");
});
示例3: catch
Electron.app.on("ready", () => {
if (config.data.vueDevTool) {
try {
Electron.BrowserWindow.addDevToolsExtension(config.data.vueDevTool);
} catch (e) {
console.log("failed to load devtools extension");
}
}
showMainWindow();
});
示例4: function
app.on("ready", async function() {
// make sure there is only one instance of this application
// var gotTheLock = app.requestSingleInstanceLock();
// if (!gotTheLock) {
// app.quit();
// return;
// }
app.on("second-instance", function(event, commandLine, workingDirectory) {
const projectFilePath = commandLine[commandLine.length - 1];
if (projectFilePath.toLowerCase().endsWith(".eez-project")) {
openFile(projectFilePath);
} else {
const {
bringHomeWindowToFocus
} = require("main/home-window") as typeof HomeWindowModule;
bringHomeWindowToFocus();
}
});
const { loadSettings } = require("main/settings") as typeof SettingsModule;
loadSettings();
await setup();
require("eez-studio-shared/service");
// start with:
// npm start devToolsExtension="C:\Users\mvladic\AppData\Local\Google\Chrome\User Data\Default\Extensions\fmkadmapgofadopljbjfkapdkoienihi\3.4.2_0"
if (process.argv.length > 2 && process.argv[2].startsWith("devToolsExtension=")) {
BrowserWindow.addDevToolsExtension(process.argv[2].substr("devToolsExtension=".length));
}
if (projectFilePath) {
openFile(projectFilePath);
} else {
const projectFilePath = process.argv[process.argv.length - 1];
if (projectFilePath.toLowerCase().endsWith(".eez-project")) {
openFile(projectFilePath);
} else {
const { openHomeWindow } = require("main/home-window") as typeof HomeWindowModule;
openHomeWindow();
}
}
require("main/menu");
setupFinished = true;
});
示例5: async
const installExtension = async (extensionID: string) => {
try {
const url = `https://clients2.google.com/service/update2/crx?response=redirect&prodversion=49.0&x=id%3D${extensionID}%26installsource%3Dondemand%26uc`;
const extensionPath = path.resolve(app.getPath('temp'), 'extensions');
const downloadPath = path.resolve(extensionPath, `${extensionID}.crx`);
const unzipPath = path.resolve(extensionPath, extensionID);
rimraf.sync(unzipPath);
mkdirp.sync(unzipPath);
const res = await axios.get<ArrayBuffer>(url, {
responseType: 'arraybuffer',
});
const buffer = Buffer.from(res.data);
await promisify(fs.writeFile)(downloadPath, buffer, { encoding: null });
await unzip(downloadPath, unzipPath);
BrowserWindow.addDevToolsExtension(unzipPath);
} catch (error) {
console.error(error);
}
};
示例6: async
//.........这里部分代码省略.........
quitting: false,
};
store.dispatch(actions.systemAssessed({ system }));
try {
await loadPreferences(store);
} catch (e) {
logger.error(
`Could not load preferences: ${e.stack || e.message || e}`
);
}
try {
const netSession = session.fromPartition(NET_PARTITION_NAME, {
cache: false,
});
const envSettings: string =
process.env.https_proxy ||
process.env.HTTPS_PROXY ||
process.env.http_proxy ||
process.env.HTTP_PROXY;
let proxySettings = {
proxy: null as string,
source: "os" as ProxySource,
};
if (envSettings) {
logger.info(`Got proxy settings from environment: ${envSettings}`);
proxySettings = {
proxy: envSettings,
source: "env",
};
testProxy = true;
store.dispatch(actions.proxySettingsDetected(proxySettings));
}
await applyProxySettings(netSession, proxySettings);
} catch (e) {
logger.warn(
`Could not detect proxy settings: ${e ? e.message : "unknown error"}`
);
}
if (env.production && env.appName === "itch") {
try {
app.setAsDefaultProtocolClient("itchio");
app.setAsDefaultProtocolClient("itch");
} catch (e) {
logger.error(
`Could not set app as default protocol client: ${e.stack ||
e.message ||
e}`
);
}
}
} catch (e) {
throw e;
} finally {
const t2 = Date.now();
logger.info(`preboot ran in ${elapsed(t1, t2)}`);
}
store.dispatch(actions.prebootDone({}));
let devtoolsPath = process.env.ITCH_REACT_DEVTOOLS_PATH;
if (!devtoolsPath && env.development) {
let reactDevtoolsId = "fmkadmapgofadopljbjfkapdkoienihi";
let devtoolsFolder = path.join(
app.getPath("home"),
"AppData",
"Local",
"Google",
"Chrome",
"User Data",
"Default",
"Extensions",
reactDevtoolsId
);
try {
const files = fs.readdirSync(devtoolsFolder);
let version = files[0];
if (version) {
devtoolsPath = path.join(devtoolsFolder, version);
logger.info(`Found React devtools at ${devtoolsPath}`);
}
} catch (e) {
logger.warn(`Could not find react devtools at ${devtoolsFolder}: ${e}`);
}
}
if (devtoolsPath) {
try {
logger.info(`Adding react devtools from ${devtoolsPath}`);
BrowserWindow.addDevToolsExtension(devtoolsPath);
} catch (e) {
logger.error(`While adding react devtools path: ${e.stack}`);
}
}
});