Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
9cd72a49
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9cd72a49
编写于
10月 14, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
d93855c9
变更
18
展开全部
显示空白变更内容
内联
并排
Showing
18 changed file
with
543 addition
and
227 deletion
+543
-227
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+37
-21
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+114
-2
packages/uni-app-plus/dist/view.css
packages/uni-app-plus/dist/view.css
+1
-1
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+2
-2
packages/uni-h5/dist/index.css
packages/uni-h5/dist/index.css
+1
-1
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+9
-7
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+45
-20
packages/uni-mp-jd/dist/index.js
packages/uni-mp-jd/dist/index.js
+37
-21
packages/uni-mp-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+47
-22
packages/uni-mp-lark/dist/index.js
packages/uni-mp-lark/dist/index.js
+38
-19
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+36
-20
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+66
-38
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+34
-18
packages/uni-mp-xhs/dist/index.js
packages/uni-mp-xhs/dist/index.js
+35
-13
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+38
-19
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1132,7 +1132,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -1878,21 +1878,40 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -1900,7 +1919,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -1994,7 +2013,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2077,26 +2096,29 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
function
parseComponent$1
(
vueComponentOptions
)
{
const
componentOptions
=
parseComponent
(
vueComponentOptions
);
function
parseComponent$1
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
]
=
parseComponent
(
vueComponentOptions
,
true
);
componentOptions
.
methods
.
$getAppWebview
=
function
()
{
return
plus
.
webview
.
getWebviewById
(
`
${
this
.
__wxWebviewId__
}
`
)
};
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$2
=
[
...
...
@@ -2107,13 +2129,10 @@ const hooks$2 = [
hooks$2
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent$1
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent$1
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$2
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$2
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2133,10 +2152,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
return
parseBasePage
(
vuePageOptions
)
}
const
hooks$3
=
[
...
...
@@ -2252,7 +2268,7 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
wx
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
9cd72a49
...
...
@@ -57,7 +57,13 @@ var serviceContext = (function () {
'getLocation',
'chooseLocation',
'openLocation',
'createMapContext'
'createMapContext',
'onLocationChange',
'onLocationChangeError',
'startLocationUpdate',
'stopLocationUpdate',
'offLocationChange',
'offLocationChangeError'
];
const media = [
...
...
@@ -7086,6 +7092,86 @@ var serviceContext = (function () {
return api.openLocation(...array)
}
const callbackIds$2 = [];
const callbackOnErrorIds = [];
const callbackOffErrorIds = [];
let watchId;
/**
* 开始更新定位
*/
function startLocationUpdate ({ type = 'wgs84' }) {
watchId = plus.geolocation.watchPosition(
res => {
callbackIds$2.forEach(callbackId => {
invoke$1(callbackId, res.coords);
});
},
error => {
callbackOnErrorIds.forEach(callbackId => {
invoke$1(callbackId, {
errMsg: 'onLocationChange:fail' + error.message
});
});
},
{
coordsType: type
}
);
}
/**
* 暂停更新定位
* @param {*} callbackId
*/
function stopLocationUpdate (callbackId) {
if (watchId) {
plus.geolocation.clearWatch(watchId);
} else {
invoke$1(callbackId, { errMsg: 'stopLocationUpdate:fail' });
}
return {}
}
/**
* 监听更新定位
* @param {*} callbackId
*/
function onLocationChange (callbackId) {
callbackIds$2.push(callbackId);
}
/**
* 监听更新定位失败
* @param {*} callbackId
*/
function onLocationChangeError (callbackId) {
callbackOnErrorIds.push(callbackId);
}
// 移除实时地理位置变化事件的监听函数
function offLocationChange (callbackId) {
if (callbackId) {
const index = callbackIds$2.indexOf(callbackId);
if (index >= 0) {
callbackIds$2.splice(index, 1);
} else {
callbackOffErrorIds.forEach(callbackId => {
invoke$1(callbackId, {
errMsg: 'offLocationChange:fail'
});
});
}
} else {
callbackIds$2.length = 0;
}
}
// 移除实时地理位置变化事件的监听函数
function offLocationChangeError (callbackId) {
callbackOffErrorIds.push(callbackId);
}
const RECORD_TIME = 60 * 60 * 1000;
let recorder;
...
...
@@ -11790,7 +11876,9 @@ var serviceContext = (function () {
const data = {
code: e.code,
errMsg: e.message
errCode: e.code,
errMsg: e.message,
detail: e.detail
};
this._adError = data;
...
...
@@ -11800,6 +11888,7 @@ var serviceContext = (function () {
const error = new Error(JSON.stringify(this._adError));
error.code = e.code;
error.errMsg = e.message;
error.detail = e.detail;
if (this._loadPromiseReject != null) {
this._loadPromiseReject(error);
...
...
@@ -12235,6 +12324,12 @@ var serviceContext = (function () {
chooseLocation: chooseLocation$3,
getLocation: getLocation$1,
openLocation: openLocation$3,
startLocationUpdate: startLocationUpdate,
stopLocationUpdate: stopLocationUpdate,
onLocationChange: onLocationChange,
onLocationChangeError: onLocationChangeError,
offLocationChange: offLocationChange,
offLocationChangeError: offLocationChangeError,
startRecord: startRecord,
stopRecord: stopRecord,
playVoice: playVoice,
...
...
@@ -21500,11 +21595,28 @@ var serviceContext = (function () {
}
const onPushMessageCallbacks = [];
let listening = false;
// 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
const onPushMessage = (fn) => {
if (onPushMessageCallbacks.indexOf(fn) === -1) {
onPushMessageCallbacks.push(fn);
}
// 不能程序启动时就监听,因为离线事件,仅触发一次,框架监听后,无法转发给还没开始监听的开发者
if ( !listening) {
listening = true;
plus.push.addEventListener('click', (result) => {
invokePushCallback({
type: 'click',
message: result
});
});
plus.push.addEventListener('receive', (result) => {
invokePushCallback({
type: 'pushMsg',
message: result
});
});
}
};
const offPushMessage = (fn) => {
...
...
packages/uni-app-plus/dist/view.css
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.css
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1968,7 +1968,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2843,7 +2843,7 @@ function handleProps (ref) {
}
function
handleRef
(
ref
)
{
if
(
!
ref
)
{
if
(
!
(
ref
&&
this
.
$vm
)
)
{
return
}
if
(
ref
.
props
[
'
data-com-type
'
]
===
'
wx
'
)
{
...
...
@@ -3093,8 +3093,10 @@ function parsePage (vuePageOptions) {
triggerEvent
};
initHooks
(
pageOptions
,
hooks$1
,
vuePageOptions
);
initUnknownHooks
(
pageOptions
,
vuePageOptions
,
[
'
onReady
'
]);
Object
.
assign
(
pageOptions
.
events
,
vueOptions
.
events
||
{});
initHooks
(
pageOptions
,
hooks$1
,
vueOptions
);
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
]);
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
...
...
@@ -3192,7 +3194,7 @@ function initVm (VueComponent) {
}
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
properties
=
initProperties
(
vueOptions
.
props
,
false
,
vueOptions
.
__file
);
...
...
@@ -3255,7 +3257,7 @@ function parseComponent (vueComponentOptions) {
});
}
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
function
createComponent
(
vueOptions
)
{
...
...
@@ -3356,7 +3358,7 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
my
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
my
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
my
[
name
]))
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1490,9 +1490,18 @@ function requestPayment (params) {
}
}
function
createIntersectionObserver
(
component
,
options
)
{
if
(
options
&&
options
.
observeAll
)
{
options
.
selectAll
=
options
.
observeAll
;
delete
options
.
observeAll
;
}
return
swan
.
createIntersectionObserver
(
component
,
options
)
}
var
api
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
requestPayment
:
requestPayment
,
createIntersectionObserver
:
createIntersectionObserver
,
createMediaQueryObserver
:
createMediaQueryObserver
,
getPushClientId
:
getPushClientId
,
onPushMessage
:
onPushMessage
,
...
...
@@ -1596,7 +1605,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2332,21 +2341,40 @@ function initBehavior (options) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2354,7 +2382,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2495,7 +2523,7 @@ function fixSetDataEnd (mpInstance) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2578,6 +2606,9 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
...
...
@@ -2586,11 +2617,11 @@ function parseBaseComponent (vueComponentOptions, {
const
newLifecycle
=
swan
.
canIUse
(
'
lifecycle-2-0
'
);
function
parseComponent
(
vueOptions
)
{
const
componentOptions
=
parseBaseComponent
(
vue
Options
,
{
function
parseComponent
(
vue
ComponentOptions
,
needVue
Options
)
{
const
[
componentOptions
,
vueOptions
]
=
parseBaseComponent
(
vueComponent
Options
,
{
isPage
,
initRelation
});
}
,
true
);
// 关于百度小程序生命周期的说明(组件作为页面时):
// lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady
...
...
@@ -2651,7 +2682,7 @@ function parseComponent (vueOptions) {
};
delete
componentOptions
.
methods
.
__l
;
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$1
=
[
...
...
@@ -2662,13 +2693,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2702,10 +2730,7 @@ function onPageUnload ($vm) {
}
function
parsePage
(
vuePageOptions
)
{
const
pageOptions
=
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
});
const
pageOptions
=
parseBasePage
(
vuePageOptions
);
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
...
...
@@ -2842,7 +2867,7 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
swan
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
swan
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
swan
[
name
]))
...
...
packages/uni-mp-jd/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1213,7 +1213,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2014,21 +2014,40 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2036,7 +2055,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2122,7 +2141,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2205,27 +2224,30 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
function
parseComponent$1
(
vueComponentOptions
)
{
const
componentOptions
=
parseComponent
(
vueComponentOptions
);
function
parseComponent$1
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
]
=
parseComponent
(
vueComponentOptions
,
true
);
// 京东小程序 lifetimes 存在兼容问题
const
lifetimes
=
componentOptions
.
lifetimes
;
Object
.
keys
(
lifetimes
).
forEach
(
key
=>
{
componentOptions
[
key
]
=
lifetimes
[
key
];
});
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$1
=
[
...
...
@@ -2236,13 +2258,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent$1
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent$1
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2262,10 +2281,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
return
parseBasePage
(
vuePageOptions
)
}
function
parsePage$1
(
vuePageOptions
)
{
...
...
@@ -2376,7 +2392,7 @@ if (typeof Proxy !== 'undefined' && "mp-jd" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
jd
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
jd
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
jd
[
name
]))
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -945,7 +945,16 @@ const protocols = {
previewImage
,
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
,
getUserProfile
getUserProfile
,
requestPayment
:
{
name
:
ks
.
pay
?
'
pay
'
:
'
requestPayment
'
,
args
(
fromArgs
)
{
if
(
typeof
fromArgs
===
'
object
'
)
{
// ks.pay 服务类型 id(固定值为 '1')
if
(
ks
.
pay
&&
!
fromArgs
.
serviceId
)
fromArgs
.
serviceId
=
'
1
'
;
}
}
}
};
const
todos
=
[
'
vibrate
'
...
...
@@ -1381,7 +1390,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2101,21 +2110,40 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2123,7 +2151,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2209,7 +2237,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2292,17 +2320,20 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
/**
...
...
@@ -2343,8 +2374,8 @@ function fixSetDataEnd (mpInstance) {
}
}
function
parseComponent$1
(
vueComponentOptions
)
{
const
componentOptions
=
parseComponent
(
vueComponentOptions
);
function
parseComponent$1
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
]
=
parseComponent
(
vueComponentOptions
,
true
);
const
oldAttached
=
componentOptions
.
lifetimes
.
attached
;
componentOptions
.
lifetimes
.
attached
=
function
attached
()
{
// 暂不区分版本
...
...
@@ -2357,7 +2388,7 @@ function parseComponent$1 (vueComponentOptions) {
}
oldAttached
.
call
(
this
);
};
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$1
=
[
...
...
@@ -2368,13 +2399,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent$1
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent$1
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2394,10 +2422,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
return
parseBasePage
(
vuePageOptions
)
}
function
parsePage$1
(
vuePageOptions
)
{
...
...
@@ -2508,7 +2533,7 @@ if (typeof Proxy !== 'undefined' && "mp-kuaishou" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
ks
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
ks
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
ks
[
name
]))
...
...
packages/uni-mp-lark/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1431,7 +1431,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2148,21 +2148,40 @@ function initBehavior (options) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2170,7 +2189,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2328,7 +2347,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2411,14 +2430,20 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueOptions
)
{
const
[
componentOptions
,
VueComponent
]
=
parseBaseComponent
(
vueOptions
);
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
,
VueComponent
]
=
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
},
true
);
componentOptions
.
lifetimes
.
attached
=
function
attached
()
{
const
properties
=
this
.
properties
;
...
...
@@ -2452,7 +2477,7 @@ function parseComponent (vueOptions) {
componentOptions
.
methods
.
__l
=
handleLink$1
;
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$1
=
[
...
...
@@ -2463,13 +2488,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2489,10 +2511,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
const
pageOptions
=
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
});
const
pageOptions
=
parseBasePage
(
vuePageOptions
);
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
pageOptions
.
lifetimes
.
ready
=
function
ready
()
{
if
(
this
.
$vm
&&
this
.
$vm
.
mpType
===
'
page
'
)
{
...
...
@@ -2624,7 +2643,7 @@ if (typeof Proxy !== 'undefined' && "mp-lark" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
tt
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
tt
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
tt
[
name
]))
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1548,7 +1548,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2273,21 +2273,40 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2295,7 +2314,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2381,7 +2400,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2471,21 +2490,24 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
function
parseComponent$1
(
vueComponentOptions
)
{
return
parseComponent
(
vueComponentOptions
)
function
parseComponent$1
(
vueComponentOptions
,
needVueOptions
)
{
return
parseComponent
(
vueComponentOptions
,
needVueOptions
)
}
const
hooks$1
=
[
...
...
@@ -2496,13 +2518,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent$1
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent$1
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2522,10 +2541,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
return
parseBasePage
(
vuePageOptions
)
}
function
parsePage$1
(
vuePageOptions
)
{
...
...
@@ -2636,7 +2652,7 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
wx
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1638,7 +1638,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2354,6 +2354,53 @@ function initBehavior (options) {
return
Behavior
(
options
)
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[];
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[];
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
$refs
[
ref
]
=
[];
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
syncRefs
(
refs
,
$refs
)
}
});
}
function
handleLink
(
event
)
{
const
{
vuePid
,
...
...
@@ -2379,31 +2426,12 @@ function isPage () {
return
this
.
__nodeid__
===
0
||
this
.
__nodeId__
===
0
}
function
initRefs
(
vm
)
{
function
initRefs
$1
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
/* eslint-disable no-undef */
const
minorVersion
=
parseInt
(
tt
.
getSystemInfoSync
().
SDKVersion
.
split
(
'
.
'
)[
1
]);
if
(
minorVersion
>
16
)
{
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
// mpInstance 销毁后 selectAllComponents 取值为 null
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
)
||
[];
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[];
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
$refs
[
ref
]
=
[];
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
}
});
initRefs
(
vm
);
}
else
{
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
,
(
components
)
=>
{
components
.
forEach
(
component
=>
{
...
...
@@ -2490,7 +2518,7 @@ function parseApp (vm) {
this
.
$scope
.
route
=
this
.
$scope
.
__route__
;
}
initRefs
(
this
);
initRefs
$1
(
this
);
this
.
__init_injections
(
this
);
this
.
__init_provide
(
this
);
...
...
@@ -2555,7 +2583,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2638,6 +2666,9 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
...
...
@@ -2652,8 +2683,11 @@ function currentComponents (mpInstance, callback) {
}
}
function
parseComponent
(
vueOptions
)
{
const
[
componentOptions
,
VueComponent
]
=
parseBaseComponent
(
vueOptions
);
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
,
VueComponent
]
=
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
},
true
);
const
lifetimes
=
componentOptions
.
lifetimes
;
// 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正
...
...
@@ -2719,7 +2753,7 @@ function parseComponent (vueOptions) {
componentOptions
.
methods
.
__l
=
handleLink$1
;
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
const
hooks$1
=
[
...
...
@@ -2730,13 +2764,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2756,10 +2787,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
const
pageOptions
=
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
});
const
pageOptions
=
parseBasePage
(
vuePageOptions
);
const
lifetimes
=
pageOptions
.
lifetimes
;
const
oldCreated
=
lifetimes
.
created
;
lifetimes
.
created
=
function
created
()
{
...
...
@@ -2903,7 +2931,7 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
tt
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
tt
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
tt
[
name
]))
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1370,7 +1370,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2120,7 +2120,7 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
...
...
@@ -2134,14 +2134,33 @@ function selectAllComponents (mpInstance, selector, $refs) {
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2149,7 +2168,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2231,7 +2250,7 @@ function stringifyQuery (obj, encodeStr = encode) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2321,17 +2340,20 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
const
hooks$1
=
[
...
...
@@ -2342,13 +2364,10 @@ const hooks$1 = [
hooks$1
.
push
(...
PAGE_EVENT_HOOKS
);
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
);
function
parseBasePage
(
vuePageOptions
)
{
const
[
pageOptions
,
vueOptions
]
=
parseComponent
(
vuePageOptions
,
true
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vue
Page
Options
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vueOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
...
...
@@ -2368,10 +2387,7 @@ function parseBasePage (vuePageOptions, {
}
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
return
parseBasePage
(
vuePageOptions
)
}
function
createPage
(
vuePageOptions
)
{
...
...
@@ -2478,7 +2494,7 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
wx
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
wx
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
...
...
packages/uni-mp-xhs/dist/index.js
浏览文件 @
9cd72a49
...
...
@@ -1211,7 +1211,7 @@ function hasHook (hook, vueOptions) {
return
false
}
if
(
isFn
(
vueOptions
[
hook
]))
{
if
(
isFn
(
vueOptions
[
hook
])
||
Array
.
isArray
(
vueOptions
[
hook
])
)
{
return
true
}
const
mixins
=
vueOptions
.
mixins
;
...
...
@@ -2012,21 +2012,40 @@ function initRelation (detail) {
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
||
[]
;
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
syncRefs
(
refs
,
newRefs
)
{
const
oldKeys
=
new
Set
(...
Object
.
keys
(
refs
));
const
newKeys
=
Object
.
keys
(
newRefs
);
newKeys
.
forEach
(
key
=>
{
const
oldValue
=
refs
[
key
];
const
newValue
=
newRefs
[
key
];
if
(
Array
.
isArray
(
oldValue
)
&&
Array
.
isArray
(
newValue
)
&&
oldValue
.
length
===
newValue
.
length
&&
newValue
.
every
(
value
=>
oldValue
.
includes
(
value
)))
{
return
}
refs
[
key
]
=
newValue
;
oldKeys
.
delete
(
key
);
});
oldKeys
.
forEach
(
key
=>
{
delete
refs
[
key
];
});
return
refs
}
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
;
const
refs
=
{};
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
// TODO 暂不考虑 for 中的 scoped
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
||
[]
;
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
;
if
(
!
$refs
[
ref
])
{
...
...
@@ -2034,7 +2053,7 @@ function initRefs (vm) {
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
);
});
return
$refs
return
syncRefs
(
refs
,
$refs
)
}
});
}
...
...
@@ -2222,8 +2241,8 @@ function parsePage (vuePageOptions) {
triggerEvent
:
function
noop
()
{}
};
initHooks
(
pageOptions
,
hooks$1
,
vue
Page
Options
);
initUnknownHooks
(
pageOptions
,
vue
Page
Options
,
[
'
onReady
'
]);
initHooks
(
pageOptions
,
hooks$1
,
vueOptions
);
initUnknownHooks
(
pageOptions
,
vueOptions
,
[
'
onReady
'
]);
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
...
...
@@ -2245,7 +2264,7 @@ function createPage (vuePageOptions) {
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
}
=
{}
,
needVueOptions
)
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
);
const
options
=
{
...
...
@@ -2328,17 +2347,20 @@ function parseBaseComponent (vueComponentOptions, {
});
}
if
(
needVueOptions
)
{
return
[
componentOptions
,
vueOptions
,
VueComponent
]
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
function
parseComponent
(
vueComponentOptions
)
{
function
parseComponent
(
vueComponentOptions
,
needVueOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
,
needVueOptions
)
}
/**
...
...
@@ -2381,8 +2403,8 @@ function fixSetDataEnd (mpInstance) {
// import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
function
parseComponent$1
(
vueComponentOptions
)
{
const
componentOptions
=
parseComponent
(
vueComponentOptions
);
function
parseComponent$1
(
vueComponentOptions
,
needVueOptions
)
{
const
[
componentOptions
,
vueOptions
]
=
parseComponent
(
vueComponentOptions
,
true
);
const
oldAttached
=
componentOptions
.
lifetimes
.
attached
;
componentOptions
.
lifetimes
.
attached
=
function
attached
()
{
// 暂不区分版本
...
...
@@ -2394,7 +2416,7 @@ function parseComponent$1 (vueComponentOptions) {
}
oldAttached
.
call
(
this
);
};
return
componentOptions
return
needVueOptions
?
[
componentOptions
,
vueOptions
]
:
componentOptions
}
function
createComponent
(
vueOptions
)
{
...
...
@@ -2495,7 +2517,7 @@ if (typeof Proxy !== 'undefined' && "mp-xhs" !== 'app-plus') {
if
(
eventApi
[
name
])
{
return
eventApi
[
name
]
}
if
(
!
hasOwn
(
xhs
,
name
)
&&
!
hasOwn
(
protocols
,
name
))
{
if
(
typeof
xhs
[
name
]
!==
'
function
'
&&
!
hasOwn
(
protocols
,
name
))
{
return
}
return
promisify
(
name
,
wrapper
(
name
,
xhs
[
name
]))
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
9cd72a49
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录