Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ripplebb
uni-app
提交
27e873dc
U
uni-app
项目概览
ripplebb
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27e873dc
编写于
7月 28, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): $refs
上级
8bba8394
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
950 addition
and
330 deletion
+950
-330
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+154
-44
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+175
-62
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+165
-52
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+174
-61
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+110
-52
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+172
-59
未找到文件。
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
hasOwn
,
isArray
,
toNumber
,
isPlainObject
,
isObject
,
capitalize
,
isFunction
,
extend
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
toNumber
,
isObject
,
capitalize
,
isFunction
,
extend
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_BACK_PRESS
=
'
onBackPress
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
((
name
)
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
);
}
fns
.
forEach
((
opt
)
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
((
opt
)
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
;
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
,
...
cacheArgs
.
shift
()]);
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
,
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -88,6 +209,14 @@ function initBaseInstance(instance, options) {
},
});
}
ctx
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
;
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -120,47 +249,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_BACK_PRESS
=
'
onBackPress
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
)
;
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
]
;
return
hooks
&&
invokeArrayFns
(
hooks
,
args
)
;
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -282,7 +391,7 @@ function initWxsCallMethods(methods, wxsCallMethods) {
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
//
TODO vue3 中 没有 $children
//
标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -757,8 +866,8 @@ function parse(appOptions) {
}
var
parseAppOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
parse
:
parse
__proto__
:
null
,
parse
:
parse
});
function
handleLink$1
(
event
)
{
...
...
@@ -1128,6 +1237,7 @@ function createComponent$1(vueOptions) {
}
const
createApp
=
initCreateApp
(
parseAppOptions
);
my
.
EventChannel
=
EventChannel
;
my
.
createApp
=
createApp
;
my
.
createPage
=
createPage
;
my
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
isArray
,
hasOwn
,
toNumber
,
isPlainObject
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
((
name
)
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
);
}
fns
.
forEach
((
opt
)
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
((
opt
)
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
;
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
,
...
cacheArgs
.
shift
()]);
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
,
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -82,6 +202,14 @@ function initBaseInstance(instance, options) {
});
}
}
ctx
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
;
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -111,46 +239,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -282,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
@@ -304,7 +416,7 @@ function initRefs(instance, mpInstance) {
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
//
TODO vue3 中 没有 $children
//
标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -882,8 +994,8 @@ function parse$2(appOptions) {
}
var
parseAppOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
parse
:
parse$2
__proto__
:
null
,
parse
:
parse$2
});
function
initLifetimes
({
mocks
,
isPage
,
initRelation
,
vueOptions
,
})
{
...
...
@@ -988,13 +1100,13 @@ function parse$1(componentOptions) {
}
var
parseComponentOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
parse
:
parse$1
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
parse
:
parse$1
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
});
function
parse
(
pageOptions
)
{
...
...
@@ -1020,18 +1132,19 @@ function parse(pageOptions) {
}
var
parsePageOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
parse
:
parse
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
__proto__
:
null
,
parse
:
parse
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
});
const
createApp
=
initCreateApp
(
parseAppOptions
);
const
createPage
=
initCreatePage
(
parsePageOptions
);
const
createComponent
=
initCreateComponent
(
parseComponentOptions
);
swan
.
EventChannel
=
EventChannel
;
swan
.
createApp
=
createApp
;
swan
.
createPage
=
createPage
;
swan
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
isArray
,
hasOwn
,
toNumber
,
isPlainObject
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
((
name
)
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
);
}
fns
.
forEach
((
opt
)
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
((
opt
)
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
;
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
,
...
cacheArgs
.
shift
()]);
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
,
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -82,6 +202,14 @@ function initBaseInstance(instance, options) {
});
}
}
ctx
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
;
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -111,46 +239,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -282,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
@@ -304,7 +416,7 @@ function initRefs(instance, mpInstance) {
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
//
TODO vue3 中 没有 $children
//
标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -916,12 +1028,12 @@ function handleLink(event) {
}
var
parseOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
});
const
createApp
=
initCreateApp
();
...
...
@@ -931,6 +1043,7 @@ wx.createApp = createApp;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
qq
.
EventChannel
=
EventChannel
;
qq
.
createApp
=
createApp
;
qq
.
createPage
=
createPage
;
qq
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
isArray
,
hasOwn
,
toNumber
,
isPlainObject
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
((
name
)
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
);
}
fns
.
forEach
((
opt
)
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
((
opt
)
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
;
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
,
...
cacheArgs
.
shift
()]);
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
,
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -82,6 +202,14 @@ function initBaseInstance(instance, options) {
});
}
}
ctx
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
;
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -111,46 +239,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -285,15 +394,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
@@ -307,7 +419,7 @@ function initRefs(instance, mpInstance) {
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
//
TODO vue3 中 没有 $children
//
标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -1037,14 +1149,14 @@ function parse(componentOptions, { handleLink }) {
}
var
parseComponentOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
instances
:
instances
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes$1
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
instances
:
instances
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes$1
});
function
initLifetimes
(
lifetimesOptions
)
{
...
...
@@ -1074,18 +1186,19 @@ function initLifetimes(lifetimesOptions) {
}
var
parsePageOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes
});
const
createApp
=
initCreateApp
();
const
createPage
=
initCreatePage
(
parsePageOptions
);
const
createComponent
=
initCreateComponent
(
parseComponentOptions
);
tt
.
EventChannel
=
EventChannel
;
tt
.
createApp
=
createApp
;
tt
.
createPage
=
createPage
;
tt
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
isArray
,
hasOwn
,
toNumber
,
isPlainObject
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -82,6 +139,14 @@ function initBaseInstance(instance, options) {
});
}
}
ctx
.
getOpenerEventChannel
=
function
()
{
// 微信小程序使用自身getOpenerEventChannel
{
return
options
.
mpInstance
.
getOpenerEventChannel
();
}
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -111,46 +176,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -282,15 +328,27 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
{
if
(
component
.
dataset
.
vueGeneric
===
'
scoped
'
)
{
component
.
selectAllComponents
(
'
.scoped-ref
'
)
.
forEach
((
scopedComponent
)
=>
{
selectAllComponents
(
scopedComponent
,
selector
,
$refs
);
});
}
}
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
@@ -304,7 +362,7 @@ function initRefs(instance, mpInstance) {
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
//
TODO vue3 中 没有 $children
//
标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$children
;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -916,12 +974,12 @@ function handleLink(event) {
}
var
parseOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
initLifetimes
:
initLifetimes
});
const
createApp
=
initCreateApp
();
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
27e873dc
import
{
isArray
,
hasOwn
,
toNumber
,
isPlainObject
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
class
EventChannel
{
constructor
(
id
,
events
)
{
this
.
id
=
id
;
this
.
listener
=
{};
this
.
emitCache
=
{};
if
(
events
)
{
Object
.
keys
(
events
).
forEach
((
name
)
=>
{
this
.
on
(
name
,
events
[
name
]);
});
}
}
emit
(
eventName
,
...
args
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
(
this
.
emitCache
[
eventName
]
||
(
this
.
emitCache
[
eventName
]
=
[])).
push
(
args
);
}
fns
.
forEach
((
opt
)
=>
{
opt
.
fn
.
apply
(
opt
.
fn
,
args
);
});
this
.
listener
[
eventName
]
=
fns
.
filter
((
opt
)
=>
opt
.
type
!==
'
once
'
);
}
on
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
on
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
once
(
eventName
,
fn
)
{
this
.
_addListener
(
eventName
,
'
once
'
,
fn
);
this
.
_clearCache
(
eventName
);
}
off
(
eventName
,
fn
)
{
const
fns
=
this
.
listener
[
eventName
];
if
(
!
fns
)
{
return
;
}
if
(
fn
)
{
for
(
let
i
=
0
;
i
<
fns
.
length
;)
{
if
(
fns
[
i
].
fn
===
fn
)
{
fns
.
splice
(
i
,
1
);
i
--
;
}
i
++
;
}
}
else
{
delete
this
.
listener
[
eventName
];
}
}
_clearCache
(
eventName
)
{
const
cacheArgs
=
this
.
emitCache
[
eventName
];
if
(
cacheArgs
)
{
for
(;
cacheArgs
.
length
>
0
;)
{
this
.
emit
.
apply
(
this
,
[
eventName
,
...
cacheArgs
.
shift
()]);
}
}
}
_addListener
(
eventName
,
type
,
fn
)
{
(
this
.
listener
[
eventName
]
||
(
this
.
listener
[
eventName
]
=
[])).
push
({
fn
,
type
,
});
}
}
const
eventChannels
=
{};
const
eventChannelStack
=
[];
function
getEventChannel
(
id
)
{
if
(
id
)
{
const
eventChannel
=
eventChannels
[
id
];
delete
eventChannels
[
id
];
return
eventChannel
;
}
return
eventChannelStack
.
shift
();
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
...
...
@@ -82,6 +202,14 @@ function initBaseInstance(instance, options) {
});
}
}
ctx
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
this
.
__eventChannel__
=
new
EventChannel
();
}
return
this
.
__eventChannel__
;
};
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
}
...
...
@@ -111,46 +239,27 @@ function initMocks(instance, mpInstance, mocks) {
ctx
[
mock
]
=
mpInstance
[
mock
];
}
});
}
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
)
.
map
((
key
)
=>
{
let
val
=
obj
[
key
];
if
(
typeof
val
===
undefined
||
val
===
null
)
{
val
=
''
;
}
else
if
(
isPlainObject
(
val
))
{
val
=
JSON
.
stringify
(
val
);
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
);
})
.
filter
((
x
)
=>
x
.
length
>
0
)
.
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
// lifecycle
// App and Page
const
ON_SHOW
=
'
onShow
'
;
const
ON_HIDE
=
'
onHide
'
;
//App
const
ON_LAUNCH
=
'
onLaunch
'
;
const
ON_ERROR
=
'
onError
'
;
const
ON_THEME_CHANGE
=
'
onThemeChange
'
;
const
ON_PAGE_NOT_FOUND
=
'
onPageNotFound
'
;
const
ON_UNHANDLE_REJECTION
=
'
onUnhandledRejection
'
;
//Page
const
ON_LOAD
=
'
onLoad
'
;
const
ON_READY
=
'
onReady
'
;
const
ON_UNLOAD
=
'
onUnload
'
;
const
ON_RESIZE
=
'
onResize
'
;
const
ON_TAB_ITEM_TAP
=
'
onTabItemTap
'
;
const
ON_REACH_BOTTOM
=
'
onReachBottom
'
;
const
ON_PULL_DOWN_REFRESH
=
'
onPullDownRefresh
'
;
const
ON_ADD_TO_FAVORITES
=
'
onAddToFavorites
'
;
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
const
PAGE_HOOKS
=
[
ON_LOAD
,
...
...
@@ -282,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
@@ -1050,28 +1162,29 @@ function handleLink({ detail: { nodeId, webviewId }, }) {
}
var
parseComponentOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
mocks
:
mocks
,
isPage
:
isPage
,
parse
:
parse
,
initLifetimes
:
initLifetimes$1
__proto__
:
null
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
mocks
:
mocks
,
isPage
:
isPage
,
parse
:
parse
,
initLifetimes
:
initLifetimes$1
});
var
parsePageOptions
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes
__proto__
:
null
,
mocks
:
mocks
,
isPage
:
isPage
,
initRelation
:
initRelation
,
handleLink
:
handleLink
,
parse
:
parse
,
initLifetimes
:
initLifetimes
});
const
createApp
=
initCreateApp
();
const
createPage
=
initCreatePage
(
parsePageOptions
);
const
createComponent
=
initCreateComponent
(
parseComponentOptions
);
qa
.
EventChannel
=
EventChannel
;
qa
.
createApp
=
createApp
;
qa
.
createPage
=
createPage
;
qa
.
createComponent
=
createComponent
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录