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

@bugonly/electron-update-sdk

v0.1.2

Published

基于 electron-updater 封装的更新服务组件。

Downloads

5

Readme

@bugonly/electron-update-sdk

基于 electron-updater 封装的更新服务组件。

安装

#yarn 
yarn add @bugonly/electron-update-sdk
#npm
npm i @bugonly/electron-update-sdk

使用

Electron 主进程

Electron 需要同时在主进程和预加载脚本中引入 SDK。

主进程引入:

import updateService from '@bugonly/electron-update-sdk/libs/main';

const mainWindow = createWindow('main', {
  width: 1000,
  height: 800,
  webPreferences: {
    preload: path.join(__dirname, 'preload.js')
  }
});
// 接入 updateService
updateService.setup(mainWindow, {
  // 获取更新信息的URL
  feedUrl: 'https://xxx.com/xxx'
});

预加载脚本引入:

import { contextBridge } from 'electron';
import updateServicePreload from '@bugonly/electron-update-sdk/libs/preload';

contextBridge.exposeInMainWorld(updateServicePreload.name, updateServicePreload.content);

渲染进程

import { UpdateServiceRenderer } from '@bugonly/electron-update-sdk/libs/renderer';

const updateRenderer = new UpdateServiceRenderer({
  // 是否使用 SDK 默认的UI提示,默认为 true,建议自定义
  renderUi: false
});
// 检查更新
updateRenderer.checkUpdate(false);

功能API

updateRenderer.checkUpdate(slient:boolean)

主动检查更新,入参 slienttrue时,当检查中或没有更新时不显示UI提示。

updateRenderer.confirmDownload()

确认下载更新包,一般是在自定义UI中使用。

updateRenderer.confirmUpdate()

确认安装更新包,一般是在自定义UI中使用。

事件回调 API

可通过生命周期各阶段的事件回调执行自定义逻辑或者自定义UI提示(前提设置renderUifalse)。

updateRenderer.onCheckingUpdate(callback)

自定义回调:检测更新中

updateRenderer.onUpdateFail(callback)

自定义回调:更新失败

updateRenderer.onNoUpdate(callback)

自定义回调:没有更新版本

updateRenderer.onNeedUpdate(callback)

自定义回调:有新版本

此时可调用updateRenderer.confirmDownload()下载更新包。

updateRenderer.onDownloading(callback)

自定义回调:更新包下载中

updateRenderer.onDownloadSuccess(callback)

自定义回调:更新包下载完成

此时可调用updateRenderer.confirmUpdate()安装更行包

默认提示UI

检查更新

有可用更新

下载中

下载成功

错误提示