0.0.1 • Published 6 years ago

web-version-check v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

web-version-check

web project version checking


Install

$ npm i -D web-version-check

Options

参数说明type示例required
clientVersion浏览器客户端保存的版本号String'0.1.0'true
safeVersionUrl服务器端保存的版本文件路径String./version.jsonhttp://aa.bb.cc/site/version.jsontrue
fail校验失败时。即浏览器端与服务器端版本号不一致Functionfunction(res){}true
success校验成功时。即版本号一致Functionfunction() {}false

Usage

import webVersionCheck from 'web-version-check'
import { version } from './version.json'

webVersionCheck({
  clientVersion: version,
  safeVersionUrl: `./version.json?timestamp=${Date.now()}`,
  fail: function(res) {
    location.reload(true)
  },
  success: function() {
    console.log('success')
  }
})

version.json

{
  "version": "1.0.0"
}