提交 e3cd58ad 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return my.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -601,7 +601,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(my.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return swan.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -622,7 +622,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(swan.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return ks.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -622,7 +622,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(ks.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return qq.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -622,7 +622,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(qq.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return tt.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -625,7 +625,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(tt.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -2561,7 +2561,7 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) ||
// window registration
// global registration
resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
// fallback to implicit self-reference
......@@ -3048,7 +3048,7 @@ const PublicInstanceProxyHandlers = {
return ctx[key];
}
else if (
// window properties
// global properties
((globalProperties = appContext.config.globalProperties),
hasOwn(globalProperties, key))) {
{
......@@ -3392,6 +3392,11 @@ let compile;
const isRuntimeOnly = () => !compile;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
// template / render function normalization
// could be already set when returned from setup()
if (!instance.render) {
instance.render = (Component.render || NOOP);
}
// support for 2.x options
if (__VUE_OPTIONS_API__ && !(false )) {
setCurrentInstance(instance);
......@@ -4276,15 +4281,21 @@ function getContext() {
* only.
* @internal
*/
function mergeDefaults(
// the base props is compiler-generated and guaranteed to be in this shape.
props, defaults) {
function mergeDefaults(raw, defaults) {
const props = isArray(raw)
? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
: raw;
for (const key in defaults) {
const val = props[key];
if (val) {
val.default = defaults[key];
const opt = props[key];
if (opt) {
if (isArray(opt) || isFunction(opt)) {
props[key] = { type: opt, default: defaults[key] };
}
else {
opt.default = defaults[key];
}
}
else if (val === null) {
else if (opt === null) {
props[key] = { default: defaults[key] };
}
else if ((process.env.NODE_ENV !== 'production')) {
......@@ -4341,7 +4352,7 @@ const useSSRContext = () => {
};
// Core API ------------------------------------------------------------------
const version = "3.2.19";
const version = "3.2.20";
/**
* @internal only exposed in compat builds
*/
......@@ -4664,10 +4675,48 @@ function mountComponent(initialVNode, options) {
}
return instance.proxy;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key in attrs) {
if (key === 'class' || key === 'style' || isOn(key)) {
(res || (res = {}))[key] = attrs[key];
}
}
return res;
};
function renderComponentRoot(instance) {
const { type: Component, vnode, proxy, withProxy, props, slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
let result;
const prev = setCurrentRenderingInstance(instance);
try {
if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
const proxyToUse = withProxy || proxy;
result = render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx);
}
else {
// functional
const render = Component;
result =
render.length > 1
? render(props, { attrs, slots, emit })
: render(props, null /* we know it doesn't need it */)
? attrs
: getFunctionalFallthrough(attrs);
}
}
catch (err) {
handleError(err, instance, 1 /* RENDER_FUNCTION */);
result = false;
}
setCurrentRenderingInstance(prev);
return result;
}
function setupRenderEffect(instance) {
const componentUpdateFn = () => {
if (!instance.isMounted) {
instance.render && instance.render.call(instance.proxy);
renderComponentRoot(instance);
patch(instance);
}
else {
......@@ -4680,6 +4729,7 @@ function setupRenderEffect(instance) {
invokeArrayFns(bu);
}
effect.allowRecurse = true;
renderComponentRoot(instance);
patch(instance);
// updated hook
if (u) {
......@@ -4818,8 +4868,44 @@ function initOptionMergeStrategies(optionMergeStrategies) {
});
}
let realAtob;
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function (str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap;
var result = '';
var r1;
var r2;
var i = 0;
for (; i < str.length;) {
bitmap =
(b64.indexOf(str.charAt(i++)) << 18) |
(b64.indexOf(str.charAt(i++)) << 12) |
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
(r2 = b64.indexOf(str.charAt(i++)));
result +=
r1 === 64
? String.fromCharCode((bitmap >> 16) & 255)
: r2 === 64
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
}
return result;
};
}
else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str)
return decodeURIComponent(realAtob(str)
.split('')
.map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
......@@ -4883,11 +4969,21 @@ function initApp(app) {
var plugin = {
install(app) {
initApp(app);
// TODO 旧编译器使用了$createElement 导致告警
app.config.globalProperties.$createElement = () => { };
const oldMount = app.mount;
app.mount = function mount(rootContainer) {
const instance = oldMount.call(app, rootContainer);
// @ts-ignore
createMiniProgramApp(instance);
if (global.createApp) {
global.createApp(instance);
}
else {
// @ts-ignore 旧编译器
if (typeof createMiniProgramApp !== 'undefined') {
// @ts-ignore
createMiniProgramApp(instance);
}
}
return instance;
};
},
......
......@@ -698,7 +698,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return wx.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -568,7 +568,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(wx.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -734,7 +734,7 @@ const getLocale = () => {
if (app && app.$vm) {
return app.$vm.$locale;
}
return uni.getSystemInfoSync().language || 'zh-Hans';
return qa.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const app = getApp();
......
......@@ -553,7 +553,7 @@ function initCreateApp(parseAppOptions) {
};
}
function initLocale(appVm) {
const locale = ref(uni.getSystemInfoSync().language || 'zh-Hans');
const locale = ref(qa.getSystemInfoSync().language || 'zh-Hans');
Object.defineProperty(appVm, '$locale', {
get() {
return locale.value;
......
......@@ -30,6 +30,15 @@ function convertLength (k, v) {
}
let isFirst = true
const ZERO_WIDTH_CHAR = {
NOTE: '',
WARNING: '\u200B',
ERROR: '\u200C',
backup0: '\u200D',
backup1: '\u200E',
backup2: '\u200F',
backup3: '\uFEFF'
}
function genStyleString (input, loader) {
var output = '{}'
......@@ -56,7 +65,11 @@ function genStyleString (input, loader) {
msgs.unshift(uniI18n.__('pluginHbuilderx.nvueCssWarning'))
isFirst = false
}
msgs.forEach(msg => console.warn(msg))
msgs.forEach(msg => {
const msgType = ZERO_WIDTH_CHAR[msg.split(':')[0]]
msgType && (msg = msgType + msg + msgType)
console.warn(msg)
})
}
}
try {
......
......@@ -39,6 +39,13 @@ export class MapContext {
constructor (id, pageVm) {
this.id = id
this.pageVm = pageVm
}
on (name, callback) {
operateMapPlayer(this.id, this.pageVm, 'on', {
name,
callback
})
}
}
......@@ -46,7 +53,7 @@ MapContext.prototype.$getAppMap = function () {
if (__PLATFORM__ === 'app-plus') {
return plus.maps.getMapById(this.pageVm.$page.id + '-map-' + this.id)
}
}
}
methods.forEach(function (method) {
MapContext.prototype[method] = callback.warp(function (options, callbackId) {
......
......@@ -38,7 +38,7 @@ export default {
if (typeof nodes === 'string') {
nodes = parseHtml(nodes)
}
const nodeList = parseNodes(nodes, document.createDocumentFragment())
const nodeList = parseNodes(nodes, document.createDocumentFragment(), this)
nodeList.appendChild(this.$refs.sensor.$el)
const content = this.$refs.content
content.innerHTML = ''
......
......@@ -96,7 +96,13 @@ function decodeEntities (htmlString) {
})
}
export default function parseNodes (nodes, parentNode) {
export default function parseNodes (nodes, parentNode, $vm) {
let scopeId = ''
while ($vm) {
!scopeId && (scopeId = $vm.$options._scopeId)
$vm = $vm.$parent
}
nodes.forEach(function (node) {
if (!isPlainObject(node)) {
return
......@@ -124,6 +130,7 @@ export default function parseNodes (nodes, parentNode) {
Array.isArray(value) && (value = value.join(' '))
case 'style':
elem.setAttribute(name, value)
scopeId && elem.setAttribute(scopeId, '')
break
default:
if (tagAttrs.indexOf(name) !== -1) {
......@@ -146,4 +153,4 @@ export default function parseNodes (nodes, parentNode) {
}
})
return parentNode
}
}
......@@ -52,6 +52,9 @@ const METHODS = {
},
openMapApp (ctx, args) {
return invokeVmMethod(ctx, 'openMapApp', args)
},
on (ctx, args) {
return ctx.on(args.name, args.callback)
}
}
......
......@@ -121,24 +121,35 @@ export function showModal ({
cancelText,
cancelColor,
confirmText,
confirmColor
confirmColor,
editable = false,
placeholderText = ''
} = {}, callbackId) {
// TODO 在 editable 为 true 时,content 应该是输入框中可修改内容。后续找客户端商量。
const buttons = showCancel ? [cancelText, confirmText] : [confirmText]
const tip = editable ? placeholderText : buttons
content = content || ' '
plus.nativeUI.confirm(content, (e) => {
plus.nativeUI[editable ? 'prompt' : 'confirm'](content, (e) => {
if (showCancel) {
invoke(callbackId, {
const isConfirm = e.index === 1
const res = {
errMsg: 'showModal:ok',
confirm: e.index === 1,
confirm: isConfirm,
cancel: e.index === 0 || e.index === -1
})
}
isConfirm && editable && (res.content = e.value)
invoke(callbackId, res)
} else {
invoke(callbackId, {
const res = {
errMsg: 'showModal:ok',
confirm: e.index === 0,
cancel: false
})
}
editable && (res.content = e.value)
invoke(callbackId, res)
}
}, title, showCancel ? [cancelText, confirmText] : [confirmText])
}, title, tip, buttons)
}
export function showActionSheet ({
itemList = [],
......
......@@ -21,9 +21,9 @@ export default {
},
methods: {
// 处理 modal close 回调
_onModalClose (type) {
_onModalClose (res) {
this.showModal.visible = false
isFn(this.onModalCloseCallback) && this.onModalCloseCallback(type)
isFn(this.onModalCloseCallback) && this.onModalCloseCallback(res)
}
}
}
}
......@@ -15,7 +15,16 @@
v-text="title"
/>
</div>
<textarea
v-if="editable"
ref="editContent"
class="uni-modal__textarea"
rows="1"
:placeholder="placeholderText"
:value="content"
/>
<div
v-else
class="uni-modal__bd"
@touchmove.stop
v-text="content"
......@@ -41,7 +50,7 @@
<keypress
:disable="!visible"
@esc="_close('cancel')"
@enter="_close('confirm')"
@enter="!editable && _close('confirm')"
/>
</uni-modal>
</transition>
......@@ -86,11 +95,25 @@ export default {
visible: {
type: Boolean,
default: false
},
editable: {
type: Boolean,
default: false
},
placeholderText: {
type: String,
default: ''
}
},
methods: {
_close (type) {
this.$emit('close', type)
const res = {
[type]: true
}
if (this.editable && type === 'confirm') {
res.content = this.$refs.editContent.value
}
this.$emit('close', res)
}
}
}
......@@ -156,6 +179,19 @@ export default {
overflow-y: auto;
}
uni-modal .uni-modal__textarea {
resize: none;
border: 0;
margin: 0;
width: 90%;
padding: 10px;
font-size: 20px;
outline: none;
border: none;
background-color: #eee;
text-decoration: inherit;
}
uni-modal .uni-modal__ft {
position: relative;
line-height: 48px;
......
......@@ -4,10 +4,8 @@ const {
} = UniServiceJSBridge
export function showModal (args, callbackId) {
emit('onShowModal', args, function (type) {
invoke(callbackId, {
[type]: true
})
emit('onShowModal', args, function (res) {
invoke(callbackId, res)
})
}
......@@ -43,4 +41,4 @@ export function showActionSheet (args, callbackId) {
})
}
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册