Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
7c9072e5
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c9072e5
编写于
9月 19, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
bcc37ef7
f9b24639
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
1255 addition
and
631 deletion
+1255
-631
docs/api/key.md
docs/api/key.md
+1
-1
packages/uni-cli-shared/components/uni-match-media.vue
packages/uni-cli-shared/components/uni-match-media.vue
+16
-16
packages/uni-cli-shared/lib/tags.js
packages/uni-cli-shared/lib/tags.js
+1
-1
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+59
-8
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+42
-36
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+5
-0
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+59
-8
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+32
-35
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+59
-8
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+31
-34
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+58
-7
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+31
-34
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+672
-355
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+59
-8
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+31
-34
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+59
-8
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+32
-35
packages/uni-template-compiler/lib/mp.js
packages/uni-template-compiler/lib/mp.js
+1
-1
packages/vue-cli-plugin-uni/generator.js
packages/vue-cli-plugin-uni/generator.js
+1
-1
src/platforms/mp-baidu/runtime/wrapper/page-parser.js
src/platforms/mp-baidu/runtime/wrapper/page-parser.js
+5
-0
src/platforms/mp-weixin/helpers/create-media-query-observer.js
...latforms/mp-weixin/helpers/create-media-query-observer.js
+1
-1
未找到文件。
docs/api/key.md
浏览文件 @
7c9072e5
...
...
@@ -43,7 +43,7 @@ uni.onKeyboardHeightChange(res => {
|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|HBuilderX 2.8.1
0+|HBuilderX 2.8.10
+|基础库 2.7.0+|x|x|x|x|
|HBuilderX 2.8.1
2+|HBuilderX 2.8.12
+|基础库 2.7.0+|x|x|x|x|
**OBJECT 参数说明:**
...
...
packages/uni-cli-shared/components/uni-match-media.vue
浏览文件 @
7c9072e5
<
template
>
<view
v-show=
"matches"
>
<slot
/>
</view>
<view
v-show=
"matches"
>
<slot
/>
</view>
</
template
>
<
script
>
...
...
@@ -41,26 +41,26 @@ export default {
data
()
{
return
{
matches
:
true
,
matches
:
true
}
},
mounted
()
{
mounted
()
{
mediaQueryObserver
=
uni
.
createMediaQueryObserver
(
this
)
mediaQueryObserver
.
observe
({
width
:
this
.
width
,
maxWidth
:
this
.
maxWidth
,
minWidth
:
this
.
minWidth
,
height
:
this
.
height
,
minHeight
:
this
.
minHeight
,
maxHeight
:
this
.
maxHeight
,
orientation
:
this
.
orientation
},
matches
=>
{
this
.
matches
=
matches
})
width
:
this
.
width
,
maxWidth
:
this
.
maxWidth
,
minWidth
:
this
.
minWidth
,
height
:
this
.
height
,
minHeight
:
this
.
minHeight
,
maxHeight
:
this
.
maxHeight
,
orientation
:
this
.
orientation
},
matches
=>
{
this
.
matches
=
matches
})
},
destroyed
()
{
destroyed
()
{
mediaQueryObserver
.
disconnect
()
}
}
...
...
packages/uni-cli-shared/lib/tags.js
浏览文件 @
7c9072e5
...
...
@@ -40,5 +40,5 @@ module.exports = {
textarea
:
[
'
app-plus
'
,
'
mp-weixin
'
,
'
h5
'
],
video
:
[
'
app-plus
'
,
'
mp-weixin
'
,
'
h5
'
],
view
:
[
'
app-plus
'
,
'
mp-weixin
'
,
'
h5
'
],
'
web-view
'
:
[
'
app-plus
'
,
'
mp-weixin
'
]
,
'
web-view
'
:
[
'
app-plus
'
,
'
mp-weixin
'
]
}
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -413,7 +449,20 @@ function addSafeAreaInsets(fromRes, toRes) {
bottom
:
fromRes
.
windowHeight
-
safeArea
.
bottom
};
}
}
}
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
getProvider
=
initGetProvider
({
oauth
:
[
'
alipay
'
],
...
...
@@ -1000,7 +1049,9 @@ var protocols = /*#__PURE__*/Object.freeze({
hideHomeButton
:
hideHomeButton
,
saveImageToPhotosAlbum
:
saveImageToPhotosAlbum
,
saveVideoToPhotosAlbum
:
saveVideoToPhotosAlbum
,
chooseAddress
:
chooseAddress
chooseAddress
:
chooseAddress
,
redirectTo
:
redirectTo
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -89,9 +67,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -100,7 +75,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -111,15 +88,8 @@ function initBaseInstance(instance, options) {
}
});
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -216,7 +186,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -247,6 +217,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
...
...
@@ -261,6 +251,16 @@ function initVueIds(vueIds, mpInstance) {
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// TODO vue3 中 没有 $children
const
$children
=
instance
.
$children
;
...
...
@@ -971,11 +971,15 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
function
createPage
(
vueOptions
)
{
vueOptions
=
vueOptions
.
default
||
vueOptions
;
const
pageOptions
=
{
onLoad
(
args
)
{
onLoad
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
// 初始化 vue 实例
this
.
$vm
=
createVueComponent
(
'
page
'
,
this
,
vueOptions
);
initSpecialMethods
(
this
);
this
.
$vm
.
$callHook
(
'
onLoad
'
,
args
);
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
},
onReady
()
{
initChildVues
(
this
);
...
...
@@ -1003,6 +1007,7 @@ function createPage(vueOptions) {
}
initHooks
(
pageOptions
,
PAGE_HOOKS
);
initUnknownHooks
(
pageOptions
,
vueOptions
);
initWxsCallMethods
(
pageOptions
,
vueOptions
.
wxsCallMethods
);
return
Page
(
pageOptions
);
}
...
...
@@ -1099,6 +1104,7 @@ function createComponent(vueOptions) {
else
{
mpComponentOptions
.
didUpdate
=
createObserver
(
true
);
}
initWxsCallMethods
(
mpComponentOptions
.
methods
,
vueOptions
.
wxsCallMethods
);
return
Component
(
mpComponentOptions
);
}
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
7c9072e5
...
...
@@ -1990,6 +1990,11 @@ function parsePage (vuePageOptions) {
initRelation
});
const
onInit
=
(
vuePageOptions
.
default
||
vuePageOptions
).
onInit
;
if
(
onInit
)
{
pageOptions
.
methods
.
onInit
=
onInit
;
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
};
const
getSystemInfoSync
=
getSystemInfo
;
const
getSystemInfoSync
=
getSystemInfo
;
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
getProvider
=
initGetProvider
({
oauth
:
[
'
baidu
'
],
...
...
@@ -565,9 +614,11 @@ var protocols = /*#__PURE__*/Object.freeze({
navigateBackMiniProgram
:
navigateBackMiniProgram
,
showShareMenu
:
showShareMenu
,
getAccountInfoSync
:
getAccountInfoSync
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
...
...
@@ -810,6 +800,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const
methods
=
miniProgramPageOptions
.
methods
;
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
return
this
.
$vm
&&
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
};
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
@@ -929,7 +926,7 @@ function handleLink(event) {
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
function
isPage
(
mpInstance
)
{
return
!
mpInstance
.
ownerId
;
return
!
hasOwn
(
mpInstance
,
'
ownerId
'
)
;
}
function
initRelation
(
mpInstance
,
detail
)
{
mpInstance
.
dispatch
(
'
__l
'
,
detail
);
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
};
const
getSystemInfoSync
=
getSystemInfo
;
const
getSystemInfoSync
=
getSystemInfo
;
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
getProvider
=
initGetProvider
({
oauth
:
[
'
qq
'
],
...
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
...
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const
methods
=
miniProgramPageOptions
.
methods
;
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
return
this
.
$vm
&&
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
};
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -435,6 +471,19 @@ const previewImage = {
loop
:
false
};
}
};
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
getProvider
=
initGetProvider
({
...
...
@@ -536,7 +585,9 @@ var protocols = /*#__PURE__*/Object.freeze({
getUserInfo
:
getUserInfo
,
requestPayment
:
requestPayment
,
getFileInfo
:
getFileInfo
,
previewImage
:
previewImage
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -210,7 +180,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -241,6 +211,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
...
...
@@ -800,6 +790,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const
methods
=
miniProgramPageOptions
.
methods
;
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
return
this
.
$vm
&&
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
};
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
7c9072e5
此差异已折叠。
点击以展开。
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
};
const
getSystemInfoSync
=
getSystemInfo
;
const
getSystemInfoSync
=
getSystemInfo
;
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
getProvider
=
initGetProvider
({
oauth
:
[
'
weixin
'
],
...
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
...
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const
methods
=
miniProgramPageOptions
.
methods
;
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
return
this
.
$vm
&&
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
};
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
7c9072e5
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
const
API_TYPE_SYNC
=
1
;
function
validateProtocol
(
_name
,
_args
,
_protocol
)
{
return
true
;
}
function
formatApiArgs
(
args
,
options
)
{
if
(
!
options
)
{
return
args
;
}
}
function
createApi
({
type
,
name
,
options
},
fn
,
protocol
)
{
return
function
(...
args
)
{
if
(
type
===
API_TYPE_SYNC
)
{
if
(
!
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
protocol
&&
!
validateProtocol
()))
{
return
fn
.
apply
(
null
,
formatApiArgs
(
args
,
options
));
}
}
};
}
const
Upx2pxProtocol
=
[
{
name
:
'
upx
'
,
type
:
[
Number
,
String
],
required
:
true
}
];
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
...
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
}
...
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
...
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
}
}
function
addInterceptor
(
method
,
interceptor
)
{
const
addInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
addInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
interceptor
)
{
}
,
AddInterceptorProtocol
);
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
,
RemoveInterceptorProtocol
);
const
SYNC_API_RE
=
/^
\$
|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
};
const
getSystemInfoSync
=
getSystemInfo
;
const
getSystemInfoSync
=
getSystemInfo
;
const
redirectTo
=
{};
const
createCanvasContext
=
{
returnValue
(
fromRes
,
toRes
)
{
const
measureText
=
fromRes
.
measureText
;
toRes
.
measureText
=
function
(
text
,
callback
)
{
const
textMetrics
=
measureText
.
call
(
this
,
text
);
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(()
=>
callback
(
textMetrics
),
0
);
}
return
textMetrics
;
};
}
};
const
providers
=
{
oauth
:
[],
...
...
@@ -473,9 +522,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
7c9072e5
...
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectComponent
'
];
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
'
;
}
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
}
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
// mp
...
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
...
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
...
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
}
...
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
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
}
`
:
''
;
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
...
...
@@ -772,6 +762,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const
methods
=
miniProgramPageOptions
.
methods
;
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
return
this
.
$vm
&&
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
};
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
@@ -969,7 +966,7 @@ function initLifetimes$1(lifetimesOptions) {
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
function
isPage
(
mpInstance
)
{
return
!
mpInstance
.
ownerId
;
return
!
hasOwn
(
mpInstance
,
'
ownerId
'
)
;
}
function
initRelation
(
mpInstance
)
{
...
...
packages/uni-template-compiler/lib/mp.js
浏览文件 @
7c9072e5
...
...
@@ -47,7 +47,7 @@ const tags = [
'
video
'
,
'
view
'
,
'
web-view
'
,
'
editor
'
,
'
editor
'
]
const
baseCompiler
=
{
...
...
packages/vue-cli-plugin-uni/generator.js
浏览文件 @
7c9072e5
...
...
@@ -58,7 +58,7 @@ module.exports = (api, options, rootOptions) => {
'
@dcloudio/uni-quickapp-native
'
:
version
,
'
@dcloudio/uni-quickapp-webview
'
:
version
,
'
@dcloudio/uni-stat
'
:
version
,
'
@vue/shared
'
:
'
^3.0.0
-rc.4
'
,
// TODO
'
@vue/shared
'
:
'
^3.0.0
'
,
flyio
:
'
^0.6.2
'
,
vuex
:
'
^3.2.0
'
},
...
...
src/platforms/mp-baidu/runtime/wrapper/page-parser.js
浏览文件 @
7c9072e5
...
...
@@ -29,6 +29,11 @@ export default function parsePage (vuePageOptions) {
initRelation
})
const
onInit
=
(
vuePageOptions
.
default
||
vuePageOptions
).
onInit
if
(
onInit
)
{
pageOptions
.
methods
.
onInit
=
onInit
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
...
...
src/platforms/mp-weixin/helpers/create-media-query-observer.js
浏览文件 @
7c9072e5
...
...
@@ -8,7 +8,7 @@ export default function createMediaQueryObserver () {
const
orientation
=
windowWidth
<
windowHeight
?
'
portrait
'
:
'
landscape
'
mediaQueryObserver
.
observe
=
(
options
,
callback
)
=>
{
let
matches
=
fals
e
let
matches
=
tru
e
for
(
const
item
in
options
)
{
const
itemValue
=
item
===
'
orientation
'
?
options
[
item
]
:
Number
(
options
[
item
])
if
(
options
[
item
]
!==
''
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录