npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@htyf-desktop/electron-tabs-browser

v1.0.7

Published

electron-tabs-browser

Downloads

21

Readme

electron-tabs-browser

electron tabs 多窗口, 可分离

./screenshot.png

Install

npm i electron-tabs-browser

使用

1. 在 主进程 实例化 tabsBrowser

import tabsBrowser from 'electron-tabs-browser/main';

let browser;

browser = new tabsBrowser({
  tabPosition: 'top',
  controlSize: 99,
  controlPanel: 'renderer/you-control-interface.html',
  startPage: 'https://page-to-load-once-open',
  blankTitle: 'New tab',
  debug: true // 是否打开controlPanel的devtools
});

// 在新选项卡上创建触发器
browser.on('new-tab', ({ webContents }) => {
  // 自定义webContents
});

browser.on('closed', () => {
  // 垃圾回收
  browser = null;
});

2. 在渲染器进程进行tab标签栏开发

要使tabs导航栏界面工作,有两个步骤:

  • 设置ipc通道来接收tabs选项卡的信息
  • 发送操作来控制行为

你必须在tabs导航栏中设置ipc通道,有三个步骤:

  • ipcRenderer.send('control-ready') tabs导航栏加载完成
  • ipcRenderer.on('tabs-update', (e, tabs) => { // tabs updated }) 监听tabs更新
  • ipcRenderer.on('active-update', (e, activeID) => { // Active tab's id updated }) 监听tabs选项卡的id已更新

不要忘记在控制面板卸载后在ipcRendererremoveListener

设置ipc通道后,将获得tabs面板的所有信息:

  • tabs 对象包含打开的选项卡的所有信息
  • tabIDs 打开选项卡id的数组
  • activeID 当前活动选项卡的id

按业务开发和设计tabs选项卡界面。

然后您可以发送操作来控制浏览器视图,这些操作可以从 electron-tabs-browser/renderer:

import {
  // 告诉tabs标签栏准备好了
  sendControlReady,
  // 告诉BV加载url
  sendEnterURL, // sendEnterURL(url) to load url
  // 告诉BV 地址栏中的url已更改
  sendChangeURL, // sendChangeURL(url) on addressbar input change
  // 告诉BV回退
  sendGoBack,
  // 告诉BV goForward
  sendGoForward,
  // 告诉BV重新加载
  sendReload,
  // 告诉BV关闭选项卡
  sendNewTab, // sendNewTab([url])
  // 告诉BV切换到指定的选项卡
  sendSwitchTab, // sendSwitchTab(toID)
  // 告诉BV视图关闭选项卡
  sendCloseTab, // sendCloseTab(id)
  // 告诉BV切换新开窗口
  sendMoveNewWindow,
  // 监听tabs更新
  onTabsUpdate,
  // 监听活动当前活动tab
  onActiveUpdate,
  // 监听配置改变
  onOptionsChange,
} from 'electron-tabs-browser/renderer';

完整的控制接口实现参见example

运行 Example

  • yarn install && cd example/renderer && yarn
  • yarn dev