Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
7325d4b3
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
7325d4b3
编写于
9月 19, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp): vue@3.0.0
上级
6d85aa0c
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
1320 addition
and
626 deletion
+1320
-626
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-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+85
-15
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/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
未找到文件。
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -413,7 +449,20 @@ function addSafeAreaInsets(fromRes, toRes) {
...
@@ -413,7 +449,20 @@ function addSafeAreaInsets(fromRes, toRes) {
bottom
:
fromRes
.
windowHeight
-
safeArea
.
bottom
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
({
const
getProvider
=
initGetProvider
({
oauth
:
[
'
alipay
'
],
oauth
:
[
'
alipay
'
],
...
@@ -1000,7 +1049,9 @@ var protocols = /*#__PURE__*/Object.freeze({
...
@@ -1000,7 +1049,9 @@ var protocols = /*#__PURE__*/Object.freeze({
hideHomeButton
:
hideHomeButton
,
hideHomeButton
:
hideHomeButton
,
saveImageToPhotosAlbum
:
saveImageToPhotosAlbum
,
saveImageToPhotosAlbum
:
saveImageToPhotosAlbum
,
saveVideoToPhotosAlbum
:
saveVideoToPhotosAlbum
,
saveVideoToPhotosAlbum
:
saveVideoToPhotosAlbum
,
chooseAddress
:
chooseAddress
chooseAddress
:
chooseAddress
,
redirectTo
:
redirectTo
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -89,9 +67,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -89,9 +67,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -100,7 +75,9 @@ function initBaseInstance(instance, options) {
...
@@ -100,7 +75,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -111,15 +88,8 @@ function initBaseInstance(instance, options) {
...
@@ -111,15 +88,8 @@ function initBaseInstance(instance, options) {
}
}
});
});
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -216,7 +186,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -216,7 +186,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -247,6 +217,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
if
(
!
vueIds
)
{
return
;
return
;
...
@@ -261,6 +251,16 @@ function initVueIds(vueIds, mpInstance) {
...
@@ -261,6 +251,16 @@ function initVueIds(vueIds, mpInstance) {
mpInstance
.
_$vuePid
=
ids
[
1
];
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
)
{
function
findVmByVueId
(
instance
,
vuePid
)
{
// TODO vue3 中 没有 $children
// TODO vue3 中 没有 $children
const
$children
=
instance
.
$children
;
const
$children
=
instance
.
$children
;
...
@@ -971,11 +971,15 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
...
@@ -971,11 +971,15 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
function
createPage
(
vueOptions
)
{
function
createPage
(
vueOptions
)
{
vueOptions
=
vueOptions
.
default
||
vueOptions
;
vueOptions
=
vueOptions
.
default
||
vueOptions
;
const
pageOptions
=
{
const
pageOptions
=
{
onLoad
(
args
)
{
onLoad
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
// 初始化 vue 实例
// 初始化 vue 实例
this
.
$vm
=
createVueComponent
(
'
page
'
,
this
,
vueOptions
);
this
.
$vm
=
createVueComponent
(
'
page
'
,
this
,
vueOptions
);
initSpecialMethods
(
this
);
initSpecialMethods
(
this
);
this
.
$vm
.
$callHook
(
'
onLoad
'
,
args
);
this
.
$vm
.
$callHook
(
'
onLoad
'
,
query
);
},
},
onReady
()
{
onReady
()
{
initChildVues
(
this
);
initChildVues
(
this
);
...
@@ -1003,6 +1007,7 @@ function createPage(vueOptions) {
...
@@ -1003,6 +1007,7 @@ function createPage(vueOptions) {
}
}
initHooks
(
pageOptions
,
PAGE_HOOKS
);
initHooks
(
pageOptions
,
PAGE_HOOKS
);
initUnknownHooks
(
pageOptions
,
vueOptions
);
initUnknownHooks
(
pageOptions
,
vueOptions
);
initWxsCallMethods
(
pageOptions
,
vueOptions
.
wxsCallMethods
);
return
Page
(
pageOptions
);
return
Page
(
pageOptions
);
}
}
...
@@ -1099,6 +1104,7 @@ function createComponent(vueOptions) {
...
@@ -1099,6 +1104,7 @@ function createComponent(vueOptions) {
else
{
else
{
mpComponentOptions
.
didUpdate
=
createObserver
(
true
);
mpComponentOptions
.
didUpdate
=
createObserver
(
true
);
}
}
initWxsCallMethods
(
mpComponentOptions
.
methods
,
vueOptions
.
wxsCallMethods
);
return
Component
(
mpComponentOptions
);
return
Component
(
mpComponentOptions
);
}
}
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
7325d4b3
...
@@ -1897,6 +1897,11 @@ function parsePage (vuePageOptions) {
...
@@ -1897,6 +1897,11 @@ function parsePage (vuePageOptions) {
initRelation
initRelation
});
});
const
onInit
=
(
vuePageOptions
.
default
||
vuePageOptions
).
onInit
;
if
(
onInit
)
{
pageOptions
.
methods
.
onInit
=
onInit
;
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
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
({
const
getProvider
=
initGetProvider
({
oauth
:
[
'
baidu
'
],
oauth
:
[
'
baidu
'
],
...
@@ -565,9 +614,11 @@ var protocols = /*#__PURE__*/Object.freeze({
...
@@ -565,9 +614,11 @@ var protocols = /*#__PURE__*/Object.freeze({
navigateBackMiniProgram
:
navigateBackMiniProgram
,
navigateBackMiniProgram
:
navigateBackMiniProgram
,
showShareMenu
:
showShareMenu
,
showShareMenu
:
showShareMenu
,
getAccountInfoSync
:
getAccountInfoSync
,
getAccountInfoSync
:
getAccountInfoSync
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
});
}
}
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
return
Behavior
(
options
);
}
}
...
@@ -810,6 +800,13 @@ function parsePage(vueOptions, parseOptions) {
...
@@ -810,6 +800,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
initLifetimes
});
});
const
methods
=
miniProgramPageOptions
.
methods
;
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
);
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
@@ -929,7 +926,7 @@ function handleLink(event) {
...
@@ -929,7 +926,7 @@ function handleLink(event) {
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
function
isPage
(
mpInstance
)
{
function
isPage
(
mpInstance
)
{
return
!
mpInstance
.
ownerId
;
return
!
hasOwn
(
mpInstance
,
'
ownerId
'
)
;
}
}
function
initRelation
(
mpInstance
,
detail
)
{
function
initRelation
(
mpInstance
,
detail
)
{
mpInstance
.
dispatch
(
'
__l
'
,
detail
);
mpInstance
.
dispatch
(
'
__l
'
,
detail
);
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
7325d4b3
...
@@ -1317,7 +1317,9 @@ const hooks = [
...
@@ -1317,7 +1317,9 @@ const hooks = [
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
'
onError
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
];
];
function
parseBaseApp
(
vm
,
{
function
parseBaseApp
(
vm
,
{
...
@@ -1393,17 +1395,19 @@ function parseBaseApp (vm, {
...
@@ -1393,17 +1395,19 @@ function parseBaseApp (vm, {
return
appOptions
return
appOptions
}
}
/* 快手也使用__wxExparserNodeId__和__wxWebviewId__ */
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
function
findVmByVueId
(
vm
,
vuePid
)
{
function
findVmByVueId
(
vm
,
vuePid
)
{
const
$children
=
vm
.
$children
;
const
$children
=
vm
.
$children
;
// 优先查找直属
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
let
parentVm
=
$children
.
find
(
childVm
=>
childVm
.
$scope
.
_$vueId
===
vuePid
);
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
parentVm
)
{
const
childVm
=
$children
[
i
];
return
parentVm
if
(
childVm
.
$scope
.
_$vueId
===
vuePid
)
{
return
childVm
}
}
}
// 反向递归查找
// 反向递归查找
let
parentVm
;
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
parentVm
=
findVmByVueId
(
$children
[
i
],
vuePid
);
parentVm
=
findVmByVueId
(
$children
[
i
],
vuePid
);
if
(
parentVm
)
{
if
(
parentVm
)
{
...
@@ -1473,6 +1477,10 @@ function parseApp (vm) {
...
@@ -1473,6 +1477,10 @@ function parseApp (vm) {
})
})
}
}
function
parseApp$1
(
vm
)
{
return
parseApp
(
vm
)
}
function
createApp
(
vm
)
{
function
createApp
(
vm
)
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
__eventChannel__
)
{
if
(
!
this
.
__eventChannel__
)
{
...
@@ -1488,10 +1496,53 @@ function createApp (vm) {
...
@@ -1488,10 +1496,53 @@ function createApp (vm) {
}
}
return
callHook
.
call
(
this
,
hook
,
args
)
return
callHook
.
call
(
this
,
hook
,
args
)
};
};
App
(
parseApp
(
vm
));
App
(
parseApp
$1
(
vm
));
return
vm
return
vm
}
}
const
encodeReserveRE
=
/
[
!'()*
]
/g
;
const
encodeReserveReplacer
=
c
=>
'
%
'
+
c
.
charCodeAt
(
0
).
toString
(
16
);
const
commaRE
=
/%2C/g
;
// fixed encodeURIComponent which is more conformant to RFC3986:
// - escapes [!'()*]
// - preserve commas
const
encode
=
str
=>
encodeURIComponent
(
str
)
.
replace
(
encodeReserveRE
,
encodeReserveReplacer
)
.
replace
(
commaRE
,
'
,
'
);
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
).
map
(
key
=>
{
const
val
=
obj
[
key
];
if
(
val
===
undefined
)
{
return
''
}
if
(
val
===
null
)
{
return
encodeStr
(
key
)
}
if
(
Array
.
isArray
(
val
))
{
const
result
=
[];
val
.
forEach
(
val2
=>
{
if
(
val2
===
undefined
)
{
return
}
if
(
val2
===
null
)
{
result
.
push
(
encodeStr
(
key
));
}
else
{
result
.
push
(
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val2
));
}
});
return
result
.
join
(
'
&
'
)
}
return
encodeStr
(
key
)
+
'
=
'
+
encodeStr
(
val
)
}).
filter
(
x
=>
x
.
length
>
0
).
join
(
'
&
'
)
:
null
;
return
res
?
`?
${
res
}
`
:
''
}
function
parseBaseComponent
(
vueComponentOptions
,
{
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
isPage
,
initRelation
initRelation
...
@@ -1500,7 +1551,8 @@ function parseBaseComponent (vueComponentOptions, {
...
@@ -1500,7 +1551,8 @@ function parseBaseComponent (vueComponentOptions, {
const
options
=
{
const
options
=
{
multipleSlots
:
true
,
multipleSlots
:
true
,
addGlobalClass
:
true
addGlobalClass
:
true
,
...(
vueOptions
.
options
||
{})
};
};
const
componentOptions
=
{
const
componentOptions
=
{
...
@@ -1545,7 +1597,7 @@ function parseBaseComponent (vueComponentOptions, {
...
@@ -1545,7 +1597,7 @@ function parseBaseComponent (vueComponentOptions, {
}
}
},
},
detached
()
{
detached
()
{
this
.
$vm
.
$destroy
();
this
.
$vm
&&
this
.
$vm
.
$destroy
();
}
}
},
},
pageLifetimes
:
{
pageLifetimes
:
{
...
@@ -1564,6 +1616,10 @@ function parseBaseComponent (vueComponentOptions, {
...
@@ -1564,6 +1616,10 @@ function parseBaseComponent (vueComponentOptions, {
__e
:
handleEvent
__e
:
handleEvent
}
}
};
};
// externalClasses
if
(
vueOptions
.
externalClasses
)
{
componentOptions
.
externalClasses
=
vueOptions
.
externalClasses
;
}
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
...
@@ -1586,6 +1642,10 @@ function parseComponent (vueComponentOptions) {
...
@@ -1586,6 +1642,10 @@ function parseComponent (vueComponentOptions) {
})
})
}
}
function
parseComponent$1
(
vueComponentOptions
)
{
return
parseComponent
(
vueComponentOptions
)
}
const
hooks$1
=
[
const
hooks$1
=
[
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
...
@@ -1598,13 +1658,19 @@ function parseBasePage (vuePageOptions, {
...
@@ -1598,13 +1658,19 @@ function parseBasePage (vuePageOptions, {
isPage
,
isPage
,
initRelation
initRelation
})
{
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
);
const
pageOptions
=
parseComponent
$1
(
vuePageOptions
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
options
=
query
;
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
const
copyQuery
=
Object
.
assign
({},
query
);
delete
copyQuery
.
__id__
;
this
.
$page
=
{
fullPath
:
'
/
'
+
(
this
.
route
||
this
.
is
)
+
stringifyQuery
(
copyQuery
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
};
return
pageOptions
return
pageOptions
...
@@ -1617,15 +1683,19 @@ function parsePage (vuePageOptions) {
...
@@ -1617,15 +1683,19 @@ function parsePage (vuePageOptions) {
})
})
}
}
function
parsePage$1
(
vuePageOptions
)
{
return
parsePage
(
vuePageOptions
)
}
function
createPage
(
vuePageOptions
)
{
function
createPage
(
vuePageOptions
)
{
{
{
return
Component
(
parsePage
(
vuePageOptions
))
return
Component
(
parsePage
$1
(
vuePageOptions
))
}
}
}
}
function
createComponent
(
vueOptions
)
{
function
createComponent
(
vueOptions
)
{
{
{
return
Component
(
parseComponent
(
vueOptions
))
return
Component
(
parseComponent
$1
(
vueOptions
))
}
}
}
}
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
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
({
const
getProvider
=
initGetProvider
({
oauth
:
[
'
qq
'
],
oauth
:
[
'
qq
'
],
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
});
}
}
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
return
Behavior
(
options
);
}
}
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
initLifetimes
});
});
const
methods
=
miniProgramPageOptions
.
methods
;
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
);
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -435,6 +471,19 @@ const previewImage = {
...
@@ -435,6 +471,19 @@ const previewImage = {
loop
:
false
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
({
const
getProvider
=
initGetProvider
({
...
@@ -536,7 +585,9 @@ var protocols = /*#__PURE__*/Object.freeze({
...
@@ -536,7 +585,9 @@ var protocols = /*#__PURE__*/Object.freeze({
getUserInfo
:
getUserInfo
,
getUserInfo
:
getUserInfo
,
requestPayment
:
requestPayment
,
requestPayment
:
requestPayment
,
getFileInfo
:
getFileInfo
,
getFileInfo
:
getFileInfo
,
previewImage
:
previewImage
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
});
}
}
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -210,7 +180,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -210,7 +180,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -241,6 +211,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
return
Behavior
(
options
);
}
}
...
@@ -800,6 +790,13 @@ function parsePage(vueOptions, parseOptions) {
...
@@ -800,6 +790,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
initLifetimes
});
});
const
methods
=
miniProgramPageOptions
.
methods
;
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
);
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
7325d4b3
此差异已折叠。
点击以展开。
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
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
({
const
getProvider
=
initGetProvider
({
oauth
:
[
'
weixin
'
],
oauth
:
[
'
weixin
'
],
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
...
@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
});
}
}
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
return
Behavior
(
options
);
}
}
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
...
@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
initLifetimes
});
});
const
methods
=
miniProgramPageOptions
.
methods
;
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
);
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
7325d4b3
import
{
isArray
,
isPromise
,
isFunction
,
isPlainObject
,
hasOwn
,
isString
}
from
'
@vue/shared
'
;
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
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
isIOS
=
false
;
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
...
@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR
=
pixelRatio
;
deviceDPR
=
pixelRatio
;
isIOS
=
platform
===
'
ios
'
;
isIOS
=
platform
===
'
ios
'
;
}
}
function
upx2px
(
number
,
newDeviceWidth
)
{
const
upx2px
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
upx2px
'
},
(
number
,
newDeviceWidth
)
=>
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
();
checkDeviceWidth
();
}
}
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
...
@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
}
}
return
number
<
0
?
-
result
:
result
;
return
number
<
0
?
-
result
:
result
;
}
}
,
Upx2pxProtocol
);
var
HOOKS
;
var
HOOKS
;
(
function
(
HOOKS
)
{
(
function
(
HOOKS
)
{
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
...
@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return
api
(
options
,
...
params
);
return
api
(
options
,
...
params
);
}
}
const
AddInterceptorProtocol
=
[
{
name
:
'
method
'
,
type
:
[
String
,
Object
],
required
:
true
}
];
const
RemoveInterceptorProtocol
=
AddInterceptorProtocol
;
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
function
mergeInterceptorHook
(
interceptors
,
interceptor
)
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
Object
.
keys
(
interceptor
).
forEach
(
hook
=>
{
if
(
isFunction
(
interceptor
[
hook
]))
{
if
(
isFunction
(
interceptor
[
hook
]))
{
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
...
@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks
.
splice
(
index
,
1
);
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
))
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
interceptor
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
interceptor
);
}
}
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
}
}
,
AddInterceptorProtocol
);
function
removeInterceptor
(
method
,
interceptor
)
{
const
removeInterceptor
=
createApi
({
type
:
API_TYPE_SYNC
,
name
:
'
removeInterceptor
'
},
(
method
,
interceptor
)
=>
{
if
(
typeof
method
===
'
string
'
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
interceptor
))
{
if
(
isPlainObject
(
interceptor
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
removeInterceptorHook
(
scopedInterceptors
[
method
],
interceptor
);
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
...
@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else
if
(
isPlainObject
(
method
))
{
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
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
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$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
...
@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const
getSystemInfo
=
{
const
getSystemInfo
=
{
returnValue
:
addSafeAreaInsets
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
=
{
const
providers
=
{
oauth
:
[],
oauth
:
[],
...
@@ -473,9 +522,11 @@ var shims = /*#__PURE__*/Object.freeze({
...
@@ -473,9 +522,11 @@ var shims = /*#__PURE__*/Object.freeze({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
var
protocols
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
redirectTo
:
redirectTo
,
previewImage
:
previewImage
,
previewImage
:
previewImage
,
getSystemInfo
:
getSystemInfo
,
getSystemInfo
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfoSync
getSystemInfoSync
:
getSystemInfoSync
,
createCanvasContext
:
createCanvasContext
});
});
var
index
=
initUni
(
shims
,
protocols
);
var
index
=
initUni
(
shims
,
protocols
);
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
7325d4b3
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
...
@@ -52,28 +52,6 @@ const MP_METHODS = [
'
selectAllComponents
'
,
'
selectAllComponents
'
,
'
selectComponent
'
'
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
)
{
function
createEmitFn
(
oldEmit
,
ctx
)
{
return
function
emit
(
event
,
...
args
)
{
return
function
emit
(
event
,
...
args
)
{
if
(
ctx
.
$scope
&&
event
)
{
if
(
ctx
.
$scope
&&
event
)
{
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
...
@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
return
oldEmit
.
apply
(
this
,
[
event
,
...
args
]);
};
};
}
}
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
initBaseInstance
(
instance
,
options
)
{
function
initBaseInstance
(
instance
,
options
)
{
const
ctx
=
instance
.
ctx
;
const
ctx
=
instance
.
ctx
;
// mp
// mp
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
...
@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx
.
$scope
=
options
.
mpInstance
;
ctx
.
$scope
=
options
.
mpInstance
;
// TODO @deprecated
// TODO @deprecated
ctx
.
$mp
=
{};
ctx
.
$mp
=
{};
ctx
.
_self
=
{};
if
(
__VUE_OPTIONS_API__
)
{
ctx
.
_self
=
{};
}
// $vm
// $vm
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
ctx
.
$scope
.
$vm
=
instance
.
proxy
;
// slots
// slots
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
...
@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
});
}
}
}
}
if
(
__VUE_OPTIONS_API__
)
{
// $set
ctx
.
$set
=
set
;
}
// $emit
// $emit
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
instance
.
emit
=
createEmitFn
(
instance
.
emit
,
ctx
);
// $callHook
ctx
.
$hasHook
=
hasHook
;
ctx
.
$callHook
=
callHook
;
}
}
function
initComponentInstance
(
instance
,
options
)
{
function
initComponentInstance
(
instance
,
options
)
{
initBaseInstance
(
instance
,
options
);
initBaseInstance
(
instance
,
options
);
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
...
@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm
:
instance
,
$vm
:
instance
,
onLaunch
(
options
)
{
onLaunch
(
options
)
{
const
ctx
=
internalInstance
.
ctx
;
const
ctx
=
internalInstance
.
ctx
;
if
(
this
.
$vm
&&
ctx
.
$
callHook
)
{
if
(
this
.
$vm
&&
ctx
.
$
scope
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
;
return
;
}
}
...
@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
...
@@ -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
)
{
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
return
Behavior
(
options
);
}
}
...
@@ -772,6 +762,13 @@ function parsePage(vueOptions, parseOptions) {
...
@@ -772,6 +762,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
initLifetimes
});
});
const
methods
=
miniProgramPageOptions
.
methods
;
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
);
initHooks
(
methods
,
PAGE_HOOKS
);
initUnknownHooks
(
methods
,
vueOptions
);
initUnknownHooks
(
methods
,
vueOptions
);
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
parse
&&
parse
(
miniProgramPageOptions
,
{
handleLink
});
...
@@ -969,7 +966,7 @@ function initLifetimes$1(lifetimesOptions) {
...
@@ -969,7 +966,7 @@ function initLifetimes$1(lifetimesOptions) {
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
const
mocks
=
[
'
nodeId
'
,
'
componentName
'
,
'
_componentId
'
,
'
uniquePrefix
'
];
function
isPage
(
mpInstance
)
{
function
isPage
(
mpInstance
)
{
return
!
mpInstance
.
ownerId
;
return
!
hasOwn
(
mpInstance
,
'
ownerId
'
)
;
}
}
function
initRelation
(
mpInstance
)
{
function
initRelation
(
mpInstance
)
{
...
...
packages/vue-cli-plugin-uni/generator.js
浏览文件 @
7325d4b3
...
@@ -58,7 +58,7 @@ module.exports = (api, options, rootOptions) => {
...
@@ -58,7 +58,7 @@ module.exports = (api, options, rootOptions) => {
'
@dcloudio/uni-quickapp-native
'
:
version
,
'
@dcloudio/uni-quickapp-native
'
:
version
,
'
@dcloudio/uni-quickapp-webview
'
:
version
,
'
@dcloudio/uni-quickapp-webview
'
:
version
,
'
@dcloudio/uni-stat
'
:
version
,
'
@dcloudio/uni-stat
'
:
version
,
'
@vue/shared
'
:
'
^3.0.0
-rc.4
'
,
// TODO
'
@vue/shared
'
:
'
^3.0.0
'
,
flyio
:
'
^0.6.2
'
,
flyio
:
'
^0.6.2
'
,
vuex
:
'
^3.2.0
'
vuex
:
'
^3.2.0
'
},
},
...
...
src/platforms/mp-baidu/runtime/wrapper/page-parser.js
浏览文件 @
7325d4b3
...
@@ -29,6 +29,11 @@ export default function parsePage (vuePageOptions) {
...
@@ -29,6 +29,11 @@ export default function parsePage (vuePageOptions) {
initRelation
initRelation
})
})
const
onInit
=
(
vuePageOptions
.
default
||
vuePageOptions
).
onInit
if
(
onInit
)
{
pageOptions
.
methods
.
onInit
=
onInit
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
pageOptions
.
methods
.
onShow
=
function
onShow
()
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
if
(
this
.
$vm
&&
this
.
$vm
.
$mp
.
query
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录