|
1 | | -import { isFunction, isPlainObject } from './helpers/isTypes'; |
2 | | -import { assert } from './helpers/error'; |
| 1 | +import { isFunction, isPlainObject } from '../helpers/isTypes'; |
| 2 | +import { assert } from '../helpers/error'; |
3 | 3 | import { |
4 | 4 | AxiosProgressEvent, |
5 | 5 | AxiosRequestFormData, |
6 | 6 | AxiosRequestHeaders, |
7 | | -} from './core/Axios'; |
| 7 | +} from '../core/Axios'; |
8 | 8 |
|
9 | 9 | /** |
10 | 10 | * 适配器请求类型 |
@@ -240,59 +240,6 @@ export interface AxiosAdapter { |
240 | 240 | (config: AxiosAdapterRequestConfig): AxiosAdapterPlatformTask; |
241 | 241 | } |
242 | 242 |
|
243 | | -/** |
244 | | - * 获取支持的平台适配器 |
245 | | - */ |
246 | | -export function getDefaultAdapter() { |
247 | | - const platform = revisePlatformApiNames(getPlatform()); |
248 | | - |
249 | | - function getPlatform() { |
250 | | - const undef = 'undefined'; |
251 | | - |
252 | | - if (typeof uni !== undef) { |
253 | | - return { |
254 | | - request: uni.request, |
255 | | - downloadFile: uni.downloadFile, |
256 | | - uploadFile: uni.uploadFile, |
257 | | - }; |
258 | | - } else if (typeof wx !== undef) { |
259 | | - return wx; |
260 | | - } else if (typeof my !== undef) { |
261 | | - return my; |
262 | | - } else if (typeof swan !== undef) { |
263 | | - return swan; |
264 | | - } else if (typeof tt !== undef) { |
265 | | - return tt; |
266 | | - } else if (typeof qq !== undef) { |
267 | | - return qq; |
268 | | - } else if (typeof qh !== undef) { |
269 | | - return qh; |
270 | | - } else if (typeof ks !== undef) { |
271 | | - return ks; |
272 | | - } else if (typeof dd !== undef) { |
273 | | - return dd; |
274 | | - } else if (typeof jd !== undef) { |
275 | | - return jd; |
276 | | - } |
277 | | - } |
278 | | - |
279 | | - function revisePlatformApiNames(platform?: AnyObject) { |
280 | | - return ( |
281 | | - platform && { |
282 | | - request: platform.request ?? platform.httpRequest, |
283 | | - upload: platform.upload ?? platform.uploadFile, |
284 | | - download: platform.download ?? platform.downloadFile, |
285 | | - } |
286 | | - ); |
287 | | - } |
288 | | - |
289 | | - if (!isPlatform(platform)) { |
290 | | - return; |
291 | | - } |
292 | | - |
293 | | - return createAdapter(platform); |
294 | | -} |
295 | | - |
296 | 243 | /** |
297 | 244 | * 创建适配器 |
298 | 245 | * |
@@ -400,12 +347,3 @@ export function createAdapter(platform: AxiosAdapterPlatform) { |
400 | 347 |
|
401 | 348 | return adapter; |
402 | 349 | } |
403 | | - |
404 | | -export function isPlatform(value: any): value is AxiosAdapterPlatform { |
405 | | - return ( |
406 | | - isPlainObject(value) && |
407 | | - isFunction(value.request) && |
408 | | - isFunction(value.upload) && |
409 | | - isFunction(value.download) |
410 | | - ); |
411 | | -} |
0 commit comments