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


TypeScript electron.WebContents类代码示例

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


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

示例1: async

exports.waitForWebContentsToLoad = async (webContents: WebContents) => {
  const didFinishLoadPromise = emittedOnce(webContents, 'did-finish-load')
  if (webContents.isLoadingMainFrame()) {
    await didFinishLoadPromise
  }
}
开发者ID:doridoridoriand,项目名称:electron,代码行数:6,代码来源:window-helpers.ts

示例2:

 click: (item: object, focusedWindow: WebContents) => {
   if (focusedWindow) {
     focusedWindow.toggleDevTools();
   }
 }
开发者ID:nteract,项目名称:nteract,代码行数:5,代码来源:menu.ts

示例3: setupExtensions

async function setupExtensions(
    webContents: WebContents,
    resourcesPath: string,
    extensionsFolderPath: string
) {
    webContents.send("setupMessage", "Making extensions folder");
    await makeFolder(extensionsFolderPath);
    await delay(500);

    const fileList: string[] = [];

    fs.readdirSync(resourcesPath).forEach(fileName => {
        const filePath = resourcesPath + "/" + fileName;
        if (filePath.toLowerCase().endsWith(".zip")) {
            fileList.push(filePath);
        }
    });

    webContents.send("setupMessage", `Installing ${fileList.length} extensions`);

    const {
        installExtension
    } = require("eez-studio-shared/extensions/extensions") as typeof ExtensionsModule;

    for (let i = 0; i < fileList.length; i++) {
        const filePath = fileList[i];

        const fileName = path.basename(filePath);

        webContents.send("setupMessage", `Installing extension ${fileName}`);

        try {
            const extension = await installExtension(filePath, {
                notFound() {},
                async confirmReplaceNewerVersion(
                    newExtension: IExtension,
                    existingExtension: IExtension
                ) {
                    return true;
                },
                async confirmReplaceOlderVersion(
                    newExtension: IExtension,
                    existingExtension: IExtension
                ) {
                    return true;
                },
                async confirmReplaceTheSameVersion(
                    newExtension: IExtension,
                    existingExtension: IExtension
                ) {
                    return true;
                }
            });
            if (!extension) {
                webContents.send("setupMessage", {
                    error: `Failed to install ${fileName}`
                });
                await delay(1000);
            }
        } catch (err) {
            webContents.send("setupMessage", {
                error: `Failed to install ${fileName} (${err.toString()})`
            });
            await delay(1000);
        }
    }
}
开发者ID:eez-open,项目名称:studio,代码行数:67,代码来源:setup.ts

示例4: setupDatabase

async function setupDatabase(webContents: WebContents, resourcesPath: string, dbFilePath: string) {
    webContents.send("setupMessage", "Installing database");
    await copyFile(resourcesPath + "/init_storage.db", dbFilePath);
    await delay(500);
}
开发者ID:eez-open,项目名称:studio,代码行数:5,代码来源:setup.ts

示例5: loadURL

function loadURL(wc: WebContents, url: string) {
  if (ITCH_URL_RE.test(url)) {
    return;
  }
  wc.loadURL(url);
}
开发者ID:itchio,项目名称:itch,代码行数:6,代码来源:web-contents.ts


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