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 🙏

© 2025 – Pkg Stats / Ryan Hefner

uniapp-version-plugin

v1.0.0

Published

A webpack plugin for UniApp projects to check and update page versions

Readme

工作原理

  1. 版本生成

    • 构建时为每个HTML文件生成MD5签名
    • 将签名信息写入 version.json 文件
    • 在HTML文件的head标签中注入版本信息
  2. 版本检查

    • 页面加载时自动检查版本
    • 当用户从其他标签页切回时检查版本
    • 发现新版本时自动刷新页面
  3. 防刷新保护

    • 在5分钟时间窗口内最多允许刷新3次
    • 超过限制后会显示提示信息
    • 等待时间窗口结束后自动重置计数

配置选项

| 选项 | 类型 | 默认值 | 描述 | |------|------|--------|------| | filename | string | 'version.json' | 生成的版本文件名称 | | checkFilename | string | 'version-check.[hash].js' | 生成的检查脚本文件名称,支持 [hash] 占位符 | | outputPath | string | 'static/js' | 生成文件的输出路径 |

生成的文件

  1. version.json json { "index.html": "d41d8cd98f00b204e9800998ecf8427e", "pages/about.html": "7d793037a0760186574b0282f2f435e7" }

  2. version-check.js

  • 压缩后的版本检查脚本
  • 包含防刷新保护机制
  • 自动处理版本检查和页面刷新

注意事项

  1. 确保HTML模板中包含 </head> 标签,插件需要在此处注入版本信息
  2. 插件会自动注入带有hash的检查脚本,无需手动引入
  3. 如果使用了 CDN,需要确保 version.json 的路径正确

常见问题

Q: 如何修改刷新限制的次数和时间窗口?

A: 目前这些值是固定的(5分钟内3次),如果需要修改,可以提issue我们会考虑添加配置项。

Q: 是否支持多页面应用?

A: 是的,插件会自动处理所有HTML文件,并为每个文件生成独立的版本签名。

Q: 如何处理版本检查失败的情况?

A: 插件会在控制台输出错误信息,并重置刷新计数器。您可以通过网络请求失败来测试此功能。

License

MIT

作者

yxye

贡献指南

欢迎提交 issue 和 PR,让这个插件变得更好!

  1. Fork 本仓库
  2. 创建您的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的修改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开一个 Pull Request