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

luck-pc-client

v1.0.0

Published

My Electron application description

Downloads

3

Readme

简介

跨平台PC客户端,支持Windows(win7+)、MacOs、Linux(后续)。

安装依赖

// 设置electron等镜像源到国内,解决安装过程中卡住的问题
npm config set registry https://registry.npm.taobao.org
npm set electron_mirror https://npm.taobao.org/mirrors/electron/
npm i

启动

npm start

以调试模式启动:

npm run debug

打包成可执行文件

npm run make

执行后,打包文件在应用目录out/make中。

注:如上的命令只能打包当前系统环境的可执行文件,比如windows系统只能打包win环境的可执行文件。如果想实现多平台的打包,可使用Github持续集成工具Github Action,示例文件在应用.github/workflows/node.js.yml文件中。

添加附加文件

例如win7等系统需要在安装应用前安装些依赖,比如.net45vc++等,打包完成时可以将这些文件拷入最终打包好的目录,当然这些依赖目前版本仍需要手动安装。

所有的依赖文件统一放在根目录depends下,子文件夹以系统命名。

如下的命令会在打包完成后将depends/win7目录下的所有目录拷入:

npm run make -- --depends win7

原生模块

如果使用的插件中含有nodejs原生模块,比如luck-pc-client-usb,在启动前需要对electron进行重新编译,命令如下:

./node_modules/.bin/electron-rebuild

注:原生模块的开发请参考luck-mtp项目。

分发

目前提供三中分发方式。

方式一

手动将各平台的make目录下的可执行文件手动整理分发。

方式二

将打包后可执行文件推送到Github Releases中进行分发。

如下命令先将应用打包成可执行文件,并推送到Github

npm run publish -- --target @electron-forge/publisher-github

推送配置在应用根目录下forge.config.js文件publishers属性中:

publishers: [
    {
      name: '@electron-forge/publisher-github',
      config: {
        repository: {
          owner: 'lucksoft-yungui',
          name: 'pc-client'
        },
        authToken: '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',
        prerelease: true
      }
    }
  ],

注:可以通过Github持续集成工具Github Action,实现多平台的自动打包发布。

方式三

如果有私有云分发和自动更新需求,可以启用pc-client-update-server客户端分发服务。

如下命令先将应用打包成可执行文件,并推送到pc-client-update-server

npm run publish -- --target @electron-forge/publisher-nucleus

推送配置在应用根目录下forge.config.js文件publishers属性中:

publishers: [
     {
      name: '@electron-forge/publisher-nucleus',
      config: {
        host: pubConfig.nucleus.host,
        appId: pubConfig.nucleus.appId,
        channelId: config.autoUpdate.channel,
        token: pubConfig.nucleus.token // This should be set securely
      }
    }
  ]

配置

配置文件位于应用代码根目录config目录下。

应用配置

参考配置文件./config/conf.js注释。

打包配置

参考配置文件./config/publish.js注释。

使用配置

主应用和子插件可以通过如下代码访问配置:

console.log('homePage',app.appConfig.homePage);

国际化

国际化文件在应用代码根目录locales下。

应用和子插件可以通过使用如下方式使用国际化:

console.log('exit',app.i18n.__('exit'));

日志

日志分为应用日志开发日志

应用在加载时重写了console.log方法,在正常输出到开发环境外,同时也会生成对应的日志文件到相应的目录。

应用日志

应用日志存储在应用用户数据目录appDataPath下的./logs/main.log文件中。

开发日志

开发日志如打包时的日志,存储在应用开发根logs下。

插件模式

采用插件模式来保证主应用的轻量和可扩展,项目上可根据需要灵活选择集成哪个插件,插件模式有利于应用核心功能的版本化,避免应用主体过于臃肿和耦合。

开发标准

插件包名统一以luck-pc-client-为前缀,应用启动时会扫描package.json文件dependencies节点中以该前缀的包,并自动装载进应用。

入口文件

插件包必须包含如下两个文件:

  • preload.js:主进程与渲染进程间的桥接文件;
  • index.js:插件代码入口文件;

每次应用启动时会将插件中的这两个文件自动装载。

项目结构

以工作空间的方式管理主体应用和插件,如图:

picture 1

开发模式下,可以通过如下命令连接各个插件到主应用:

npm link luck-pc-client-app
npm link luck-pc-client-server

主应用根据项目需要自行fork到自己的项目中进行管理。

ToDo

  • 将demo与应用主体分离
  • SQlite插件
  • 文件处理处理插件
  • 自动更新插件