Skip to content

Commit 9eaac09

Browse files
committed
feat(axios): 暴露底层 axios 实例 (request.instance) 以支持自定义拦截器
1 parent 06bd73f commit 9eaac09

File tree

4 files changed

+14
-53
lines changed

4 files changed

+14
-53
lines changed

.changeset/sharp-tigers-run.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ethan-utils/axios": minor
3+
---
4+
5+
feat: 暴露底层 axios 实例 (request.instance) 以支持自定义拦截器
6+
docs: 更新 README.md 和 package.json 配置

packages/axios/README.md

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -464,58 +464,7 @@ async function batchUpdate(
464464

465465
## 版本记录
466466

467-
### v2.0.0
468-
469-
**重大变更**
470-
471-
- 🔄 将 `direct` 命名空间改为 `std`(标准响应)
472-
- 🔄 直接响应方法移至根级别(`request.get` 等)
473-
- 📝 更新 API 文档和使用示例
474-
475-
**改进**
476-
477-
- ✨ 更直观的 API 设计
478-
- 📚 完善的文档结构
479-
- 🎯 更清晰的使用场景说明
480-
481-
### v1.2.0
482-
483-
**新增**
484-
485-
- ✨ 添加防重复提交插件
486-
- ✨ 添加请求体大小限制插件
487-
- ✨ 添加未授权处理插件
488-
- 📝 完善插件系统文档
489-
490-
**改进**
491-
492-
- 🐛 修复多实例模式下的内存泄漏问题
493-
- ⚡ 优化错误处理机制
494-
- 📚 增加更多使用示例
495-
496-
### v1.1.0
497-
498-
**新增**
499-
500-
- ✨ 支持多实例模式
501-
- ✨ 添加插件系统
502-
- ✨ 支持自动重试机制
503-
504-
**改进**
505-
506-
- 🐛 修复 TypeScript 类型定义问题
507-
- ⚡ 优化请求性能
508-
- 📝 完善 API 文档
509-
510-
### v1.0.0
511-
512-
**首次发布**
513-
514-
- ✨ 基础 HTTP 请求功能
515-
- ✨ 支持标准响应和直接响应两种模式
516-
- ✨ 自动 Token 注入
517-
- ✨ 完整的 TypeScript 支持
518-
- 📝 基础文档和示例
467+
详细更新日志请查看 [CHANGELOG.md](./CHANGELOG.md)
519468

520469
## 贡献指南
521470

packages/axios/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ interface ApiClient {
2727
config?: AxiosRequestConfig,
2828
): Promise<T>;
2929
use<T>(plugin: AxiosPlugin<T>, options?: T): void;
30+
/**
31+
* 底层的 Axios 实例,暴露以允许外部进行高级配置(如添加拦截器)
32+
*/
33+
instance: AxiosInstance;
3034
std: {
3135
get<T, R extends BaseResponse<T> = BaseResponse<T>>(
3236
url: string,
@@ -213,6 +217,7 @@ function createClient(api: AxiosInstance): ApiClient {
213217

214218
return {
215219
...methods,
220+
instance: api,
216221
use<T>(plugin: AxiosPlugin<T>, options?: T): void {
217222
plugin(api, options);
218223
},

packages/axios/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"module": "./dist/index.js",
88
"types": "./dist/index.d.ts",
99
"files": [
10-
"dist"
10+
"dist",
11+
"CHANGELOG.md"
1112
],
1213
"exports": {
1314
".": {

0 commit comments

Comments
 (0)