diff --git a/README.md b/README.md index 9bcbbae..af1dffe 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,3 @@ axios-miniprogram 是一款为小程序平台量身定制的轻量级请求库 [提问点这里](https://github.com/zjx0905/axios-miniprogram/issues) -## 未来计划 - -2023 年 6 月 1 日 起该库将不再内部支持第三方框架,内置的 uni-app 即将移除,您依旧可以使用[适配器](https://axios-miniprogram.com/advanced/adapter)兼容 uni-app。 diff --git a/example/src/pages/index/index.vue b/example/src/pages/index/index.vue index 4815399..83fc560 100644 --- a/example/src/pages/index/index.vue +++ b/example/src/pages/index/index.vue @@ -24,54 +24,17 @@ function getRequest() { } function postRequest() { - axios.post('/users', { - name: 'Leanne Graham', - username: 'Bret', - email: 'Sincere@april.biz', - address: { - street: 'Kulas Light', - suite: 'Apt. 556', - city: 'Gwenborough', - zipcode: '92998-3874', - geo: { - lat: '-37.3159', - lng: '81.1496', - }, - }, - phone: '1-770-736-8031 x56442', - website: 'hildegard.org', - company: { - name: 'Romaguera-Crona', - catchPhrase: 'Multi-layered client-server neural-net', - bs: 'harness real-time e-markets', - }, - }); + axios.post( + '/users', + '{"name":"Leanne Graham","username":"Bret","email":"Sincere@april.biz","address":{"street":"Kulas Light","suite":"Apt. 556","city":"Gwenborough","zipcode":"92998-3874","geo":{"lat":"-37.3159","lng":"81.1496"}},"phone":"1-770-736-8031 x56442","website":"hildegard.org","company":{"name":"Romaguera-Crona","catchPhrase":"Multi-layered client-server neural-net","bs":"harness real-time e-markets"}}', + ); } function putRequest() { - axios.put('/users/:id', { - id: 1, - name: 'Leanne Graham', - username: 'Bret', - email: 'Sincere@april.biz', - address: { - street: 'Kulas Light', - suite: 'Apt. 556', - city: 'Gwenborough', - zipcode: '92998-3874', - geo: { - lat: '-37.3159', - lng: '81.1496', - }, - }, - phone: '1-770-736-8031 x56442', - website: 'hildegard.org', - company: { - name: 'Romaguera-Crona', - catchPhrase: 'Multi-layered client-server neural-net', - bs: 'harness real-time e-markets', - }, - }); + axios.put( + '/users/:id', + '{"id":1,"name":"Leanne Graham","username":"Bret","email":"Sincere@april.biz","address":{"street":"Kulas Light","suite":"Apt. 556","city":"Gwenborough","zipcode":"92998-3874","geo":{"lat":"-37.3159","lng":"81.1496"}},"phone":"1-770-736-8031 x56442","website":"hildegard.org","company":{"name":"Romaguera-Crona","catchPhrase":"Multi-layered client-server neural-net","bs":"harness real-time e-markets"}}', + ); } function deleteRequest() { diff --git a/global.variables.d.ts b/global.variables.d.ts index d659f10..96ae87f 100644 --- a/global.variables.d.ts +++ b/global.variables.d.ts @@ -1,4 +1,3 @@ -declare const uni: any; declare const wx: any; declare const my: any; declare const swan: any; diff --git a/src/adpater/getDefaultAdapter.ts b/src/adpater/getDefaultAdapter.ts index 174991e..63a5f86 100644 --- a/src/adpater/getDefaultAdapter.ts +++ b/src/adpater/getDefaultAdapter.ts @@ -13,13 +13,7 @@ export function getDefaultAdapter() { function getPlatform() { const undef = 'undefined'; - if (typeof uni !== undef) { - return { - request: uni.request, - downloadFile: uni.downloadFile, - uploadFile: uni.uploadFile, - }; - } else if (typeof wx !== undef) { + if (typeof wx !== undef) { return wx; } else if (typeof my !== undef) { return my; diff --git a/src/core/createInstance.ts b/src/core/createInstance.ts index 30f4f27..7a74720 100644 --- a/src/core/createInstance.ts +++ b/src/core/createInstance.ts @@ -54,8 +54,11 @@ export interface AxiosInstance extends AxiosRequest, Axios { fork(config: AxiosRequestConfig): AxiosInstance; } -export function createInstance(defaults: AxiosRequestConfig, parent?: Axios) { - const context = new Axios(defaults, parent); +export function createInstance( + defaults: AxiosRequestConfig, + parentContext?: Axios, +) { + const context = new Axios(defaults, parentContext); const instance = context.request as AxiosInstance; instance.getUri = function getUri(config) { diff --git a/test/adpater/getDefaultAdapter.test.ts b/test/adpater/getDefaultAdapter.test.ts index 9e18fa4..214edf6 100644 --- a/test/adpater/getDefaultAdapter.test.ts +++ b/test/adpater/getDefaultAdapter.test.ts @@ -2,7 +2,6 @@ import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'; import { getDefaultAdapter } from '@/adpater/getDefaultAdapter'; const platforms = [ - 'uni', 'wx', 'my', 'swan',