1.2.0 • Published 1 year ago

vue-check-update-plugin v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

为 vuecli 项目增加新版本检测功能

安装

npm i vue-check-update-plugin -D

使用

// vue.config.js
const CheckUpdatePlugin = require('vue-check-update-plugin')
module.exports = {
  configureWebpack: config => {
    if (process.env.NODE_ENV !== 'development') {
      config.plugins.push(
        new CheckUpdatePlugin({
          name: 'project-name-key', // 保持唯一
          version: '1.0.0', // 保持最新
          contents: ['修改了xxx Bug', '增加了xxx 新功能'] // 更新日志
        })
      )
    }
  }
}
// 在任意代码出调用此函数即可
Vue.prototype.$checkUpdate = function () {
  axios.get(window.location.origin + '/version.json?v=' + Date.now()).then(rsp => {
    const { version, title, contents } = rsp.data.data

    if (version === localStorage.getItem('project-name-key')) return

    this.$notify({
      title,
      duration: 0,
      showClose: true,
      dangerouslyUseHTMLString: true,
      message: contents.toString(),
      // 关闭后手动同步服务器上的最新版本号到本地
      onClose: () => window.syncVersion()
    })
  })
}

Props

参数名说明默认值
name唯一标识 (string/required)-
version更新的版本号(string/required)-
versionPath版本信息存放文件路径(string)dist/version.json
templatehtml 模板路径(string)dist/index.html
title版本更新大标题(string)-
syncName同步最新版本号函数名(string) windowsyncNamesyncVersion
contents版本更新日志(string[])[]
1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.0.10

2 years ago