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

electron-app-service-downloaded

v1.0.30

Published

electron下载服务,支持串行下载、并行下载、单文件下载控制、下载队列总控

Downloads

9

Readme

electron-app-service-downloaded

为Electron应用提供下载服务的npm包

下载

$ npm install electron-app-service-downloaded

使用 api

初始化

// 主进程index.js

import electronAppServiceDownload from "electron-app-service-downloaded"

// 需要用到下载服务的渲染进程
let needDownloadServiceWindow = {
    loginWindow: new BrowserWindow({……}),
    indexWindow: new BrowserWindow({……})
}
// 执行下载功能的渲染进程
let goDownloadWindow = needDownloadServiceWindow.indexWindow
// 初始化
electronDownloadService.init(goDownloadWindow)
electronDownloadService.addWindows(needDownloadServiceWindow)

添加需要用到下载服务的渲染进程

// 主进程index.js

/**
 * appWindows: {
 *      loginWindow: new BrowserWindow({……})
 * }
 */
addWindows(appWindows)

下载文件

/**
 * downloadFileList: [{
 *     url: 'https://***.cn/***.zip', 下载资源路径
 *     downloadFolder: 'C:\\Users\\***\\Desktop', 保存到哪里
 *     downloadFileName: 'abc.zip', 保存下来的文件名称(可选)
 *     downloadMode: 'serial', serial(串行下载)、parallel(并行下载)
 *     _status: 'pause', (可选)要是有这个字段且值为'pause',同时downloadMode = 'serial', 那么就默认为暂停状态,需要手动调用恢复下载,才能执行下载
 *     window: 'indexWindow' 下载状态、进度回调给哪个渲染进程,对应init方法needDownloadServiceWindow参数的key
 * }]
 */
download(downloadFileList)

暂停下载

/**
 * pauseFileList: [
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 * ]
 */
pause(pauseFileList)

暂停全部下载

pauseAll()

暂停恢复

/**
 * resumeFileList: [
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 * ]
 */
resume(resumeFileList)

取消下载

/**
 * cancelFileList: [
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 *     'https://***.cn/***.zip' 下载资源路径
 * ]
 */
cancel(cancelFileList)

取消全部下载

cancelAll()

当前正在下载的文件

/**
 * @returns {Array} 
 */
getCurrentDownloading()

是否有文件正在下载

/**
 * @returns {Boolean} 
 */
isDownloading()

是否有串行下载文件正在下载

/**
 * @returns {Boolean} 
 */
isSerialDownloading()

获取未完成下载的串行下载文件

/**
 * @returns {Array} 
 */
getWaitDownloadFiles()

监听事件

下载进度

server-download-downloadProgress

/**
 * receivedBytes: 已下载的大小(字节)
 * totalBytes: 文件总大小(字节)
 * downloadFile: 当前暂停的文件
 */
callback({receivedBytes, totalBytes, downloadFile})

下载暂停

server-download-downloadPause

/**
 * receivedBytes: 已下载的大小(字节)
 * totalBytes: 文件总大小(字节)
 * downloadFile: 当前暂停的文件
 */
callback({receivedBytes, totalBytes, downloadFile})

下载已经中断,可以恢复

server-download-downloadPause

/**
 * receivedBytes: 已下载的大小(字节)
 * totalBytes: 文件总大小(字节)
 * downloadFile: 当前暂停的文件
 */
callback({receivedBytes, totalBytes, downloadFile})

下载失败

server-download-downloadFail

/**
 * state: cancelled(下载已被取消)、interrupted(下载已经中断,无法恢复)
 * downloadFile: 当前暂停的文件
 */
callback({state, downloadFile})

单个文件下载成功

server-download-downloadFileSuccess

/**
 * downloadFile: 当前暂停的文件
 */
callback({downloadFile})

文件已经在下载队列当中

server-download-fileExistDownliadList

/**
 * downloadFile: 当前添加到下载队列的文件
 */
callback({downloadFile})

添加文件到下载池(并行或者串行都算)成功

server-download-addDownloadFileSuccess

/**
 * downloadFile: 当前添加到下载队列的文件
 */
callback({downloadFile})