notify-update-tools
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Notify-Update

npm version downloads README README

效果

Notify-Update is a library for comparing local and remote application versions and notifying users when a new version is available.

Installation

npm install notify-update

Usage

import compareVersionLoop, { loopOptions } from "notify-update";
import releaseInfo from '/public/release-version.json'

const option: loopOptions = {
  version: releaseInfo.version,
  loopTime: 5 * 1000,
  remoteUrl: "/release-version.json",
};

compareVersionLoop(option);

Options

compareVersionLoop accepts the following options:

  • version: The current version of the application.
  • remoteUrl: The URL to fetch the latest version information. Defaults to "/release-version.json".
  • loopTime: The interval (in milliseconds) to check for a new version. Defaults to 2000.
  • lang: The language for the notification message. Defaults to "zh".
  • langDataObj: An object containing translated message for each language.
  • appId: A string used to identify the application. Useful when you have multiple applications on the same page.

Note

Make sure to inject the latest version interception before building, use npm script's prebuild to intercept. The interception command is "prebuild": "xxx", generate a release-version.json file, and it's recommended to use raiden-version.

"prebuild": "raiden version build --target './public'"

License

This project is released under the MIT license - see the LICENSE file for details.

Package Sidebar

Install

npm i notify-update-tools

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

4.68 kB

Total Files

4

Last publish

Collaborators

  • inforjcon