
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
uve-request
Advanced tools
uve-request 是一个基于 axios 封装的高性能、多功能请求库,专为现代前端开发设计。它集成了加密、自动 Loading 管理、浙里办 (ZLB) 适配、Vue 插件支持等常用功能。
mgop 适配,支持 IRS 加密转发。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);
});
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(...)
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
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 加密。
request({
url: '/api/secure',
sm4Key: 'your-secret-key',
encryptKey: 'data', // 需要加密的字段
data: {
data: 'sensitive info'
}
});
通过 aesKey 和配置中的 aesStr 实现。
当设置了 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
FAQs
基于 axios 封装的请求库
We found that uve-request demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.