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 🙏

© 2026 – Pkg Stats / Ryan Hefner

wx-wechat-login

v1.0.6

Published

微信登录组件

Readme

wx-wechat-login

一个基于 Vue 3 的通用微信扫码登录组件,支持二维码轮询登录状态、超时处理、刷新二维码等功能。可通过 npm 引入使用。

✨ 特性

  • Vue 3 + <script setup> 编写
  • 支持登录状态轮询与超时终止
  • 支持插槽自定义 UI
  • 提供灵活的事件钩子:登录成功、失败、超时、刷新
  • 支持按需加载 / 全局注册

📦 安装

npm install wx-wechat-login
# 或者
pnpm add wx-wechat-login

🔨 使用方式

1. 注册组件

局部注册

<script setup>
// 导入组件
import { WechatLogin } from 'wx-wechat-login'
// 导入样式
import 'wx-wechat-login/dist/wx-login.css'
</script>

<template>
  <WechatLogin ... />
</template>

全局注册(main.js/main.ts)

import { createApp } from 'vue'
import App from './App.vue'
import WechatLoginPlugin from 'wx-wechat-login'

const app = createApp(App)
app.use(WechatLoginPlugin)
app.mount('#app')

⚙️ 组件参数(Props)

| 属性名 | 类型 | 必填 | 说明 | |----------------|----------|------|------| | imgUrl | String | ✅ | 微信二维码图片地址 | | scene | String | ✅ | 唯一标识码,用于后台状态查询 | | getStatus | Function | ✅ | 轮询接口,请求返回登录状态(如 api.getWxStatus) | | onSuccess | Function | ✅ | 登录成功的回调,参数为接口返回的数据 | | onRefresh | Function | ❌ | 点击二维码过期层后的刷新操作 | | onTimeout | Function | ❌ | 二维码过期超时后的回调 | | onError | Function | ❌ | 接口报错或请求失败时的回调 | | expireSeconds| Number | ❌ | 过期时间(默认 60 秒) |


🔁 插槽 Slots

| 插槽名 | 说明 | |----------------|------| | title | 自定义顶部标题区域 | | expired-text | 自定义二维码过期遮罩文案 | | footer | 自定义底部内容(如其他登录方式) |


🧪 示例

<template>
  <WechatLogin
    :img-url="imgUrl"
    :scene="scene"
    :get-status="api.getWxStatus"
    :on-success="handleSuccess"
    :on-refresh="refreshQr"
    :expire-seconds="60"
  />
</template>
const handleSuccess = (token) => {
  // 保存 token 并跳转
}

const refreshQr = async () => {
  const res = await api.getWxQrCode()
  imgUrl.value = res.data.qr_url
  scene.value = res.data.scene
}

🚀 发布到 npm

步骤

  1. 修改 package.json 中 name、version、description 等字段
  2. 创建 .npmrc 并配置你的 npm token(或登录)
npm login
  1. 打包构建(如有):
vite build # 或 rollup build
  1. 发布:
npm publish --access public

📄 License

MIT