提交 84634920 编写于 作者: fxy060608's avatar fxy060608

feat: createApi => defineApi

上级 9151b16f
...@@ -63,12 +63,12 @@ function wrapperApi<T extends Function>( ...@@ -63,12 +63,12 @@ function wrapperApi<T extends Function>(
} as unknown) as T } as unknown) as T
} }
export function createOnApi<T extends Function>( export function defineOnApi<T extends Function>(
name: string, name: string,
fn: T, fn: T,
options?: ApiOptions options?: ApiOptions
) { ) {
return createApi( return defineApi(
API_TYPE_ON, API_TYPE_ON,
name, name,
fn, fn,
...@@ -77,13 +77,13 @@ export function createOnApi<T extends Function>( ...@@ -77,13 +77,13 @@ export function createOnApi<T extends Function>(
) )
} }
export function createTaskApi<T extends Function>( export function defineTaskApi<T extends Function>(
name: string, name: string,
fn: T, fn: T,
protocol?: ApiProtocols, protocol?: ApiProtocols,
options?: ApiOptions options?: ApiOptions
) { ) {
return createApi( return defineApi(
API_TYPE_TASK, API_TYPE_TASK,
name, name,
fn, fn,
...@@ -92,13 +92,13 @@ export function createTaskApi<T extends Function>( ...@@ -92,13 +92,13 @@ export function createTaskApi<T extends Function>(
) )
} }
export function createSyncApi<T extends Function>( export function defineSyncApi<T extends Function>(
name: string, name: string,
fn: T, fn: T,
protocol?: ApiProtocols, protocol?: ApiProtocols,
options?: ApiOptions options?: ApiOptions
) { ) {
return createApi( return defineApi(
API_TYPE_SYNC, API_TYPE_SYNC,
name, name,
fn, fn,
...@@ -107,18 +107,18 @@ export function createSyncApi<T extends Function>( ...@@ -107,18 +107,18 @@ export function createSyncApi<T extends Function>(
) )
} }
export function createAsyncApi<T extends Function>( export function defineAsyncApi<T extends Function>(
name: string, name: string,
fn: T, fn: T,
protocol?: ApiProtocols, protocol?: ApiProtocols,
options?: ApiOptions options?: ApiOptions
) { ) {
return promisify( return promisify(
createApi(API_TYPE_ASYNC, name, fn, __DEV__ ? protocol : undefined, options) defineApi(API_TYPE_ASYNC, name, fn, __DEV__ ? protocol : undefined, options)
) )
} }
function createApi<T extends Function>( function defineApi<T extends Function>(
type: API_TYPES, type: API_TYPES,
name: string, name: string,
fn: T, fn: T,
......
...@@ -23,10 +23,10 @@ export * from './protocols/media/getImageInfo' ...@@ -23,10 +23,10 @@ export * from './protocols/media/getImageInfo'
// helpers // helpers
export { export {
createOnApi, defineOnApi,
createTaskApi, defineTaskApi,
createSyncApi, defineSyncApi,
createAsyncApi, defineAsyncApi,
} from './helpers/api' } from './helpers/api'
export { handlePromise } from './helpers/api/promise' export { handlePromise } from './helpers/api/promise'
......
import { getRealPath } from '@dcloudio/uni-platform'
import { ApiOptions, ApiProtocol } from '../type' import { ApiOptions, ApiProtocol } from '../type'
export const GetImageInfoOptions: ApiOptions = { export const GetImageInfoOptions: ApiOptions = {
formatArgs: { formatArgs: {
src(src, params) { src(src, params) {
params.src = (uni as any).getRealPath(src) params.src = getRealPath(src)
}, },
}, },
} }
......
// @ts-ignore // @ts-ignore
import { encode, decode } from '../../helpers/base64-arraybuffer' import { encode, decode } from '../../helpers/base64-arraybuffer'
import { createSyncApi } from '../../helpers/api' import { defineSyncApi } from '../../helpers/api'
import { import {
Base64ToArrayBufferProtocol, Base64ToArrayBufferProtocol,
ArrayBufferToBase64Protocol, ArrayBufferToBase64Protocol,
} from '../../protocols/base/base64' } from '../../protocols/base/base64'
export const base64ToArrayBuffer = createSyncApi< export const base64ToArrayBuffer = defineSyncApi<
typeof uni.base64ToArrayBuffer typeof uni.base64ToArrayBuffer
>( >(
'base64ToArrayBuffer', 'base64ToArrayBuffer',
...@@ -18,7 +18,7 @@ export const base64ToArrayBuffer = createSyncApi< ...@@ -18,7 +18,7 @@ export const base64ToArrayBuffer = createSyncApi<
Base64ToArrayBufferProtocol Base64ToArrayBufferProtocol
) )
export const arrayBufferToBase64 = createSyncApi< export const arrayBufferToBase64 = defineSyncApi<
typeof uni.arrayBufferToBase64 typeof uni.arrayBufferToBase64
>( >(
'arrayBufferToBase64', 'arrayBufferToBase64',
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
HOOKS, HOOKS,
} from '../../helpers/interceptor' } from '../../helpers/interceptor'
import { createSyncApi } from '../../helpers/api' import { defineSyncApi } from '../../helpers/api'
import { import {
AddInterceptorProtocol, AddInterceptorProtocol,
...@@ -80,7 +80,7 @@ function removeHook(hooks: Function[] | undefined, hook: Function) { ...@@ -80,7 +80,7 @@ function removeHook(hooks: Function[] | undefined, hook: Function) {
} }
} }
export const addInterceptor = createSyncApi( export const addInterceptor = defineSyncApi(
'addInterceptor', 'addInterceptor',
(method: string | Interceptor, interceptor: Interceptor | undefined) => { (method: string | Interceptor, interceptor: Interceptor | undefined) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
...@@ -95,7 +95,7 @@ export const addInterceptor = createSyncApi( ...@@ -95,7 +95,7 @@ export const addInterceptor = createSyncApi(
AddInterceptorProtocol AddInterceptorProtocol
) )
export const removeInterceptor = createSyncApi( export const removeInterceptor = defineSyncApi(
'removeInterceptor', 'removeInterceptor',
(method: string | Interceptor, interceptor: Interceptor | undefined) => { (method: string | Interceptor, interceptor: Interceptor | undefined) => {
if (typeof method === 'string') { if (typeof method === 'string') {
......
import { getBaseSystemInfo } from '@dcloudio/uni-platform' import { getBaseSystemInfo } from '@dcloudio/uni-platform'
import { createSyncApi } from '../../helpers/api' import { defineSyncApi } from '../../helpers/api'
import { Upx2pxProtocol } from '../../protocols/base/upx2px' import { Upx2pxProtocol } from '../../protocols/base/upx2px'
const EPS = 1e-4 const EPS = 1e-4
...@@ -15,7 +15,7 @@ function checkDeviceWidth() { ...@@ -15,7 +15,7 @@ function checkDeviceWidth() {
isIOS = platform === 'ios' isIOS = platform === 'ios'
} }
export const upx2px = createSyncApi<typeof uni.upx2px>( export const upx2px = defineSyncApi<typeof uni.upx2px>(
'upx2px', 'upx2px',
(number, newDeviceWidth?: number) => { (number, newDeviceWidth?: number) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
......
...@@ -2,7 +2,7 @@ import { extend } from '@vue/shared' ...@@ -2,7 +2,7 @@ import { extend } from '@vue/shared'
import { ServiceJSBridge } from '@dcloudio/uni-core' import { ServiceJSBridge } from '@dcloudio/uni-core'
import { createSyncApi } from '../../helpers/api' import { defineSyncApi } from '../../helpers/api'
import { getCurrentPageVm } from '../utils' import { getCurrentPageVm } from '../utils'
const defaultOptions = { const defaultOptions = {
...@@ -120,7 +120,7 @@ class ServiceIntersectionObserver { ...@@ -120,7 +120,7 @@ class ServiceIntersectionObserver {
} }
} }
export const createIntersectionObserver = createSyncApi< export const createIntersectionObserver = defineSyncApi<
typeof uni.createIntersectionObserver typeof uni.createIntersectionObserver
>('createIntersectionObserver', (context?, options?) => { >('createIntersectionObserver', (context?, options?) => {
if (!context) { if (!context) {
......
...@@ -3319,7 +3319,7 @@ function addBase(filePath) { ...@@ -3319,7 +3319,7 @@ function addBase(filePath) {
} }
return base + filePath; return base + filePath;
} }
function getRealPath$1(filePath) { function getRealPath(filePath) {
if (__uniConfig.router.base === "./") { if (__uniConfig.router.base === "./") {
filePath = filePath.replace(/^\.\/static\//, "/static/"); filePath = filePath.replace(/^\.\/static\//, "/static/");
} }
...@@ -3395,7 +3395,7 @@ const _sfc_main$j = { ...@@ -3395,7 +3395,7 @@ const _sfc_main$j = {
return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0; return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0;
}, },
realImagePath() { realImagePath() {
return getRealPath$1(this.src); return getRealPath(this.src);
}, },
modeStyle() { modeStyle() {
let size = "auto"; let size = "auto";
...@@ -7716,13 +7716,13 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -7716,13 +7716,13 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options); return defineApi(API_TYPE_SYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options);
} }
function createAsyncApi(name, fn, protocol, options) { function defineAsyncApi(name, fn, protocol, options) {
return promisify(createApi(API_TYPE_ASYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); return promisify(defineApi(API_TYPE_ASYNC, name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options));
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -7748,10 +7748,10 @@ const ArrayBufferToBase64Protocol = [ ...@@ -7748,10 +7748,10 @@ const ArrayBufferToBase64Protocol = [
required: true required: true
} }
]; ];
const base64ToArrayBuffer = /* @__PURE__ */ createSyncApi("base64ToArrayBuffer", (base64) => { const base64ToArrayBuffer = defineSyncApi("base64ToArrayBuffer", (base64) => {
return decode(base64); return decode(base64);
}, Base64ToArrayBufferProtocol); }, Base64ToArrayBufferProtocol);
const arrayBufferToBase64 = /* @__PURE__ */ createSyncApi("arrayBufferToBase64", (arrayBuffer) => { const arrayBufferToBase64 = defineSyncApi("arrayBufferToBase64", (arrayBuffer) => {
return encode(arrayBuffer); return encode(arrayBuffer);
}, ArrayBufferToBase64Protocol); }, ArrayBufferToBase64Protocol);
const Upx2pxProtocol = [ const Upx2pxProtocol = [
...@@ -7772,7 +7772,7 @@ function checkDeviceWidth() { ...@@ -7772,7 +7772,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio2; deviceDPR = pixelRatio2;
isIOS = platform === "ios"; isIOS = platform === "ios";
} }
const upx2px = /* @__PURE__ */ createSyncApi("upx2px", (number, newDeviceWidth) => { const upx2px = defineSyncApi("upx2px", (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -7851,14 +7851,14 @@ function removeHook(hooks, hook) { ...@@ -7851,14 +7851,14 @@ function removeHook(hooks, hook) {
hooks.splice(index2, 1); hooks.splice(index2, 1);
} }
} }
const addInterceptor = /* @__PURE__ */ createSyncApi("addInterceptor", (method, interceptor) => { const addInterceptor = defineSyncApi("addInterceptor", (method, interceptor) => {
if (typeof method === "string" && isPlainObject(interceptor)) { if (typeof method === "string" && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} else if (isPlainObject(method)) { } else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = /* @__PURE__ */ createSyncApi("removeInterceptor", (method, interceptor) => { const removeInterceptor = defineSyncApi("removeInterceptor", (method, interceptor) => {
if (typeof method === "string") { if (typeof method === "string") {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
...@@ -7946,7 +7946,7 @@ class ServiceIntersectionObserver { ...@@ -7946,7 +7946,7 @@ class ServiceIntersectionObserver {
}, this._pageId); }, this._pageId);
} }
} }
const createIntersectionObserver = /* @__PURE__ */ createSyncApi("createIntersectionObserver", (context, options) => { const createIntersectionObserver = defineSyncApi("createIntersectionObserver", (context, options) => {
if (!context) { if (!context) {
context = getCurrentPageVm(); context = getCurrentPageVm();
} }
...@@ -7984,7 +7984,7 @@ const OpenDocumentProtocol = { ...@@ -7984,7 +7984,7 @@ const OpenDocumentProtocol = {
const GetImageInfoOptions = { const GetImageInfoOptions = {
formatArgs: { formatArgs: {
src(src, params) { src(src, params) {
params.src = uni.getRealPath(src); params.src = getRealPath(src);
} }
} }
}; };
...@@ -8002,16 +8002,16 @@ const SCHEMA_CSS = { ...@@ -8002,16 +8002,16 @@ const SCHEMA_CSS = {
"css.env": cssSupports("top:env(a)"), "css.env": cssSupports("top:env(a)"),
"css.constant": cssSupports("top:constant(a)") "css.constant": cssSupports("top:constant(a)")
}; };
const canIUse = /* @__PURE__ */ createSyncApi("canIUse", (schema) => { const canIUse = defineSyncApi("canIUse", (schema) => {
if (hasOwn$1(SCHEMA_CSS, schema)) { if (hasOwn$1(SCHEMA_CSS, schema)) {
return SCHEMA_CSS[schema]; return SCHEMA_CSS[schema];
} }
return true; return true;
}, CanIUseProtocol); }, CanIUseProtocol);
const makePhoneCall = /* @__PURE__ */ createAsyncApi("makePhoneCall", (option) => { const makePhoneCall = defineAsyncApi("makePhoneCall", (option) => {
window.location.href = `tel:${option.phoneNumber}`; window.location.href = `tel:${option.phoneNumber}`;
}, MakePhoneCallProtocol); }, MakePhoneCallProtocol);
const getSystemInfoSync = /* @__PURE__ */ createSyncApi("getSystemInfoSync", () => { const getSystemInfoSync = defineSyncApi("getSystemInfoSync", () => {
const pixelRatio2 = window.devicePixelRatio; const pixelRatio2 = window.devicePixelRatio;
const screenFix = getScreenFix(); const screenFix = getScreenFix();
const landscape = isLandscape(screenFix); const landscape = isLandscape(screenFix);
...@@ -8111,16 +8111,16 @@ const getSystemInfoSync = /* @__PURE__ */ createSyncApi("getSystemInfoSync", () ...@@ -8111,16 +8111,16 @@ const getSystemInfoSync = /* @__PURE__ */ createSyncApi("getSystemInfoSync", ()
} }
}; };
}); });
const getSystemInfo = /* @__PURE__ */ createAsyncApi("getSystemInfo", () => { const getSystemInfo = defineAsyncApi("getSystemInfo", () => {
return getSystemInfoSync(); return getSystemInfoSync();
}); });
const openDocument = /* @__PURE__ */ createAsyncApi("openDocument", (option) => { const openDocument = defineAsyncApi("openDocument", (option) => {
window.open(option.filePath); window.open(option.filePath);
}, OpenDocumentProtocol); }, OpenDocumentProtocol);
function _getServiceAddress() { function _getServiceAddress() {
return window.location.protocol + "//" + window.location.host; return window.location.protocol + "//" + window.location.host;
} }
const getImageInfo = /* @__PURE__ */ createAsyncApi("getImageInfo", ({src}, callback) => { const getImageInfo = defineAsyncApi("getImageInfo", ({src}, callback) => {
const img = new Image(); const img = new Image();
img.onload = function() { img.onload = function() {
callback({ callback({
...@@ -8137,9 +8137,9 @@ const getImageInfo = /* @__PURE__ */ createAsyncApi("getImageInfo", ({src}, call ...@@ -8137,9 +8137,9 @@ const getImageInfo = /* @__PURE__ */ createAsyncApi("getImageInfo", ({src}, call
}; };
img.src = src; img.src = src;
}, GetImageInfoProtocol, GetImageInfoOptions); }, GetImageInfoProtocol, GetImageInfoOptions);
const navigateBack = /* @__PURE__ */ createAsyncApi("navigateBack", () => { const navigateBack = defineAsyncApi("navigateBack", () => {
}); });
const navigateTo = /* @__PURE__ */ createAsyncApi("navigateTo", (options) => { const navigateTo = defineAsyncApi("navigateTo", (options) => {
const router = getApp().$router; const router = getApp().$router;
router.push({ router.push({
path: options.url, path: options.url,
...@@ -8147,14 +8147,11 @@ const navigateTo = /* @__PURE__ */ createAsyncApi("navigateTo", (options) => { ...@@ -8147,14 +8147,11 @@ const navigateTo = /* @__PURE__ */ createAsyncApi("navigateTo", (options) => {
state: createPageState("navigateTo") state: createPageState("navigateTo")
}); });
}); });
const redirectTo = /* @__PURE__ */ createAsyncApi("redirectTo", () => { const redirectTo = defineAsyncApi("redirectTo", () => {
}); });
const reLaunch = /* @__PURE__ */ createAsyncApi("reLaunch", () => { const reLaunch = defineAsyncApi("reLaunch", () => {
}); });
const switchTab = /* @__PURE__ */ createAsyncApi("switchTab", () => { const switchTab = defineAsyncApi("switchTab", () => {
});
const getRealPath = /* @__PURE__ */ createSyncApi("getRealPath", (path) => {
return path;
}); });
var api = /* @__PURE__ */ Object.freeze({ var api = /* @__PURE__ */ Object.freeze({
__proto__: null, __proto__: null,
...@@ -8177,8 +8174,7 @@ var api = /* @__PURE__ */ Object.freeze({ ...@@ -8177,8 +8174,7 @@ var api = /* @__PURE__ */ Object.freeze({
navigateTo, navigateTo,
redirectTo, redirectTo,
reLaunch, reLaunch,
switchTab, switchTab
getRealPath
}); });
const uni$1 = api; const uni$1 = api;
const UniServiceJSBridge$1 = extend(ServiceJSBridge, { const UniServiceJSBridge$1 = extend(ServiceJSBridge, {
...@@ -8464,7 +8460,7 @@ function usePageHeadButtons(navigationBar) { ...@@ -8464,7 +8460,7 @@ function usePageHeadButtons(navigationBar) {
const fonts = Object.create(null); const fonts = Object.create(null);
buttons.forEach((btn) => { buttons.forEach((btn) => {
if (btn.fontSrc && !btn.fontFamily) { if (btn.fontSrc && !btn.fontFamily) {
const fontSrc = getRealPath$1(btn.fontSrc); const fontSrc = getRealPath(btn.fontSrc);
let fontFamily = fonts[fontSrc]; let fontFamily = fonts[fontSrc];
if (!fontFamily) { if (!fontFamily) {
fontFamily = `font${Date.now()}`; fontFamily = `font${Date.now()}`;
...@@ -9268,4 +9264,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { ...@@ -9268,4 +9264,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
]); ]);
} }
_sfc_main.render = _sfc_render; _sfc_main.render = _sfc_render;
export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$p as Audio, _sfc_main$o as Canvas, _sfc_main$n as Checkbox, _sfc_main$m as CheckboxGroup, _sfc_main$l as Editor, _sfc_main$k as Form, index$1 as Icon, _sfc_main$j as Image, _sfc_main$i as Input, _sfc_main$h as Label, _sfc_main$g as MovableView, _sfc_main$f as Navigator, index as PageComponent, _sfc_main$e as Progress, _sfc_main$d as Radio, _sfc_main$c as RadioGroup, _sfc_main$b as ResizeSensor, _sfc_main$a as RichText, _sfc_main$9 as ScrollView, _sfc_main$8 as Slider, _sfc_main$7 as SwiperItem, _sfc_main$6 as Switch, _sfc_main$5 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getRealPath, getSystemInfo, getSystemInfoSync, makePhoneCall, navigateBack, navigateTo, openDocument, index$2 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, switchTab, uni$1 as uni, upx2px}; export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$p as Audio, _sfc_main$o as Canvas, _sfc_main$n as Checkbox, _sfc_main$m as CheckboxGroup, _sfc_main$l as Editor, _sfc_main$k as Form, index$1 as Icon, _sfc_main$j as Image, _sfc_main$i as Input, _sfc_main$h as Label, _sfc_main$g as MovableView, _sfc_main$f as Navigator, index as PageComponent, _sfc_main$e as Progress, _sfc_main$d as Radio, _sfc_main$c as RadioGroup, _sfc_main$b as ResizeSensor, _sfc_main$a as RichText, _sfc_main$9 as ScrollView, _sfc_main$8 as Slider, _sfc_main$7 as SwiperItem, _sfc_main$6 as Switch, _sfc_main$5 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getSystemInfo, getSystemInfoSync, makePhoneCall, navigateBack, navigateTo, openDocument, index$2 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, switchTab, uni$1 as uni, upx2px};
import { hasOwn } from '@vue/shared' import { hasOwn } from '@vue/shared'
import { CanIUseProtocol, createSyncApi } from '@dcloudio/uni-api' import { CanIUseProtocol, defineSyncApi } from '@dcloudio/uni-api'
function cssSupports(css: string) { function cssSupports(css: string) {
return window.CSS && window.CSS.supports && window.CSS.supports(css) return window.CSS && window.CSS.supports && window.CSS.supports(css)
...@@ -12,7 +12,7 @@ const SCHEMA_CSS = { ...@@ -12,7 +12,7 @@ const SCHEMA_CSS = {
'css.constant': cssSupports('top:constant(a)'), 'css.constant': cssSupports('top:constant(a)'),
} }
export const canIUse = createSyncApi<typeof uni.canIUse>( export const canIUse = defineSyncApi<typeof uni.canIUse>(
'canIUse', 'canIUse',
(schema: string) => { (schema: string) => {
if (hasOwn(SCHEMA_CSS, schema)) { if (hasOwn(SCHEMA_CSS, schema)) {
......
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
import { getSystemInfoSync } from './getSystemInfoSync' import { getSystemInfoSync } from './getSystemInfoSync'
export const getSystemInfo = createAsyncApi<typeof uni.getSystemInfo>( export const getSystemInfo = defineAsyncApi<typeof uni.getSystemInfo>(
'getSystemInfo', 'getSystemInfo',
() => { () => {
return getSystemInfoSync() return getSystemInfoSync()
......
import safeAreaInsets from 'safe-area-insets' import safeAreaInsets from 'safe-area-insets'
import { createSyncApi } from '@dcloudio/uni-api' import { defineSyncApi } from '@dcloudio/uni-api'
import { getWindowOffset } from '@dcloudio/uni-core' import { getWindowOffset } from '@dcloudio/uni-core'
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
/** /**
* 获取系统信息-同步 * 获取系统信息-同步
*/ */
export const getSystemInfoSync = createSyncApi<typeof uni.getSystemInfoSync>( export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
'getSystemInfoSync', 'getSystemInfoSync',
() => { () => {
const pixelRatio = window.devicePixelRatio const pixelRatio = window.devicePixelRatio
......
import { createAsyncApi, MakePhoneCallProtocol } from '@dcloudio/uni-api' import { defineAsyncApi, MakePhoneCallProtocol } from '@dcloudio/uni-api'
export const makePhoneCall = createAsyncApi<typeof uni.makePhoneCall>( export const makePhoneCall = defineAsyncApi<typeof uni.makePhoneCall>(
'makePhoneCall', 'makePhoneCall',
(option) => { (option) => {
window.location.href = `tel:${option.phoneNumber}` window.location.href = `tel:${option.phoneNumber}`
......
import { createAsyncApi, OpenDocumentProtocol } from '@dcloudio/uni-api' import { defineAsyncApi, OpenDocumentProtocol } from '@dcloudio/uni-api'
export const openDocument = createAsyncApi<typeof uni.openDocument>( export const openDocument = defineAsyncApi<typeof uni.openDocument>(
'openDocument', 'openDocument',
(option) => { (option) => {
window.open(option.filePath) window.open(option.filePath)
......
...@@ -14,8 +14,6 @@ export * from './route/redirectTo' ...@@ -14,8 +14,6 @@ export * from './route/redirectTo'
export * from './route/reLaunch' export * from './route/reLaunch'
export * from './route/switchTab' export * from './route/switchTab'
export * from './util/getRealPath'
export { export {
upx2px, upx2px,
addInterceptor, addInterceptor,
......
import { import {
createAsyncApi, defineAsyncApi,
GetImageInfoOptions, GetImageInfoOptions,
GetImageInfoProtocol, GetImageInfoProtocol,
} from '@dcloudio/uni-api' } from '@dcloudio/uni-api'
...@@ -8,7 +8,7 @@ function _getServiceAddress() { ...@@ -8,7 +8,7 @@ function _getServiceAddress() {
return window.location.protocol + '//' + window.location.host return window.location.protocol + '//' + window.location.host
} }
export const getImageInfo = createAsyncApi<typeof uni.getImageInfo>( export const getImageInfo = defineAsyncApi<typeof uni.getImageInfo>(
'getImageInfo', 'getImageInfo',
({ src }, callback?: Function) => { ({ src }, callback?: Function) => {
const img = new Image() const img = new Image()
......
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
export const navigateBack = createAsyncApi<typeof uni.navigateBack>( export const navigateBack = defineAsyncApi<typeof uni.navigateBack>(
'navigateBack', 'navigateBack',
() => {} () => {}
) )
import { Router } from 'vue-router' import { Router } from 'vue-router'
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
import { createPageState } from '../../../framework/plugin/page' import { createPageState } from '../../../framework/plugin/page'
export const navigateTo = createAsyncApi<typeof uni.navigateTo>( export const navigateTo = defineAsyncApi<typeof uni.navigateTo>(
'navigateTo', 'navigateTo',
(options) => { (options) => {
const router = getApp().$router as Router const router = getApp().$router as Router
......
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
export const reLaunch = createAsyncApi('reLaunch', () => {}) export const reLaunch = defineAsyncApi('reLaunch', () => {})
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
export const redirectTo = createAsyncApi('redirectTo', () => {}) export const redirectTo = defineAsyncApi('redirectTo', () => {})
import { createAsyncApi } from '@dcloudio/uni-api' import { defineAsyncApi } from '@dcloudio/uni-api'
export const switchTab = createAsyncApi('switchTab', () => {}) export const switchTab = defineAsyncApi('switchTab', () => {})
import { createSyncApi } from '@dcloudio/uni-api'
export const getRealPath = createSyncApi('getRealPath', (path: string) => {
return path
})
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return my.getSystemInfoSync() return my.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return swan.getSystemInfoSync() return swan.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return qq.getSystemInfoSync() return qq.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return tt.getSystemInfoSync() return tt.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return wx.getSystemInfoSync() return wx.getSystemInfoSync()
} }
export function getRealPath() {}
...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) { ...@@ -285,10 +285,10 @@ function wrapperApi(fn, name, protocol, options) {
return fn.apply(null, formatApiArgs(args)); return fn.apply(null, formatApiArgs(args));
}; };
} }
function createSyncApi(name, fn, protocol, options) { function defineSyncApi(name, fn, protocol, options) {
return createApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options); return defineApi(API_TYPE_SYNC, name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
} }
function createApi(type, name, fn, protocol, options) { function defineApi(type, name, fn, protocol, options) {
switch (type) { switch (type) {
case API_TYPE_ON: case API_TYPE_ON:
return wrapperApi(wrapperOnApi(name, fn), name, protocol); return wrapperApi(wrapperOnApi(name, fn), name, protocol);
...@@ -324,7 +324,7 @@ function checkDeviceWidth() { ...@@ -324,7 +324,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio; deviceDPR = pixelRatio;
isIOS = platform === 'ios'; isIOS = platform === 'ios';
} }
const upx2px = createSyncApi('upx2px', (number, newDeviceWidth) => { const upx2px = defineSyncApi('upx2px', (number, newDeviceWidth) => {
if (deviceWidth === 0) { if (deviceWidth === 0) {
checkDeviceWidth(); checkDeviceWidth();
} }
...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) { ...@@ -506,7 +506,7 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1); hooks.splice(index, 1);
} }
} }
const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => { const addInterceptor = defineSyncApi('addInterceptor', (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) { if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
} }
...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) => ...@@ -514,7 +514,7 @@ const addInterceptor = createSyncApi('addInterceptor', (method, interceptor) =>
mergeInterceptorHook(globalInterceptors, method); mergeInterceptorHook(globalInterceptors, method);
} }
}, AddInterceptorProtocol); }, AddInterceptorProtocol);
const removeInterceptor = createSyncApi('removeInterceptor', (method, interceptor) => { const removeInterceptor = defineSyncApi('removeInterceptor', (method, interceptor) => {
if (typeof method === 'string') { if (typeof method === 'string') {
if (isPlainObject(interceptor)) { if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor); removeInterceptorHook(scopedInterceptors[method], interceptor);
......
export function getBaseSystemInfo() { export function getBaseSystemInfo() {
return qa.getSystemInfoSync() return qa.getSystemInfoSync()
} }
export function getRealPath() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册