parent
2496333e42
commit
96ea0266dd
|
@ -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。
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
declare const uni: any;
|
||||
declare const wx: any;
|
||||
declare const my: any;
|
||||
declare const swan: any;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -2,7 +2,6 @@ import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest';
|
|||
import { getDefaultAdapter } from '@/adpater/getDefaultAdapter';
|
||||
|
||||
const platforms = [
|
||||
'uni',
|
||||
'wx',
|
||||
'my',
|
||||
'swan',
|
||||
|
|
Loading…
Reference in New Issue