當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。