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

build uni runtime(app-plus add subNVue)

上级 c9a2c894
...@@ -40,7 +40,7 @@ const camelize = cached((str) => { ...@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}); });
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/;
const CONTEXT_API_RE = /^create|Manager$/; const CONTEXT_API_RE = /^create|Manager$/;
...@@ -144,7 +144,9 @@ function upx2px (number, newDeviceWidth) { ...@@ -144,7 +144,9 @@ function upx2px (number, newDeviceWidth) {
return number < 0 ? -result : result return number < 0 ? -result : result
} }
var protocols = {}; const protocols = {};
const todos = [];
const canIUses = [];
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; const CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
...@@ -248,7 +250,52 @@ TODOS.forEach(function (name) { ...@@ -248,7 +250,52 @@ TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name); todoApis[name] = createTodoApi(name);
}); });
function requireNativePlugin (pluginName) { function wrapper$1 (webview) {
webview.$processed = true;
if (!webview.__uniapp_mask_id) {
return
}
const maskColor = webview.__uniapp_mask;
const maskWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id);
const oldShow = webview.show;
const oldHide = webview.hide;
const oldClose = webview.close;
const showMask = function () {
maskWebview.setStyle({
mask: maskColor
});
};
const closeMask = function () {
maskWebview.setStyle({
mask: 'none'
});
};
webview.show = function (...args) {
showMask();
return oldShow.apply(webview, args)
};
webview.hide = function (...args) {
closeMask();
return oldHide.apply(webview, args)
};
webview.close = function (...args) {
closeMask();
return oldClose.apply(webview, args)
};
}
const subNVue = {
getSubNVueById (id) {
const webview = plus.webview.getWebviewById(id);
if (webview && !webview.$processed) {
wrapper$1(webview);
}
return webview
}
};
function requireNativePlugin (pluginName) {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
if (typeof weex !== 'undefined') { if (typeof weex !== 'undefined') {
return weex.requireModule(pluginName) return weex.requireModule(pluginName)
...@@ -258,7 +305,8 @@ function requireNativePlugin (pluginName) { ...@@ -258,7 +305,8 @@ function requireNativePlugin (pluginName) {
} }
var api = /*#__PURE__*/Object.freeze({ var api = /*#__PURE__*/Object.freeze({
requireNativePlugin: requireNativePlugin requireNativePlugin: requireNativePlugin,
subNVue: subNVue
}); });
const MPPage = Page; const MPPage = Page;
...@@ -532,7 +580,7 @@ function getProperties (props, isBehavior = false, file = '') { ...@@ -532,7 +580,7 @@ function getProperties (props, isBehavior = false, file = '') {
return properties return properties
} }
function wrapper$1 (event) { function wrapper$2 (event) {
// TODO 又得兼容 mpvue 的 mp 对象 // TODO 又得兼容 mpvue 的 mp 对象
try { try {
event.mp = JSON.parse(JSON.stringify(event)); event.mp = JSON.parse(JSON.stringify(event));
...@@ -683,7 +731,7 @@ const ONCE = '~'; ...@@ -683,7 +731,7 @@ const ONCE = '~';
const CUSTOM = '^'; const CUSTOM = '^';
function handleEvent (event) { function handleEvent (event) {
event = wrapper$1(event); event = wrapper$2(event);
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]] // [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const eventOpts = (event.currentTarget || event.target).dataset.eventOpts; const eventOpts = (event.currentTarget || event.target).dataset.eventOpts;
...@@ -975,6 +1023,17 @@ function createComponent (vueOptions) { ...@@ -975,6 +1023,17 @@ function createComponent (vueOptions) {
return initComponent$1(componentOptions, vueOptions) return initComponent$1(componentOptions, vueOptions)
} }
todos.forEach(todoApi => {
protocols[todoApi] = false;
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!wx.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
let uni = {}; let uni = {};
if (typeof Proxy !== 'undefined') { if (typeof Proxy !== 'undefined') {
......
{ {
"name": "@dcloudio/uni-app-plus", "name": "@dcloudio/uni-app-plus",
"version": "0.0.230", "version": "0.0.231",
"description": "uni-app app-plus", "description": "uni-app app-plus",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -2,7 +2,7 @@ import { ...@@ -2,7 +2,7 @@ import {
isFn isFn
} from 'uni-shared' } from 'uni-shared'
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/ const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
const CONTEXT_API_RE = /^create|Manager$/ const CONTEXT_API_RE = /^create|Manager$/
......
export function requireNativePlugin (pluginName) { export function requireNativePlugin (pluginName) {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
if (typeof weex !== 'undefined') { if (typeof weex !== 'undefined') {
return weex.requireModule(pluginName) return weex.requireModule(pluginName)
} }
/* eslint-disable no-undef */ /* eslint-disable no-undef */
return __requireNativePlugin__(pluginName) return __requireNativePlugin__(pluginName)
} }
export * from './sub-nvue'
function wrapper (webview) {
webview.$processed = true
if (!webview.__uniapp_mask_id) {
return
}
const maskColor = webview.__uniapp_mask
const maskWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id)
const oldShow = webview.show
const oldHide = webview.hide
const oldClose = webview.close
const showMask = function () {
maskWebview.setStyle({
mask: maskColor
})
}
const closeMask = function () {
maskWebview.setStyle({
mask: 'none'
})
}
webview.show = function (...args) {
showMask()
return oldShow.apply(webview, args)
}
webview.hide = function (...args) {
closeMask()
return oldHide.apply(webview, args)
}
webview.close = function (...args) {
closeMask()
return oldClose.apply(webview, args)
}
}
export const subNVue = {
getSubNVueById (id) {
const webview = plus.webview.getWebviewById(id)
if (webview && !webview.$processed) {
wrapper(webview)
}
return webview
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册