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

uve-request

v1.1.26

Published

基于 axios 封装的请求库

Readme

uve-request

uve-request 是一个基于 axios 封装的高性能、多功能请求库,专为现代前端开发设计。它集成了加密、自动 Loading 管理、浙里办 (ZLB) 适配、Vue 插件支持等常用功能。

特性

  • 🚀 基于 Axios: 继承了 Axios 的所有优秀特性。
  • 🔐 安全性: 内置 SM4 (国密)、AES、SHA256 等多种加密方式。
  • 📦 单文件打包: 采用 Vite 进行库模式打包,提供 ESM 和 UMD 格式。
  • 🛠️ 浙里办适配: 内置 mgop 适配,支持 IRS 加密转发。
  • 🔄 自动 Loading: 配合 Store 自动管理请求状态。
  • 📥 实用工具: 内置文件下载、Blob 转换、参数序列化等工具。
  • 🔌 Vue 插件: 支持 Vue 3 插件式安装,无缝集成到全局属性。

安装

npm install uve-request
# 或者
yarn add uve-request

快速上手

基础用法

import request from 'uve-request';

// 发送一个 GET 请求
request.get('/api/user', { id: 1 }).then(res => {
  console.log(res);
});

// 发送一个 POST 请求
request({
  url: '/api/update',
  method: 'post',
  data: { name: 'Antigravity' }
}).then(res => {
  console.log(res);
});

在 Vue 3 中使用

import { createApp } from 'vue';
import request from 'uve-request';
import App from './App.vue';

const app = createApp(App);

app.use(request, {
  baseURL: 'https://api.example.com',
  tokenField: 'Authorization',
  successCode: [200, 2000],
  // 其他配置...
});

app.mount('#app');

// 在组件中通过 proxy 访问
// proxy.axios.get(...)

全局配置 (Options)

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | baseURL | string | "" | 基础 URL | | useStore | () => Store | null | 返回一个包含 token 和 requests(Set) 的对象,用于状态管理 | | successCode | number[] | [200, 2000] | 业务成功的状态码 | | codeField | string \| string[] | "code" | 业务状态码字段名 | | messageField | string \| string[] | ["errorMsg", "msg", "message"] | 错误信息字段名 | | tokenField | string | "Authorization" | 请求头中 Token 的字段名 | | timeout | number | - | 请求超时时间 | | onlySm4 | boolean | false | 是否仅使用 SM4 加密(不进行 base64) |

加密功能

SM4 加密

支持配置全局或单个请求的 SM4 加密。

request({
  url: '/api/secure',
  sm4Key: 'your-secret-key',
  encryptKey: 'data', // 需要加密的字段
  data: {
    data: 'sensitive info'
  }
});

AES 加密

通过 aesKey 和配置中的 aesStr 实现。

浙里办 (ZLB) 支持

当设置了 zlbApi 且配置了 zlbAppKey 时,库会自动切换到 mgop 适配器。

request({
  url: 'irs-api-path',
  zlbApi: 'mgop.xxxx.yyyy',
  method: 'post',
  data: { ... }
});

实用工具

  • download(data, filename, isLink): 通用下载方法。
  • requestAll(promises, setLoading): 合并多个请求,统一管理 Loading。
  • cancelAll(promises, message): 批量取消请求。
  • transParams(params): 将对象转为 URL 查询字符串。

许可证

MIT