• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript electron.webContents类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: if

    (e: Electron.IpcMessageEvent, data: any) => {
      const contents = webContents.fromId(e.sender.id);
      const storage = global.databases[data.extensionId];
      const msg = API_STORAGE_OPERATION + data.id;

      if (data.type === 'get') {
        storage[data.area].get(data.arg, d => {
          for (const key in d) {
            if (Buffer.isBuffer(d[key])) {
              d[key] = JSON.parse(d[key].toString());
            }
          }
          contents.send(msg, d);
        });
      } else if (data.type === 'set') {
        storage[data.area].set(data.arg, () => {
          contents.send(msg);
        });
      } else if (data.type === 'clear') {
        storage[data.area].clear(() => {
          contents.send(msg);
        });
      } else if (data.type === 'remove') {
        storage[data.area].set(data.arg, () => {
          contents.send(msg);
        });
      }
    },
开发者ID:laquereric,项目名称:wexond,代码行数:28,代码来源:extensions-service.ts


示例2: makeId

const interceptRequest = (
  eventName: string,
  details: any,
  callback: any = null,
): boolean => {
  let isIntercepted = false;

  if (Array.isArray(eventListeners[eventName])) {
    for (const event of eventListeners[eventName]) {
      if (!matchesFilter(event.filters, details.url)) continue;

      const id = makeId(32);

      if (callback) {
        ipcMain.once(
          `api-webRequest-response-${eventName}-${event.id}-${id}`,
          (e: any, res: any) => {
            callback(res);
          },
        );
      }

      const contents = webContents.fromId(event.webContentsId);
      contents.send(
        `api-webRequest-intercepted-${eventName}-${event.id}`,
        details,
        id,
      );

      isIntercepted = true;
    }
  }

  return isIntercepted;
};
开发者ID:laquereric,项目名称:wexond,代码行数:35,代码来源:web-request.ts


示例3:

 Object.keys(global.backgroundPages).forEach(key => {
   const bgPage = global.backgroundPages[key];
   if (e.sender.id !== bgPage.webContentsId) {
     const contents = webContents.fromId(bgPage.webContentsId);
     contents.send(API_PORT_POSTMESSAGE + portId, msg);
   }
 });
开发者ID:laquereric,项目名称:wexond,代码行数:7,代码来源:extensions-service.ts


示例4: async

    async (e: Electron.IpcMessageEvent, data: any) => {
      const { extensionId, portId, sender, name } = data;
      const bgPage = global.backgroundPages[extensionId];

      if (e.sender.id !== bgPage.webContentsId) {
        const contents = webContents.fromId(bgPage.webContentsId);
        contents.send(API_RUNTIME_CONNECT, { portId, sender, name });
      }
    },
开发者ID:laquereric,项目名称:wexond,代码行数:9,代码来源:extensions-service.ts


示例5: onModelsUpdateHandler

/* Immediately notify all renderers about global model change */
function onModelsUpdateHandler():void
{
	allWebContents = electron.webContents.getAllWebContents();

	for (webContent of allWebContents)
	{
		//webContent.send(PokerGlobalDataVO.EVENT_MODEL_CHANGED);
	}
}
开发者ID:hivaga,项目名称:angular2-seed,代码行数:10,代码来源:start.desktop.ts


示例6: async

  watcher.on(actions.tabGotWebContents, async (store, action) => {
    const { wind, tab, webContentsId } = action.payload;
    const rs = store.getState();
    const initialURL = rs.winds[wind].tabInstances[tab].location.url;

    const wc = webContents.fromId(webContentsId);
    storeWebContents(wind, tab, wc);

    logger.debug(`Loading url '${initialURL}'`);
    await hookWebContents(store, wind, tab, wc as ExtendedWebContents);
    loadURL(wc, initialURL);
  });
开发者ID:itchio,项目名称:itch,代码行数:12,代码来源:web-contents.ts


示例7: deleteAccount

export async function deleteAccount(id: number, accountId: string, partitionId?: string) {
  // Delete session data
  try {
    const webviewWebcontent = webContents.fromId(id);
    if (!webviewWebcontent) {
      throw new Error(`Unable to find webview content id "${id}"`);
    }
    if (!webviewWebcontent.hostWebContents) {
      throw new Error('Only a webview can have its storage wiped');
    }
    logger.log(`Deleting session data for account "${accountId}"...`);
    await clearStorage(webviewWebcontent.session);
    logger.log(`Deleted session data for account "${accountId}".`);
  } catch (error) {
    logger.error(`Failed to delete session data for account "${accountId}", reason: "${error.message}".`);
  }

  // Delete the webview partition
  // Note: The first account always uses the default session,
  // therefore partitionId is optional
  // ToDo: Move the first account to a partition
  if (partitionId) {
    try {
      if (!ValidationUtil.isUUIDv4(partitionId)) {
        throw new Error('Partition is not an UUID');
      }
      const partitionDir = path.join(USER_DATA_DIR, 'Partitions', partitionId);
      await fs.remove(partitionDir);
      logger.log(`Deleted partition "${partitionId}" for account "${accountId}".`);
    } catch (error) {
      logger.log(`Unable to delete partition "${partitionId}" for account "${accountId}", reason: "${error.message}".`);
    }
  }

  // Delete logs for this account
  try {
    if (!ValidationUtil.isUUIDv4(accountId)) {
      throw new Error('Account is not an UUID');
    }
    const sessionFolder = path.join(LOG_DIR, accountId);
    await fs.remove(sessionFolder);
    logger.log(`Deleted logs folder for account "${accountId}".`);
  } catch (error) {
    logger.error(`Failed to delete logs folder for account "${accountId}", reason: "${error.message}".`);
  }
}
开发者ID:wireapp,项目名称:wire-desktop,代码行数:46,代码来源:LocalAccountDeletion.ts


示例8: it

    it('returns an array of web contents', async () => {
      w.loadFile(path.join(fixturesPath, 'pages', 'webview-zoom-factor.html'))

      await emittedOnce(w.webContents, 'did-attach-webview')

      w.webContents.openDevTools()

      await emittedOnce(w.webContents, 'devtools-opened')

      const all = webContents.getAllWebContents().sort((a, b) => {
        return a.id - b.id
      })

      expect(all).to.have.length(3)
      expect(all[0].getType()).to.equal('window')
      expect(all[all.length - 2].getType()).to.equal('webview')
      expect(all[all.length - 1].getType()).to.equal('remote')
    })
开发者ID:doridoridoriand,项目名称:electron,代码行数:18,代码来源:api-web-contents-spec.ts


示例9: setTimeout

  ipcMain.on(API_ALARMS_OPERATION, (e: Electron.IpcMessageEvent, data: any) => {
    const { extensionId, type } = data;
    const contents = webContents.fromId(e.sender.id);

    if (type === 'create') {
      const { name, alarmInfo } = data;
      const alarms = global.extensionsAlarms[extensionId];
      const exists = alarms.findIndex(e => e.name === name) !== -1;

      e.returnValue = null;
      if (exists) return;

      let scheduledTime = 0;

      if (alarmInfo.when != null) {
        scheduledTime = alarmInfo.when;
      }

      if (alarmInfo.delayInMinutes != null) {
        if (alarmInfo.delayInMinutes < 1) {
          return console.error(
            `Alarm delay is less than minimum of 1 minutes. In released .crx, alarm "${name}" will fire in approximately 1 minutes.`,
          );
        }

        scheduledTime = Date.now() + alarmInfo.delayInMinutes * 60000;
      }

      const alarm: ExtensionsAlarm = {
        periodInMinutes: alarmInfo.periodInMinutes,
        scheduledTime,
        name,
      };

      global.extensionsAlarms[extensionId].push(alarm);

      if (!alarm.periodInMinutes) {
        setTimeout(() => {
          contents.send(`api-emit-event-alarms-onAlarm`, alarm);
        }, alarm.scheduledTime - Date.now());
      }
    }
  });
开发者ID:laquereric,项目名称:wexond,代码行数:43,代码来源:extensions-service.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript electron.webFrame类代码示例发布时间:2022-05-25
下一篇:
TypeScript NsisUpdater.NsisUpdater类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap