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

refactor: defineAsyncApi

上级 959060f0
import { isPlainObject } from '@vue/shared'
import { extend, isPlainObject } from '@vue/shared'
import { ApiOptions, ApiProtocols } from '../../protocols/type'
import { API_TYPE_ON_PROTOCOLS, validateProtocols } from '../protocol'
import {
......@@ -48,18 +48,20 @@ function wrapperSyncApi(fn: Function) {
return (...args: any[]) => fn.apply(null, args)
}
function wrapperAsyncApi(name: string, fn: Function, options?: ApiOptions) {
function wrapperAsyncApi(
name: string,
fn: (args: unknown) => Promise<unknown>,
options?: ApiOptions
) {
return (args: Record<string, any>) => {
const callbackId = createAsyncApiCallback(name, args, options)
const res = fn.apply(null, [
args,
(res: unknown) => {
invokeCallback(callbackId, res)
},
])
if (res) {
invokeCallback(callbackId, res)
}
const id = createAsyncApiCallback(name, args, options)
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }))
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') })
})
}
}
......@@ -91,7 +93,7 @@ export function defineOnApi<T extends Function>(
fn,
__DEV__ ? API_TYPE_ON_PROTOCOLS : undefined,
options
)
) as T
}
export function defineTaskApi<T extends Function>(
......@@ -106,7 +108,7 @@ export function defineTaskApi<T extends Function>(
fn,
__DEV__ ? protocol : undefined,
options
)
) as T
}
export function defineSyncApi<T extends Function>(
......@@ -121,37 +123,80 @@ export function defineSyncApi<T extends Function>(
fn,
__DEV__ ? protocol : undefined,
options
)
) as T
}
interface AsyncMethodOptionLike {
success?: (...args: any[]) => void
}
type PromisifySuccessResult<P, R> = P extends {
success: any
}
? void
: P extends { fail: any }
? void
: P extends { complete: any }
? void
: Promise<R>
type AsyncApiLike = (args: any) => Promise<unknown> | void
type AsyncApiOptions<T extends AsyncApiLike> = Parameters<T>[0]
type AsyncApiRes<T extends AsyncMethodOptionLike> = Parameters<
Exclude<T['success'], undefined>
>[0]
type AsyncApiRequired<T extends AsyncMethodOptionLike> = <P extends T>(
args: P
) => PromisifySuccessResult<P, AsyncApiRes<T>>
type AsyncApiOptional<T extends AsyncMethodOptionLike> = <P extends T>(
args?: P
) => PromisifySuccessResult<P, AsyncApiRes<T>>
interface AsyncApiOptionalOptions {
success?: any
fail?: any
complete?: any
}
export function defineAsyncApi<T extends Function>(
type AsyncApi<
T extends AsyncMethodOptionLike
> = AsyncApiOptionalOptions extends T
? AsyncApiOptional<T>
: AsyncApiRequired<T>
export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>(
name: string,
fn: T,
fn: (
args: Omit<P, 'success' | 'fail' | 'complete'>
) => Promise<AsyncApiRes<P> | void>,
protocol?: ApiProtocols,
options?: ApiOptions
) {
return promisify(
defineApi(API_TYPE_ASYNC, name, fn, __DEV__ ? protocol : undefined, options)
)
) as AsyncApi<P>
}
function defineApi<T extends Function>(
function defineApi(
type: API_TYPES,
name: string,
fn: T,
fn: Function,
protocol?: ApiProtocols,
options?: ApiOptions
) {
switch (type) {
case API_TYPE_ON:
return wrapperApi<T>(wrapperOnApi(name, fn), name, protocol, options)
return wrapperApi(wrapperOnApi(name, fn), name, protocol, options)
case API_TYPE_TASK:
return wrapperApi<T>(wrapperTaskApi(name, fn), name, protocol, options)
return wrapperApi(wrapperTaskApi(name, fn), name, protocol, options)
case API_TYPE_SYNC:
return wrapperApi<T>(wrapperSyncApi(fn), name, protocol, options)
return wrapperApi(wrapperSyncApi(fn), name, protocol, options)
case API_TYPE_ASYNC:
return wrapperApi<T>(
wrapperAsyncApi(name, fn, options),
return wrapperApi(
wrapperAsyncApi(name, fn as any, options),
name,
protocol,
options
......
......@@ -7752,16 +7752,12 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res2) => {
invokeCallback(callbackId, res2);
}
]);
if (res) {
invokeCallback(callbackId, res);
}
const id2 = createAsyncApiCallback(name, args, options);
fn(args).then((res) => {
invokeCallback(id2, extend(res || {}, {errMsg: name + ":ok"}));
}).catch((err) => {
invokeCallback(id2, {errMsg: name + ":fail" + (err ? " " + err : "")});
});
};
}
function wrapperApi(fn, name, protocol, options) {
......@@ -8229,8 +8225,9 @@ const canIUse = defineSyncApi(API_CAN_I_USE, (schema) => {
}
return true;
}, CanIUseProtocol);
const makePhoneCall = defineAsyncApi(API_MAKE_PHONE_CALL, (option) => {
window.location.href = `tel:${option.phoneNumber}`;
const makePhoneCall = defineAsyncApi(API_MAKE_PHONE_CALL, ({phoneNumber}) => {
window.location.href = `tel:${phoneNumber}`;
return Promise.resolve();
}, MakePhoneCallProtocol);
const getSystemInfoSync = defineSyncApi("getSystemInfoSync", () => {
const pixelRatio2 = window.devicePixelRatio;
......@@ -8333,63 +8330,62 @@ const getSystemInfoSync = defineSyncApi("getSystemInfoSync", () => {
};
});
const getSystemInfo = defineAsyncApi("getSystemInfo", () => {
return getSystemInfoSync();
return Promise.resolve(getSystemInfoSync());
});
const openDocument = defineAsyncApi(API_OPEN_DOCUMENT, (option) => {
window.open(option.filePath);
const openDocument = defineAsyncApi(API_OPEN_DOCUMENT, ({filePath}) => {
window.open(filePath);
return Promise.resolve();
}, OpenDocumentProtocol);
function _getServiceAddress() {
return window.location.protocol + "//" + window.location.host;
}
const getImageInfo = defineAsyncApi(API_GET_IMAGE_INFO, ({src}, callback) => {
const getImageInfo = defineAsyncApi(API_GET_IMAGE_INFO, ({src}) => {
const img = new Image();
img.onload = function() {
callback({
errMsg: `${API_GET_IMAGE_INFO}:ok`,
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf("/") === 0 ? _getServiceAddress() + src : src
});
};
img.onerror = function() {
callback({
errMsg: `${API_GET_IMAGE_INFO}:fail`
});
};
img.src = src;
return new Promise((resolve, reject) => {
img.onload = function() {
resolve({
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf("/") === 0 ? _getServiceAddress() + src : src
});
};
img.onerror = function() {
reject();
};
img.src = src;
});
}, GetImageInfoProtocol, GetImageInfoOptions);
const navigateBack = defineAsyncApi(API_NAVIGATE_BACK, (options) => {
const navigateBack = defineAsyncApi(API_NAVIGATE_BACK, ({delta}) => new Promise((resolve, reject) => {
let canBack = true;
const vm = getCurrentPageVm();
if (vm && vm.$callHook("onBackPress") === true) {
canBack = false;
}
if (!canBack) {
return {
errMsg: `${API_NAVIGATE_BACK}:fail onBackPress`
};
return reject("onBackPress");
}
getApp().$router.go(-options.delta);
}, NavigateBackProtocol, NavigateBackOptions);
function navigate(type, url, callback) {
getApp().$router.go(-delta);
resolve();
}), NavigateBackProtocol, NavigateBackOptions);
function navigate(type, url) {
const router = getApp().$router;
router[type === "navigateTo" ? "push" : "replace"]({
path: url,
force: true,
state: createPageState(type)
}).then((failure) => {
if (isNavigationFailure(failure)) {
return callback({
errMsg: `:fail ${failure.message}`
});
}
callback();
return new Promise((resolve, reject) => {
router[type === "navigateTo" ? "push" : "replace"]({
path: url,
force: true,
state: createPageState(type)
}).then((failure) => {
if (isNavigationFailure(failure)) {
return reject(failure.message);
}
return resolve();
});
});
}
const navigateTo = defineAsyncApi(API_NAVIGATE_TO, (options, callback) => navigate(API_NAVIGATE_TO, options.url, callback), NavigateToProtocol, NavigateToOptions);
const redirectTo = defineAsyncApi(API_REDIRECT_TO, (options, callback) => navigate(API_REDIRECT_TO, options.url, callback), RedirectToProtocol, RedirectToOptions);
const reLaunch = defineAsyncApi(API_RE_LAUNCH, (options, callback) => navigate(API_RE_LAUNCH, options.url, callback), ReLaunchProtocol, ReLaunchOptions);
const switchTab = defineAsyncApi(API_SWITCH_TAB, (options, callback) => navigate(API_SWITCH_TAB, options.url, callback), SwitchTabProtocol, SwitchTabOptions);
const navigateTo = defineAsyncApi(API_NAVIGATE_TO, ({url}) => navigate(API_NAVIGATE_TO, url), NavigateToProtocol, NavigateToOptions);
const redirectTo = defineAsyncApi(API_REDIRECT_TO, ({url}) => navigate(API_REDIRECT_TO, url), RedirectToProtocol, RedirectToOptions);
const reLaunch = defineAsyncApi(API_RE_LAUNCH, ({url}) => navigate(API_RE_LAUNCH, url), ReLaunchProtocol, ReLaunchOptions);
const switchTab = defineAsyncApi(API_SWITCH_TAB, ({url}) => navigate(API_SWITCH_TAB, url), SwitchTabProtocol, SwitchTabOptions);
var api = /* @__PURE__ */ Object.freeze({
__proto__: null,
[Symbol.toStringTag]: "Module",
......
......@@ -5,6 +5,6 @@ import { getSystemInfoSync } from './getSystemInfoSync'
export const getSystemInfo = defineAsyncApi<typeof uni.getSystemInfo>(
'getSystemInfo',
() => {
return getSystemInfoSync()
return Promise.resolve(getSystemInfoSync())
}
)
......@@ -6,8 +6,9 @@ import {
export const makePhoneCall = defineAsyncApi<typeof uni.makePhoneCall>(
API_MAKE_PHONE_CALL,
(option) => {
window.location.href = `tel:${option.phoneNumber}`
({ phoneNumber }) => {
window.location.href = `tel:${phoneNumber}`
return Promise.resolve()
},
MakePhoneCallProtocol
)
......@@ -6,8 +6,9 @@ import {
export const openDocument = defineAsyncApi<typeof uni.openDocument>(
API_OPEN_DOCUMENT,
(option) => {
window.open(option.filePath)
({ filePath }) => {
window.open(filePath)
return Promise.resolve()
},
OpenDocumentProtocol
)
......@@ -11,22 +11,21 @@ function _getServiceAddress() {
export const getImageInfo = defineAsyncApi<typeof uni.getImageInfo>(
API_GET_IMAGE_INFO,
({ src }, callback?: Function) => {
({ src }) => {
const img = new Image()
img.onload = function () {
callback!({
errMsg: `${API_GET_IMAGE_INFO}:ok`,
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf('/') === 0 ? _getServiceAddress() + src : src,
})
}
img.onerror = function () {
callback!({
errMsg: `${API_GET_IMAGE_INFO}:fail`,
})
}
img.src = src
return new Promise((resolve, reject) => {
img.onload = function () {
resolve({
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf('/') === 0 ? _getServiceAddress() + src : src,
} as UniApp.GetImageInfoSuccessData) // orientation和type是可选的,但GetImageInfoSuccessData定义的不对,暂时强制转换
}
img.onerror = function () {
reject()
}
img.src = src
})
},
GetImageInfoProtocol,
GetImageInfoOptions
......
......@@ -8,19 +8,19 @@ import {
export const navigateBack = defineAsyncApi<typeof uni.navigateBack>(
API_NAVIGATE_BACK,
(options) => {
let canBack = true
const vm = getCurrentPageVm()
if (vm && vm.$callHook('onBackPress') === true) {
canBack = false
}
if (!canBack) {
return {
errMsg: `${API_NAVIGATE_BACK}:fail onBackPress`,
({ delta }) =>
new Promise((resolve, reject) => {
let canBack = true
const vm = getCurrentPageVm()
if (vm && vm.$callHook('onBackPress') === true) {
canBack = false
}
}
getApp().$router.go(-options.delta!)
},
if (!canBack) {
return reject('onBackPress')
}
getApp().$router.go(-delta!)
resolve()
}),
NavigateBackProtocol,
NavigateBackOptions
)
......@@ -8,8 +8,7 @@ import { navigate } from './utils'
export const navigateTo = defineAsyncApi<typeof uni.navigateTo>(
API_NAVIGATE_TO,
(options, callback?: Function) =>
navigate(API_NAVIGATE_TO, options.url, callback!),
({ url }) => navigate(API_NAVIGATE_TO, url),
NavigateToProtocol,
NavigateToOptions
)
......@@ -8,8 +8,7 @@ import { navigate } from './utils'
export const reLaunch = defineAsyncApi<typeof uni.reLaunch>(
API_RE_LAUNCH,
(options, callback?: Function) =>
navigate(API_RE_LAUNCH, options.url, callback!),
({ url }) => navigate(API_RE_LAUNCH, url),
ReLaunchProtocol,
ReLaunchOptions
)
......@@ -8,8 +8,7 @@ import { navigate } from './utils'
export const redirectTo = defineAsyncApi<typeof uni.redirectTo>(
API_REDIRECT_TO,
(options, callback?: Function) =>
navigate(API_REDIRECT_TO, options.url, callback!),
({ url }) => navigate(API_REDIRECT_TO, url),
RedirectToProtocol,
RedirectToOptions
)
......@@ -8,8 +8,7 @@ import { navigate } from './utils'
export const switchTab = defineAsyncApi<typeof uni.switchTab>(
API_SWITCH_TAB,
(options, callback?: Function) =>
navigate(API_SWITCH_TAB, options.url, callback!),
({ url }) => navigate(API_SWITCH_TAB, url),
SwitchTabProtocol,
SwitchTabOptions
)
......@@ -3,20 +3,19 @@ import { createPageState } from '../../../framework/plugin/page'
export function navigate(
type: 'navigateTo' | 'redirectTo' | 'reLaunch' | 'switchTab',
url: string,
callback: Function
) {
url: string
): Promise<void> {
const router = getApp().$router as Router
router[type === 'navigateTo' ? 'push' : 'replace']({
path: url,
force: true,
state: createPageState(type),
}).then((failure) => {
if (isNavigationFailure(failure)) {
return callback({
errMsg: `:fail ${failure.message}`,
})
}
callback()
return new Promise((resolve, reject) => {
router[type === 'navigateTo' ? 'push' : 'replace']({
path: url,
force: true,
state: createPageState(type),
}).then((failure) => {
if (isNavigationFailure(failure)) {
return reject(failure.message)
}
return resolve()
})
})
}
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, isPromise, isString } from '@vue/shared';
import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isFunction, extend, isPromise, isString } from '@vue/shared';
function validateProtocolFail(name, msg) {
const errMsg = `${name}:fail ${msg}`;
......@@ -276,16 +276,14 @@ function wrapperSyncApi(fn) {
}
function wrapperAsyncApi(name, fn, options) {
return (args) => {
const callbackId = createAsyncApiCallback(name, args, options);
const res = fn.apply(null, [
args,
(res) => {
invokeCallback(callbackId, res);
},
]);
if (res) {
invokeCallback(callbackId, res);
}
const id = createAsyncApiCallback(name, args, options);
fn(args)
.then((res) => {
invokeCallback(id, extend(res || {}, { errMsg: name + ':ok' }));
})
.catch((err) => {
invokeCallback(id, { errMsg: name + ':fail' + (err ? ' ' + err : '') });
});
};
}
function wrapperApi(fn, name, protocol, options) {
......
......@@ -145,7 +145,7 @@ function resolveManifestFeature(
options: VitePluginUniResolvedOptions
): ManifestFeatures {
const features: ManifestFeatures = {
wx: true, // 是否启用小程序的组件实例 API,如:selectComponent 等(uni-core/src/service/plugin/appConfig)
wx: true,
wxs: true, // 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig)
promise: false, // 是否启用旧版本的 promise 支持(即返回[err,res]的格式)
longpress: true, // 是否启用longpress
......@@ -194,22 +194,23 @@ export function getFeatures(
resolveProjectFeature(options, command)
)
return {
__UNI_FEATURE_WX__: wx,
__UNI_FEATURE_WXS__: wxs,
__UNI_FEATURE_NVUE__: nvue,
__UNI_FEATURE_PROMISE__: promise,
__UNI_FEATURE_LONGPRESS__: longpress,
__UNI_FEATURE_ROUTER_MODE__: routerMode,
__UNI_FEATURE_PAGES__: pages,
__UNI_FEATURE_TABBAR__: tabBar,
__UNI_FEATURE_TOPWINDOW__: topWindow,
__UNI_FEATURE_LEFTWINDOW__: leftWindow,
__UNI_FEATURE_RIGHTWINDOW__: rightWindow,
__UNI_FEATURE_RESPONSIVE__: topWindow || leftWindow || rightWindow,
__UNI_FEATURE_NAVIGATIONBAR__: navigationBar,
__UNI_FEATURE_PULL_DOWN_REFRESH__: pullDownRefresh,
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: navigationBarButtons,
__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: navigationBarSearchInput,
__UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: navigationBarTransparent,
__UNI_FEATURE_WX__: wx, // 是否启用小程序的组件实例 API,如:selectComponent 等(uni-core/src/service/plugin/appConfig)
__UNI_FEATURE_WXS__: wxs, // 是否启用 wxs 支持,如:getComponentDescriptor 等(uni-core/src/view/plugin/appConfig)
__UNI_FEATURE_PROMISE__: promise, // 是否启用旧版本的 promise 支持(即返回[err,res]的格式),默认返回标准
__UNI_FEATURE_LONGPRESS__: longpress, // 是否启用longpress
// 以下特性,编译器已自动识别是否需要启用
__UNI_FEATURE_NVUE__: nvue, // 是否启用nvue
__UNI_FEATURE_ROUTER_MODE__: routerMode, // 路由模式
__UNI_FEATURE_PAGES__: pages, // 是否多页面
__UNI_FEATURE_TABBAR__: tabBar, // 是否包含tabBar
__UNI_FEATURE_TOPWINDOW__: topWindow, // 是否包含topWindow
__UNI_FEATURE_LEFTWINDOW__: leftWindow, // 是否包含leftWindow
__UNI_FEATURE_RIGHTWINDOW__: rightWindow, // 是否包含rightWindow
__UNI_FEATURE_RESPONSIVE__: topWindow || leftWindow || rightWindow, // 是否启用响应式
__UNI_FEATURE_NAVIGATIONBAR__: navigationBar, // 是否启用标题栏
__UNI_FEATURE_PULL_DOWN_REFRESH__: pullDownRefresh, // 是否启用下拉刷新
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: navigationBarButtons, // 是否启用标题栏按钮
__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: navigationBarSearchInput, // 是否启用标题栏搜索框
__UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: navigationBarTransparent, // 是否启用透明标题栏
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册