@uni-helper/axios-adapter 1.18.1 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/index.cjs +10 -7
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +9 -6
- package/dist/{rolldown-runtime-D6vf50IK.cjs → rolldown-runtime-VH7oDXx4.cjs} +1 -1
- package/dist/{unplugin-CbkCxx2I.cjs → unplugin-DATd423M.cjs} +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/webpack.cjs +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
pnpm i @uni-helper/axios-adapter axios
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
适配器与 axios 的版本需要保持主版本号和次版本号一致。当前适配器版本为 `1.
|
|
54
|
+
适配器与 axios 的版本需要保持主版本号和次版本号一致。当前适配器版本为 `1.20.0`,推荐搭配 `axios@^1.20.0` 使用。
|
|
55
55
|
|
|
56
56
|
## 快速开始
|
|
57
57
|
|
|
@@ -136,14 +136,16 @@ export default {
|
|
|
136
136
|
- `options`:可选配置对象,当前版本支持扩展 uni-app 请求参数(参见 `globalExtensions.ts` 中的类型定义)。
|
|
137
137
|
- 返回值:标准的 `AxiosAdapter` 函数。
|
|
138
138
|
|
|
139
|
-
### `axios.upload<T>(url: string, data?:
|
|
139
|
+
### `axios.upload<T = any, D = any, P = any>(url: string, data?: D, config?: AxiosRequestConfig<D, P>): Promise<AxiosResponse<T, D, {}, P>>`
|
|
140
140
|
|
|
141
141
|
以 `uni.uploadFile` 发送上传请求,`data` 通常为 `FormData` 实例。
|
|
142
142
|
|
|
143
|
-
### `axios.download<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>`
|
|
143
|
+
### `axios.download<T = any, D = any, P = any>(url: string, config?: AxiosRequestConfig<D, P>): Promise<AxiosResponse<T, D, {}, P>>`
|
|
144
144
|
|
|
145
145
|
以 `uni.downloadFile` 发起下载请求,返回的 `response.data` 默认为文件临时路径或 `Buffer`(取决于运行环境)。
|
|
146
146
|
|
|
147
|
+
泛型已与 axios 自带方法对齐:`T` 为响应数据类型,`D`/`P` 分别对应请求数据与 `params`。旧版的第二个泛型参数 `R`(自定义返回类型)已移除——axios 1.19 起其默认值 `AxiosResponseDefault` 未导出,无法继续透传 `R`。
|
|
148
|
+
|
|
147
149
|
## 版本策略
|
|
148
150
|
|
|
149
151
|
自 1.4.0 开始,请始终保持主版本号和次版本号与 axios 一致。例如当你安装了 1.5.1 版本时,你可以安装 axios 的 1.5.x 版本。这样做的目的是确保适配器始终支持最新的 axios 特性。
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
3
3
|
let axios = require("axios");
|
|
4
4
|
let axios_unsafe_core_buildFullPath = require("axios/unsafe/core/buildFullPath");
|
|
5
5
|
axios_unsafe_core_buildFullPath = require_rolldown_runtime.__toESM(axios_unsafe_core_buildFullPath, 1);
|
|
@@ -163,14 +163,15 @@ const download = (config, options) => {
|
|
|
163
163
|
...requestOptions,
|
|
164
164
|
success(result) {
|
|
165
165
|
if (!task) return;
|
|
166
|
-
|
|
166
|
+
const response = {
|
|
167
167
|
config: responseConfig,
|
|
168
168
|
data: result.tempFilePath,
|
|
169
169
|
headers: {},
|
|
170
170
|
status: result.statusCode,
|
|
171
171
|
statusText: result.errMsg ?? "OK",
|
|
172
172
|
request: task
|
|
173
|
-
}
|
|
173
|
+
};
|
|
174
|
+
(0, axios_unsafe_core_settle.default)(resolve, reject, response);
|
|
174
175
|
task = null;
|
|
175
176
|
},
|
|
176
177
|
fail(error) {
|
|
@@ -209,7 +210,7 @@ const request = (config, options) => {
|
|
|
209
210
|
result.header = dingHeader;
|
|
210
211
|
}
|
|
211
212
|
const headers = new axios.AxiosHeaders(result.header);
|
|
212
|
-
|
|
213
|
+
const response = {
|
|
213
214
|
config: responseConfig,
|
|
214
215
|
data: result.data,
|
|
215
216
|
headers,
|
|
@@ -217,7 +218,8 @@ const request = (config, options) => {
|
|
|
217
218
|
statusText: result.errMsg ?? "OK",
|
|
218
219
|
request: task,
|
|
219
220
|
cookies: result.cookies
|
|
220
|
-
}
|
|
221
|
+
};
|
|
222
|
+
(0, axios_unsafe_core_settle.default)(resolve, reject, response);
|
|
221
223
|
task = null;
|
|
222
224
|
},
|
|
223
225
|
fail(error) {
|
|
@@ -260,14 +262,15 @@ const upload = (config, options) => {
|
|
|
260
262
|
...requestOptions,
|
|
261
263
|
success(result) {
|
|
262
264
|
if (!task) return;
|
|
263
|
-
|
|
265
|
+
const response = {
|
|
264
266
|
config: responseConfig,
|
|
265
267
|
data: result.data,
|
|
266
268
|
headers: {},
|
|
267
269
|
status: result.statusCode,
|
|
268
270
|
statusText: result.errMsg ?? "OK",
|
|
269
271
|
request: task
|
|
270
|
-
}
|
|
272
|
+
};
|
|
273
|
+
(0, axios_unsafe_core_settle.default)(resolve, reject, response);
|
|
271
274
|
task = null;
|
|
272
275
|
},
|
|
273
276
|
fail(error) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxiosAdapter } from "axios";
|
|
2
|
-
|
|
3
2
|
//#region src/types.d.ts
|
|
4
3
|
interface Options {}
|
|
5
4
|
interface UserOptions extends Partial<Options> {}
|
|
@@ -11,8 +10,8 @@ declare module 'axios' {
|
|
|
11
10
|
cookies?: string[];
|
|
12
11
|
}
|
|
13
12
|
interface Axios {
|
|
14
|
-
upload: <T = any,
|
|
15
|
-
download: <T = any,
|
|
13
|
+
upload: <T = any, D = any, P = any>(url: string, data?: D, config?: AxiosRequestConfig<D, P>) => AxiosPromise<T, D, P>;
|
|
14
|
+
download: <T = any, D = any, P = any>(url: string, config?: AxiosRequestConfig<D, P>) => AxiosPromise<T, D, P>;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxiosAdapter } from "axios";
|
|
2
|
-
|
|
3
2
|
//#region src/types.d.ts
|
|
4
3
|
interface Options {}
|
|
5
4
|
interface UserOptions extends Partial<Options> {}
|
|
@@ -11,8 +10,8 @@ declare module 'axios' {
|
|
|
11
10
|
cookies?: string[];
|
|
12
11
|
}
|
|
13
12
|
interface Axios {
|
|
14
|
-
upload: <T = any,
|
|
15
|
-
download: <T = any,
|
|
13
|
+
upload: <T = any, D = any, P = any>(url: string, data?: D, config?: AxiosRequestConfig<D, P>) => AxiosPromise<T, D, P>;
|
|
14
|
+
download: <T = any, D = any, P = any>(url: string, config?: AxiosRequestConfig<D, P>) => AxiosPromise<T, D, P>;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -157,14 +157,15 @@ const download = (config, options) => {
|
|
|
157
157
|
...requestOptions,
|
|
158
158
|
success(result) {
|
|
159
159
|
if (!task) return;
|
|
160
|
-
|
|
160
|
+
const response = {
|
|
161
161
|
config: responseConfig,
|
|
162
162
|
data: result.tempFilePath,
|
|
163
163
|
headers: {},
|
|
164
164
|
status: result.statusCode,
|
|
165
165
|
statusText: result.errMsg ?? "OK",
|
|
166
166
|
request: task
|
|
167
|
-
}
|
|
167
|
+
};
|
|
168
|
+
settle(resolve, reject, response);
|
|
168
169
|
task = null;
|
|
169
170
|
},
|
|
170
171
|
fail(error) {
|
|
@@ -203,7 +204,7 @@ const request = (config, options) => {
|
|
|
203
204
|
result.header = dingHeader;
|
|
204
205
|
}
|
|
205
206
|
const headers = new AxiosHeaders(result.header);
|
|
206
|
-
|
|
207
|
+
const response = {
|
|
207
208
|
config: responseConfig,
|
|
208
209
|
data: result.data,
|
|
209
210
|
headers,
|
|
@@ -211,7 +212,8 @@ const request = (config, options) => {
|
|
|
211
212
|
statusText: result.errMsg ?? "OK",
|
|
212
213
|
request: task,
|
|
213
214
|
cookies: result.cookies
|
|
214
|
-
}
|
|
215
|
+
};
|
|
216
|
+
settle(resolve, reject, response);
|
|
215
217
|
task = null;
|
|
216
218
|
},
|
|
217
219
|
fail(error) {
|
|
@@ -254,14 +256,15 @@ const upload = (config, options) => {
|
|
|
254
256
|
...requestOptions,
|
|
255
257
|
success(result) {
|
|
256
258
|
if (!task) return;
|
|
257
|
-
|
|
259
|
+
const response = {
|
|
258
260
|
config: responseConfig,
|
|
259
261
|
data: result.data,
|
|
260
262
|
headers: {},
|
|
261
263
|
status: result.statusCode,
|
|
262
264
|
statusText: result.errMsg ?? "OK",
|
|
263
265
|
request: task
|
|
264
|
-
}
|
|
266
|
+
};
|
|
267
|
+
settle(resolve, reject, response);
|
|
265
268
|
task = null;
|
|
266
269
|
},
|
|
267
270
|
fail(error) {
|
|
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
2
2
|
let node_process = require("node:process");
|
|
3
3
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
4
|
let local_pkg = require("local-pkg");
|
package/dist/vite.cjs
CHANGED
package/dist/webpack.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-helper/axios-adapter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.20.0",
|
|
5
5
|
"description": "The Axios adapter for uniapp",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "kejunmao",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dist"
|
|
61
61
|
],
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"axios": "^1.
|
|
63
|
+
"axios": "^1.20.0",
|
|
64
64
|
"vite": "^5.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"unplugin": "^2.3.11"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@antfu/eslint-config": "^9.
|
|
72
|
-
"@dcloudio/types": "^3.4.
|
|
73
|
-
"@types/node": "^24.13.
|
|
74
|
-
"axios": "^1.
|
|
75
|
-
"bumpp": "^
|
|
76
|
-
"eslint": "^10.
|
|
77
|
-
"msw": "^2.
|
|
78
|
-
"tsdown": "^0.22.
|
|
71
|
+
"@antfu/eslint-config": "^9.3.0",
|
|
72
|
+
"@dcloudio/types": "^3.4.32",
|
|
73
|
+
"@types/node": "^24.13.3",
|
|
74
|
+
"axios": "^1.20.0",
|
|
75
|
+
"bumpp": "^12.2.2",
|
|
76
|
+
"eslint": "^10.9.1",
|
|
77
|
+
"msw": "^2.15.0",
|
|
78
|
+
"tsdown": "^0.22.14",
|
|
79
79
|
"typescript": "^6.0.3",
|
|
80
80
|
"vite": "^5.4.21",
|
|
81
|
-
"vitest": "^3.2.
|
|
81
|
+
"vitest": "^3.2.7"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsdown",
|