@dpdfe/auto-upgrade
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Features

  • 前端上线后,路由跳转时自动升级

安装

  • 使用 npm:
npm i --save @dpdfe/auto-upgrade
  • 引入
import reloadSiteWhenRouteChange from '@dpdfe/auto-upgrade'

使用方法

在你的入口文件中,引入 reloadSiteWhenRouteChange 方法,并调用它

    reloadSiteWhenRouteChange();

支持 3 个可选参数配置

  • isInBlacklist: ()=>boolean

    如果有的页面不需要自动升级,可以配置一个函数,返回 true 表示不需要升级,false 表示需要升级

  • hasNewVersion: ()=> Promise;

    如果有的页面需要判断是否有新版本,可以配置一个函数,返回 Promise 对象,resolve(true) 表示有新版本,resolve(false) 表示没有新版本 默认检查 指定 url 的返回结果 是否发生变化来判断是否有新版本

  • online_url: string

    在没有传递 hasNewVersion 时生效,默认值为 window.location.origin, 通过检查 online_url 是否发生变化来判断是否有新版本

demo

reloadSiteWhenRouteChange({
    isInBlacklist: () => {
        return window.location.href.includes('/report');
    },
    online_url: 'http://XXX/demo',
});

Readme

Keywords

none

Package Sidebar

Install

npm i @dpdfe/auto-upgrade

Weekly Downloads

6

Version

1.0.3

License

ISC

Unpacked Size

24.3 kB

Total Files

28

Last publish

Collaborators

  • pearone
  • superhui
  • yuki_xu
  • jjjkkkhhhggg
  • bh20077