Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
eb5c684c
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
eb5c684c
编写于
8月 19, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(runtime): add exists for redirectTo
上级
cf87a142
变更
33
展开全部
显示空白变更内容
内联
并排
Showing
33 changed file
with
1019 addition
and
339 deletion
+1019
-339
build/rollup.config.mp.js
build/rollup.config.mp.js
+4
-1
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+62
-10
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+150
-148
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+2
-2
packages/uni-h5/dist/index.css
packages/uni-h5/dist/index.css
+1
-1
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/manifest.json
packages/uni-h5/manifest.json
+4
-16
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+125
-38
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+96
-11
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+96
-11
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+96
-11
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+95
-10
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+96
-11
src/core/helpers/index.js
src/core/helpers/index.js
+12
-0
src/core/runtime/wrapper.js
src/core/runtime/wrapper.js
+13
-6
src/core/service/api/device/theme.js
src/core/service/api/device/theme.js
+1
-1
src/core/service/plugins/page/create-page.js
src/core/service/plugins/page/create-page.js
+1
-0
src/core/view/components/navigator/index.vue
src/core/view/components/navigator/index.vue
+18
-12
src/platforms/app-plus/service/api/route/redirect-to.js
src/platforms/app-plus/service/api/route/redirect-to.js
+32
-4
src/platforms/app-plus/service/framework/page.js
src/platforms/app-plus/service/framework/page.js
+2
-1
src/platforms/h5/service/api/route/route.js
src/platforms/h5/service/api/route/route.js
+14
-1
src/platforms/mp-alipay/runtime/api/protocols.js
src/platforms/mp-alipay/runtime/api/protocols.js
+16
-13
src/platforms/mp-alipay/runtime/wrapper/page-parser.js
src/platforms/mp-alipay/runtime/wrapper/page-parser.js
+28
-19
src/platforms/mp-baidu/runtime/api/protocols.js
src/platforms/mp-baidu/runtime/api/protocols.js
+3
-1
src/platforms/mp-kuaishou/runtime/api/protocols.js
src/platforms/mp-kuaishou/runtime/api/protocols.js
+3
-1
src/platforms/mp-qq/runtime/api/protocols.js
src/platforms/mp-qq/runtime/api/protocols.js
+3
-1
src/platforms/mp-toutiao/runtime/api/protocols.js
src/platforms/mp-toutiao/runtime/api/protocols.js
+3
-1
src/platforms/mp-weixin/helpers/redirect-to.js
src/platforms/mp-weixin/helpers/redirect-to.js
+23
-0
src/platforms/mp-weixin/runtime/api/protocols.js
src/platforms/mp-weixin/runtime/api/protocols.js
+3
-1
src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js
src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js
+11
-3
src/platforms/quickapp-webview/runtime/api/protocols.js
src/platforms/quickapp-webview/runtime/api/protocols.js
+3
-1
未找到文件。
build/rollup.config.mp.js
浏览文件 @
eb5c684c
...
...
@@ -56,6 +56,9 @@ module.exports = {
plugins
:
[
alias
({
entries
:
[{
find
:
'
uni-shared/query
'
,
replacement
:
path
.
resolve
(
__dirname
,
'
../src/shared/query.js
'
)
},
{
find
:
'
uni-shared
'
,
replacement
:
path
.
resolve
(
__dirname
,
'
../src/shared/util.js
'
)
},
{
...
...
packages/uni-app-plus/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -431,7 +431,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
wx
[
options
.
name
||
methodName
].
apply
(
wx
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
wx
[
methodName
].
apply
(
wx
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1147,10 +1152,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1346,6 +1351,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1470,9 +1518,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$2
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
eb5c684c
...
...
@@ -131,6 +131,7 @@ var serviceContext = (function () {
'
checkIsSupportSoterAuthentication
'
,
'
checkIsSoterEnrolledInDevice
'
,
'
startSoterAuthentication
'
,
'
onThemeChange
'
,
'
onUIStyleChange
'
];
...
...
@@ -3573,85 +3574,6 @@ var serviceContext = (function () {
return
data
}
const
DEVICE_FREQUENCY
=
200
;
const
NETWORK_TYPES
=
[
'
unknown
'
,
'
none
'
,
'
ethernet
'
,
'
wifi
'
,
'
2g
'
,
'
3g
'
,
'
4g
'
];
const
MAP_ID
=
'
__UNIAPP_MAP
'
;
const
TEMP_PATH_BASE
=
'
_doc/uniapp_temp
'
;
const
TEMP_PATH
=
`
${
TEMP_PATH_BASE
}
_
${
Date
.
now
()}
`
;
/**
* 5+错误对象转换为错误消息
* @param {*} error 5+错误对象
*/
function
toErrMsg
(
error
)
{
var
msg
=
'
base64ToTempFilePath:fail
'
;
if
(
error
&&
error
.
message
)
{
msg
+=
`
${
error
.
message
}
`
;
}
else
if
(
error
)
{
msg
+=
`
${
error
}
`
;
}
return
msg
}
function
base64ToTempFilePath
({
base64Data
,
x
,
y
,
width
,
height
,
destWidth
,
destHeight
,
canvasId
,
fileType
,
quality
}
=
{},
callbackId
)
{
var
id
=
Date
.
now
();
var
bitmap
=
new
plus
.
nativeObj
.
Bitmap
(
`bitmap
${
id
}
`
);
bitmap
.
loadBase64Data
(
base64Data
,
function
()
{
var
formats
=
[
'
jpg
'
,
'
png
'
];
var
format
=
String
(
fileType
).
toLowerCase
();
if
(
formats
.
indexOf
(
format
)
<
0
)
{
format
=
'
png
'
;
}
/**
* 保存配置
*/
var
saveOption
=
{
overwrite
:
true
,
quality
:
typeof
quality
===
'
number
'
?
quality
*
100
:
100
,
format
};
/**
* 保存文件路径
*/
var
tempFilePath
=
`
${
TEMP_PATH
}
/canvas/
${
id
}
.
${
format
}
`
;
bitmap
.
save
(
tempFilePath
,
saveOption
,
function
()
{
clear
();
invoke$1
(
callbackId
,
{
tempFilePath
,
errMsg
:
'
base64ToTempFilePath:ok
'
});
},
function
(
error
)
{
clear
();
invoke$1
(
callbackId
,
{
errMsg
:
toErrMsg
(
error
)
});
});
},
function
(
error
)
{
clear
();
invoke$1
(
callbackId
,
{
errMsg
:
toErrMsg
(
error
)
});
});
function
clear
()
{
bitmap
.
clear
();
}
}
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
const
pageId
=
pageVm
.
$page
.
id
;
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-map-
'
+
mapId
,
{
...
...
@@ -3934,6 +3856,14 @@ var serviceContext = (function () {
return
createLivePusherContext
(
id
,
vm
)
}
const
DEVICE_FREQUENCY
=
200
;
const
NETWORK_TYPES
=
[
'
unknown
'
,
'
none
'
,
'
ethernet
'
,
'
wifi
'
,
'
2g
'
,
'
3g
'
,
'
4g
'
];
const
MAP_ID
=
'
__UNIAPP_MAP
'
;
const
TEMP_PATH_BASE
=
'
_doc/uniapp_temp
'
;
const
TEMP_PATH
=
`
${
TEMP_PATH_BASE
}
_
${
Date
.
now
()}
`
;
let
watchAccelerationId
=
false
;
let
isWatchAcceleration
=
false
;
...
...
@@ -6579,7 +6509,7 @@ var serviceContext = (function () {
};
const
cookiesPrase
=
header
=>
{
let
cookiesStr
=
header
[
'
Set-Cookie
'
];
let
cookiesStr
=
header
[
'
Set-Cookie
'
]
||
header
[
'
set-cookie
'
]
;
let
cookiesArr
=
[];
if
(
!
cookiesStr
)
{
return
[]
...
...
@@ -8755,6 +8685,7 @@ var serviceContext = (function () {
meta
:
routeOptions
.
meta
,
path
,
route
,
fullPath
:
url
,
openType
},
$remove
()
{
...
...
@@ -8923,13 +8854,47 @@ var serviceContext = (function () {
});
}
function
hasLifecycleHook
(
vueOptions
=
{},
hook
)
{
return
Array
.
isArray
(
vueOptions
[
hook
])
&&
vueOptions
[
hook
].
length
}
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
function
_redirectTo
({
url
,
path
,
query
query
,
exists
},
callbackId
)
{
const
pages
=
getCurrentPages
();
const
lastPage
=
pages
[
pages
.
length
-
1
];
const
len
=
pages
.
length
-
1
;
if
(
exists
===
'
back
'
)
{
const
existsPageIndex
=
findExistsPageIndex
(
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
len
-
existsPageIndex
;
if
(
delta
>
0
)
{
navigateBack$1
({
delta
});
invoke$1
(
callbackId
,
{
errMsg
:
'
redirectTo:ok
'
});
return
}
}
}
const
lastPage
=
pages
[
len
];
lastPage
&&
lastPage
.
$remove
();
...
...
@@ -8959,7 +8924,8 @@ var serviceContext = (function () {
setStatusBarStyle
();
}
function
redirectTo$1
({
url
url
,
exists
},
callbackId
)
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
...
...
@@ -8968,7 +8934,8 @@ var serviceContext = (function () {
_redirectTo
({
url
,
path
,
query
query
,
exists
},
callbackId
);
});
}
...
...
@@ -9840,6 +9807,7 @@ var serviceContext = (function () {
};
});
this
.
_preload
=
options
.
preload
!==
undefined
?
options
.
preload
:
true
;
this
.
_isLoad
=
false
;
this
.
_adError
=
''
;
this
.
_loadPromiseResolve
=
null
;
...
...
@@ -9849,8 +9817,8 @@ var serviceContext = (function () {
const
rewardAd
=
this
.
_rewardAd
=
plus
.
ad
.
createRewardedVideoAd
(
options
);
rewardAd
.
onLoad
((
e
)
=>
{
this
.
_isLoad
=
true
;
this
.
_dispatchEvent
(
'
load
'
,
{});
this
.
_lastLoadTime
=
Date
.
now
();
this
.
_dispatchEvent
(
'
load
'
,
{});
if
(
this
.
_loadPromiseResolve
!=
null
)
{
this
.
_loadPromiseResolve
();
...
...
@@ -9858,7 +9826,9 @@ var serviceContext = (function () {
}
});
rewardAd
.
onClose
((
e
)
=>
{
if
(
this
.
_preload
)
{
this
.
_loadAd
();
}
this
.
_dispatchEvent
(
'
close
'
,
{
isEnded
:
e
.
isEnded
});
});
rewardAd
.
onVerify
&&
rewardAd
.
onVerify
((
e
)
=>
{
...
...
@@ -9878,11 +9848,14 @@ var serviceContext = (function () {
this
.
_loadPromiseReject
=
null
;
}
});
if
(
this
.
_preload
)
{
this
.
_loadAd
();
}
}
get
isExpired
()
{
return
(
Math
.
abs
(
Date
.
now
()
-
this
.
_lastLoadTime
)
>
EXPIRED_TIME
)
return
(
this
.
_lastLoadTime
!==
0
&&
(
Math
.
abs
(
Date
.
now
()
-
this
.
_lastLoadTime
)
>
EXPIRED_TIME
)
)
}
load
()
{
...
...
@@ -9961,7 +9934,6 @@ var serviceContext = (function () {
setBackgroundAudioState
:
setBackgroundAudioState
,
operateBackgroundAudio
:
operateBackgroundAudio
,
getBackgroundAudioState
:
getBackgroundAudioState
,
base64ToTempFilePath
:
base64ToTempFilePath
,
operateMapPlayer
:
operateMapPlayer$2
,
operateVideoPlayer
:
operateVideoPlayer$2
,
createLivePusherContext
:
createLivePusherContext$1
,
...
...
@@ -11145,37 +11117,20 @@ var serviceContext = (function () {
});
return
}
const
cId
=
canvasEventCallbacks
.
push
(
function
({
base64
})
{
if
(
!
base64
||
!
base64
.
length
)
{
invoke$1
(
callbackId
,
{
errMsg
:
'
canvasToTempFilePath:fail
'
});
}
invokeMethod
(
'
base64ToTempFilePath
'
,
{
base64Data
:
base64
,
x
,
y
,
width
,
height
,
destWidth
,
destHeight
,
canvasId
,
fileType
,
qualit
},
callbackId
);
const
cId
=
canvasEventCallbacks
.
push
(
function
(
res
)
{
invoke$1
(
callbackId
,
res
);
});
operateCanvas
(
canvasId
,
pageId
,
'
getDataUrl
'
,
{
const
dirname
=
`
${
TEMP_PATH
}
/canvas`
;
operateCanvas
(
canvasId
,
pageId
,
'
toTempFilePath
'
,
{
x
,
y
,
width
,
height
,
destWidth
,
destHeight
,
hidpi
:
false
,
fileType
,
qualit
,
dirname
,
callbackId
:
cId
});
}
...
...
@@ -11210,7 +11165,9 @@ var serviceContext = (function () {
}
MapContext
.
prototype
.
$getAppMap
=
function
()
{
{
return
plus
.
maps
.
getMapById
(
this
.
pageVm
.
$page
.
id
+
'
-map-
'
+
this
.
id
)
}
};
methods
.
forEach
(
function
(
method
)
{
...
...
@@ -11681,6 +11638,17 @@ var serviceContext = (function () {
const
callbacks$9
=
[];
onMethod
(
'
onThemeChange
'
,
function
(
res
)
{
callbacks$9
.
forEach
(
callbackId
=>
{
invoke$1
(
callbackId
,
res
);
});
});
function
onThemeChange
(
callbackId
)
{
callbacks$9
.
push
(
callbackId
);
}
// 旧版本 API,后期文档更新后考虑移除
onMethod
(
'
onUIStyleChange
'
,
function
(
res
)
{
callbacks$9
.
forEach
(
callbackId
=>
{
invoke$1
(
callbackId
,
res
);
...
...
@@ -11689,10 +11657,12 @@ var serviceContext = (function () {
function
onUIStyleChange
(
callbackId
)
{
callbacks$9
.
push
(
callbackId
);
console
.
log
(
'
API uni.onUIStyleChange 已过时,请使用 uni.onThemeChange,详情:https://uniapp.dcloud.net.cn/api/system/theme
'
);
}
var
require_context_module_1_15
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
onThemeChange
:
onThemeChange
,
onUIStyleChange
:
onUIStyleChange
});
...
...
@@ -12955,7 +12925,14 @@ var serviceContext = (function () {
}
function
onAppEnterForeground
()
{
callAppHook
(
getApp
(),
'
onShow
'
);
const
pages
=
getCurrentPages
();
const
page
=
pages
[
pages
.
length
-
1
];
const
args
=
{
path
:
page
.
route
,
query
:
page
.
options
};
callAppHook
(
getApp
(),
'
onShow
'
,
args
);
callCurrentPageHook
(
'
onShow
'
);
}
...
...
@@ -13275,6 +13252,14 @@ var serviceContext = (function () {
});
globalEvent
.
addEventListener
(
'
uistylechange
'
,
function
(
event
)
{
const
args
=
{
theme
:
event
.
uistyle
};
callAppHook
(
appCtx
,
'
onThemeChange
'
,
args
);
publish
(
'
onThemeChange
'
,
args
);
// 兼容旧版本 API
publish
(
'
onUIStyleChange
'
,
{
style
:
event
.
uistyle
});
...
...
@@ -13386,6 +13371,33 @@ var serviceContext = (function () {
}
}
function
clearTempFile
()
{
// 统一处理路径
function
getPath
(
path
)
{
path
=
path
.
replace
(
/
\/
$/
,
''
);
return
path
.
indexOf
(
'
_
'
)
===
0
?
plus
.
io
.
convertLocalFileSystemURL
(
path
)
:
path
}
var
basePath
=
getPath
(
TEMP_PATH_BASE
);
var
tempPath
=
getPath
(
TEMP_PATH
);
// 获取父目录
var
dirPath
=
tempPath
.
split
(
'
/
'
);
dirPath
.
pop
();
dirPath
=
dirPath
.
join
(
'
/
'
);
plus
.
io
.
resolveLocalFileSystemURL
(
plus
.
io
.
convertAbsoluteFileSystem
(
dirPath
),
entry
=>
{
var
reader
=
entry
.
createReader
();
reader
.
readEntries
(
function
(
entries
)
{
if
(
entries
&&
entries
.
length
)
{
entries
.
forEach
(
function
(
entry
)
{
if
(
entry
.
isDirectory
&&
entry
.
fullPath
.
indexOf
(
basePath
)
===
0
&&
entry
.
fullPath
.
indexOf
(
tempPath
)
!==
0
)
{
entry
.
removeRecursively
();
}
});
}
});
});
}
function
registerApp
(
appVm
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
[uni-app] registerApp
'
);
...
...
@@ -13415,6 +13427,9 @@ var serviceContext = (function () {
initAppLaunch
(
appVm
);
// 10s后清理临时文件
setTimeout
(
clearTempFile
,
10000
);
__uniConfig
.
ready
=
true
;
process
.
env
.
NODE_ENV
!==
'
production
'
&&
perf
(
'
registerApp
'
);
...
...
@@ -13422,6 +13437,11 @@ var serviceContext = (function () {
var
tags
=
[
'
uni-app
'
,
'
uni-layout
'
,
'
uni-content
'
,
'
uni-main
'
,
'
uni-left-window
'
,
'
uni-right-window
'
,
'
uni-tabbar
'
,
'
uni-page
'
,
'
uni-page-head
'
,
...
...
@@ -13477,20 +13497,17 @@ var serviceContext = (function () {
'
uni-web-view
'
];
function
hasLifecycleHook
(
vueOptions
=
{},
hook
)
{
return
Array
.
isArray
(
vueOptions
[
hook
])
&&
vueOptions
[
hook
].
length
}
// 使用白名单过滤(前期有一批自定义组件使用了 uni-)
function
initVue
(
Vue
)
{
Vue
.
config
.
errorHandler
=
function
(
err
,
vm
,
info
)
{
Vue
.
util
.
warn
(
`Error in
${
info
}
: "
${
err
.
toString
()}
"`
,
vm
);
const
errType
=
toRawType
(
err
);
Vue
.
util
.
warn
(
`Error in
${
info
}
: "
${
errType
===
'
Error
'
?
err
.
toString
()
:
err
}
"`
,
vm
);
const
app
=
typeof
getApp
===
'
function
'
&&
getApp
();
if
(
app
&&
hasLifecycleHook
(
app
.
$options
,
'
onError
'
))
{
app
.
__call_hook
(
'
onError
'
,
err
);
}
else
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
&&
errType
===
'
Error
'
)
{
console
.
error
(
`
${
err
.
message
}
${
err
.
stack
}
...
...
@@ -13615,11 +13632,9 @@ var serviceContext = (function () {
const
isAndroid
=
plus
.
os
.
name
.
toLowerCase
()
===
'
android
'
;
const
FOCUS_TIMEOUT
=
isAndroid
?
300
:
700
;
const
HIDE_TIMEOUT
=
isAndroid
?
800
:
300
;
let
keyboardHeight
=
0
;
let
onKeyboardShow
;
let
focusTimer
;
let
hideKeyboardTimeout
;
function
hookKeyboardEvent
(
event
,
callback
)
{
onKeyboardShow
=
null
;
...
...
@@ -13647,19 +13662,6 @@ var serviceContext = (function () {
keyboardHeight
=
res
.
height
;
if
(
keyboardHeight
>
0
)
{
onKeyboardShow
&&
onKeyboardShow
();
if
(
hideKeyboardTimeout
)
{
clearTimeout
(
hideKeyboardTimeout
);
hideKeyboardTimeout
=
null
;
}
}
else
{
// 安卓/iOS13收起键盘时通知view层失去焦点
if
(
isAndroid
||
parseInt
(
plus
.
os
.
version
)
>=
13
)
{
hideKeyboardTimeout
=
setTimeout
(
function
()
{
hideKeyboardTimeout
=
null
;
var
pageId
=
getCurrentPageId
();
UniServiceJSBridge
.
publishHandler
(
'
hideKeyboard
'
,
{},
pageId
);
},
HIDE_TIMEOUT
);
}
}
});
...
...
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
eb5c684c
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.css
浏览文件 @
eb5c684c
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
eb5c684c
此差异已折叠。
点击以展开。
packages/uni-h5/manifest.json
浏览文件 @
eb5c684c
...
...
@@ -451,6 +451,10 @@
"/core/service/api/device/bluetooth.js"
,
[]
],
"onThemeChange"
:
[
"/core/service/api/device/theme.js"
,
[]
],
"onUIStyleChange"
:
[
"/core/service/api/device/theme.js"
,
[]
...
...
@@ -780,10 +784,6 @@
"createCanvasContext"
:
[
"/core/service/api/context/canvas.js"
,
[
[
"/platforms/h5/service/api/context/canvas.js"
,
"base64ToTempFilePath"
],
[
"/core/helpers/protocol/context/context.js"
,
"createCanvasContext"
...
...
@@ -793,10 +793,6 @@
"canvasToTempFilePath"
:
[
"/core/service/api/context/canvas.js"
,
[
[
"/platforms/h5/service/api/context/canvas.js"
,
"base64ToTempFilePath"
],
[
"/core/helpers/protocol/context/canvas.js"
,
"canvasToTempFilePath"
...
...
@@ -806,10 +802,6 @@
"canvasPutImageData"
:
[
"/core/service/api/context/canvas.js"
,
[
[
"/platforms/h5/service/api/context/canvas.js"
,
"base64ToTempFilePath"
],
[
"/core/helpers/protocol/context/canvas.js"
,
"canvasPutImageData"
...
...
@@ -819,10 +811,6 @@
"canvasGetImageData"
:
[
"/core/service/api/context/canvas.js"
,
[
[
"/platforms/h5/service/api/context/canvas.js"
,
"base64ToTempFilePath"
],
[
"/core/helpers/protocol/context/canvas.js"
,
"canvasGetImageData"
...
...
packages/uni-mp-alipay/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
// 不支持的 API 列表
const
todos
=
[
'
preloadPage
'
,
...
...
@@ -434,6 +466,7 @@ function _handleSystemInfo (result) {
}
const
protocols
=
{
// 需要做转换的 API 列表
redirectTo
,
returnValue
(
methodName
,
res
=
{})
{
// 通用 returnValue 解析
if
(
res
.
error
||
res
.
errorMessage
)
{
res
.
errMsg
=
`
${
methodName
}
:fail
${
res
.
errorMessage
||
res
.
error
}
`
;
...
...
@@ -466,7 +499,8 @@ const protocols = { // 需要做转换的 API 列表
},
data
(
data
)
{
// 钉钉小程序在content-type为application/json时需上传字符串形式data,使用my.dd在真机运行钉钉小程序时不能正确判断
if
(
my
.
canIUse
(
'
saveFileToDingTalk
'
)
&&
method
.
toUpperCase
()
===
'
POST
'
&&
headers
[
'
content-type
'
].
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
data
))
{
if
(
my
.
canIUse
(
'
saveFileToDingTalk
'
)
&&
method
.
toUpperCase
()
===
'
POST
'
&&
headers
[
'
content-type
'
].
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
data
))
{
return
{
name
:
'
data
'
,
value
:
JSON
.
stringify
(
data
)
...
...
@@ -900,7 +934,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
my
[
options
.
name
||
methodName
].
apply
(
my
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
my
[
methodName
].
apply
(
my
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1626,10 +1665,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -2046,6 +2085,49 @@ function createApp (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
}
`
:
''
}
const
hooks$1
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -2064,7 +2146,7 @@ function parsePage (vuePageOptions) {
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
args
)
{
onLoad
(
query
)
{
const
properties
=
this
.
props
;
const
options
=
{
...
...
@@ -2081,8 +2163,13 @@ function parsePage (vuePageOptions) {
// 触发首次 setData
this
.
$vm
.
$mount
();
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
options
=
query
;
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
},
onReady
()
{
initChildVues
(
this
);
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
...
@@ -468,6 +500,7 @@ const protocols = {
method
:
false
}
},
redirectTo
,
previewImage
,
getRecorderManager
:
{
returnValue
(
fromRet
)
{
...
...
@@ -576,7 +609,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
swan
[
options
.
name
||
methodName
].
apply
(
swan
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
swan
[
methodName
].
apply
(
swan
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1289,10 +1327,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1484,6 +1522,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1637,9 +1718,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
...
@@ -391,6 +423,7 @@ var previewImage = {
};
const
protocols
=
{
redirectTo
,
previewImage
};
const
todos
=
[
...
...
@@ -537,7 +570,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
wx
[
options
.
name
||
methodName
].
apply
(
wx
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
wx
[
methodName
].
apply
(
wx
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1205,10 +1243,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1401,6 +1439,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1527,9 +1608,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
...
@@ -489,6 +521,7 @@ const protocols = {
sizeType
:
false
}
},
redirectTo
,
previewImage
,
connectSocket
:
{
args
:
{
...
...
@@ -629,7 +662,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
tt
[
options
.
name
||
methodName
].
apply
(
tt
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
tt
[
methodName
].
apply
(
tt
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1297,10 +1335,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1573,6 +1611,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1719,9 +1800,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
...
@@ -402,6 +434,7 @@ function addSafeAreaInsets (result) {
}
}
const
protocols
=
{
redirectTo
,
previewImage
,
getSystemInfo
:
{
returnValue
:
addSafeAreaInsets
...
...
@@ -489,7 +522,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
wx
[
options
.
name
||
methodName
].
apply
(
wx
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
wx
[
methodName
].
apply
(
wx
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1162,10 +1200,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1354,6 +1392,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1476,9 +1557,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
eb5c684c
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
eb5c684c
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
eb5c684c
...
...
@@ -356,6 +356,38 @@ var baseApi = /*#__PURE__*/Object.freeze({
interceptors
:
interceptors
});
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
();
let
len
=
pages
.
length
;
while
(
len
--
)
{
const
page
=
pages
[
len
];
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
var
redirectTo
=
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
);
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
;
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
;
}
}
}
}
};
var
previewImage
=
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
...
@@ -391,6 +423,7 @@ var previewImage = {
};
const
protocols
=
{
redirectTo
,
previewImage
};
const
todos
=
[
...
...
@@ -471,7 +504,12 @@ function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
);
}
const
returnValue
=
qa
[
options
.
name
||
methodName
].
apply
(
qa
,
args
);
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
);
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
;
}
const
returnValue
=
qa
[
methodName
].
apply
(
qa
,
args
);
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
@@ -1147,10 +1185,10 @@ function handleEvent (event) {
eventArray
[
2
],
isCustom
,
methodName
)
||
[]
;
);
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[])
.
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
}
});
}
...
...
@@ -1404,6 +1442,49 @@ function createApp (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
,
{
isPage
,
initRelation
...
...
@@ -1550,9 +1631,13 @@ function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks$1
,
vuePageOptions
);
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
);
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
;
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
};
this
.
$vm
.
$mp
.
query
=
query
;
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
);
};
return
pageOptions
...
...
src/core/helpers/index.js
浏览文件 @
eb5c684c
...
...
@@ -42,3 +42,15 @@ export function upx2px (str) {
}
return
parseInt
(
str
)
||
0
}
export
function
findExistsPageIndex
(
url
)
{
const
pages
=
getCurrentPages
()
let
len
=
pages
.
length
while
(
len
--
)
{
const
page
=
pages
[
len
]
if
(
page
.
$page
&&
page
.
$page
.
fullPath
===
url
)
{
return
len
}
}
return
-
1
}
src/core/runtime/wrapper.js
浏览文件 @
eb5c684c
...
...
@@ -10,7 +10,9 @@ import {
isContextApi
}
from
'
../helpers/promise
'
import
{
protocols
}
from
'
uni-platform/runtime/api/protocols
'
import
{
protocols
}
from
'
uni-platform/runtime/api/protocols
'
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
]
...
...
@@ -83,7 +85,12 @@ export default function wrapper (methodName, method) {
if
(
typeof
arg2
!==
'
undefined
'
)
{
args
.
push
(
arg2
)
}
const
returnValue
=
__GLOBAL__
[
options
.
name
||
methodName
].
apply
(
__GLOBAL__
,
args
)
if
(
isFn
(
options
.
name
))
{
methodName
=
options
.
name
(
arg1
)
}
else
if
(
isStr
(
options
.
name
))
{
methodName
=
options
.
name
}
const
returnValue
=
__GLOBAL__
[
methodName
].
apply
(
__GLOBAL__
,
args
)
if
(
isSyncApi
(
methodName
))
{
// 同步 api
return
processReturnValue
(
methodName
,
returnValue
,
options
.
returnValue
,
isContextApi
(
methodName
))
}
...
...
src/core/service/api/device/theme.js
浏览文件 @
eb5c684c
...
...
@@ -27,5 +27,5 @@ onMethod('onUIStyleChange', function (res) {
export
function
onUIStyleChange
(
callbackId
)
{
callbacks
.
push
(
callbackId
)
console
.
log
(
"
API uni.onUIStyleChange 已过时,请使用 uni.onThemeChange,详情:https://uniapp.dcloud.net.cn/api/system/theme
"
)
console
.
log
(
'
API uni.onUIStyleChange 已过时,请使用 uni.onThemeChange,详情:https://uniapp.dcloud.net.cn/api/system/theme
'
)
}
src/core/service/plugins/page/create-page.js
浏览文件 @
eb5c684c
...
...
@@ -14,6 +14,7 @@ export default function createPage (pageVm, options) {
id
,
path
:
$route
.
path
,
route
:
$route
.
meta
.
pagePath
,
fullPath
:
$route
.
meta
.
isEntry
?
$route
.
meta
.
pagePath
:
$route
.
fullPath
,
options
:
options
,
meta
:
Object
.
assign
({},
$route
.
meta
)
}
...
...
src/core/view/components/navigator/index.vue
浏览文件 @
eb5c684c
...
...
@@ -55,13 +55,18 @@ export default {
hoverStayTime
:
{
type
:
[
Number
,
String
],
default
:
600
},
exists
:
{
type
:
String
,
default
:
''
}
},
methods
:
{
_onClick
(
$event
)
{
if
(
this
.
openType
!==
'
navigateBack
'
&&
!
this
.
url
)
{
console
.
error
(
'
<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab
'
)
console
.
error
(
'
<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab
'
)
return
}
...
...
@@ -73,7 +78,8 @@ export default {
break
case
'
redirect
'
:
uni
.
redirectTo
({
url
:
this
.
url
url
:
this
.
url
,
exists
:
this
.
exists
})
break
case
'
switchTab
'
:
...
...
src/platforms/app-plus/service/api/route/redirect-to.js
浏览文件 @
eb5c684c
...
...
@@ -2,6 +2,10 @@ import {
parseQuery
}
from
'
uni-shared
'
import
{
findExistsPageIndex
}
from
'
uni-helpers/index
'
import
{
showWebview
}
from
'
./util
'
...
...
@@ -20,13 +24,35 @@ import {
navigate
}
from
'
../../framework/navigator
'
import
{
navigateBack
}
from
'
./navigate-back
'
function
_redirectTo
({
url
,
path
,
query
query
,
exists
},
callbackId
)
{
const
pages
=
getCurrentPages
()
const
lastPage
=
pages
[
pages
.
length
-
1
]
const
len
=
pages
.
length
-
1
if
(
exists
===
'
back
'
)
{
const
existsPageIndex
=
findExistsPageIndex
(
url
)
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
len
-
existsPageIndex
if
(
delta
>
0
)
{
navigateBack
({
delta
})
invoke
(
callbackId
,
{
errMsg
:
'
redirectTo:ok
'
})
return
}
}
}
const
lastPage
=
pages
[
len
]
lastPage
&&
lastPage
.
$remove
()
...
...
@@ -56,7 +82,8 @@ function _redirectTo ({
setStatusBarStyle
()
}
export
function
redirectTo
({
url
url
,
exists
},
callbackId
)
{
const
urls
=
url
.
split
(
'
?
'
)
const
path
=
urls
[
0
]
...
...
@@ -65,7 +92,8 @@ export function redirectTo ({
_redirectTo
({
url
,
path
,
query
query
,
exists
},
callbackId
)
})
}
src/platforms/app-plus/service/framework/page.js
浏览文件 @
eb5c684c
...
...
@@ -152,6 +152,7 @@ export function registerPage ({
meta
:
routeOptions
.
meta
,
path
,
route
,
fullPath
:
url
,
openType
},
$remove
()
{
...
...
src/platforms/h5/service/api/route/route.js
浏览文件 @
eb5c684c
import
{
hasLifecycleHook
hasLifecycleHook
,
findExistsPageIndex
}
from
'
uni-helpers/index
'
const
{
...
...
@@ -9,6 +10,7 @@ const {
function
onAppRoute
(
type
,
{
url
,
delta
,
exists
,
animationType
,
animationDuration
,
from
=
'
navigateBack
'
,
...
...
@@ -17,6 +19,17 @@ function onAppRoute (type, {
const
router
=
getApp
().
$router
switch
(
type
)
{
case
'
redirectTo
'
:
if
(
exists
===
'
back
'
)
{
const
existsPageIndex
=
findExistsPageIndex
(
url
)
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
(
getCurrentPages
().
length
-
1
)
-
existsPageIndex
if
(
delta
>
0
)
{
return
onAppRoute
(
'
navigateBack
'
,
{
delta
})
}
}
}
router
.
replace
({
type
,
path
:
url
...
...
src/platforms/mp-alipay/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
{
isPlainObject
}
from
'
uni-shared
'
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
// 不支持的 API 列表
const
todos
=
[
'
preloadPage
'
,
...
...
@@ -79,6 +80,7 @@ function _handleSystemInfo (result) {
}
const
protocols
=
{
// 需要做转换的 API 列表
redirectTo
,
returnValue
(
methodName
,
res
=
{})
{
// 通用 returnValue 解析
if
(
res
.
error
||
res
.
errorMessage
)
{
res
.
errMsg
=
`
${
methodName
}
:fail
${
res
.
errorMessage
||
res
.
error
}
`
...
...
@@ -111,7 +113,8 @@ const protocols = { // 需要做转换的 API 列表
},
data
(
data
)
{
// 钉钉小程序在content-type为application/json时需上传字符串形式data,使用my.dd在真机运行钉钉小程序时不能正确判断
if
(
my
.
canIUse
(
'
saveFileToDingTalk
'
)
&&
method
.
toUpperCase
()
===
'
POST
'
&&
headers
[
'
content-type
'
].
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
data
))
{
if
(
my
.
canIUse
(
'
saveFileToDingTalk
'
)
&&
method
.
toUpperCase
()
===
'
POST
'
&&
headers
[
'
content-type
'
].
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
data
))
{
return
{
name
:
'
data
'
,
value
:
JSON
.
stringify
(
data
)
...
...
src/platforms/mp-alipay/runtime/wrapper/page-parser.js
浏览文件 @
eb5c684c
import
Vue
from
'
vue
'
import
{
stringifyQuery
}
from
'
uni-shared/query
'
import
{
initData
,
initHooks
,
...
...
@@ -35,7 +39,7 @@ export default function parsePage (vuePageOptions) {
const
pageOptions
=
{
mixins
:
initBehaviors
(
vueOptions
,
initBehavior
),
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
onLoad
(
args
)
{
onLoad
(
query
)
{
const
properties
=
this
.
props
const
options
=
{
...
...
@@ -52,8 +56,13 @@ export default function parsePage (vuePageOptions) {
// 触发首次 setData
this
.
$vm
.
$mount
()
this
.
$vm
.
$mp
.
query
=
args
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
)
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
}
this
.
options
=
query
this
.
$vm
.
$mp
.
query
=
query
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
)
},
onReady
()
{
initChildVues
(
this
)
...
...
src/platforms/mp-baidu/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
// 不支持的 API 列表
const
todos
=
[
...
...
@@ -77,6 +78,7 @@ const protocols = {
method
:
false
}
},
redirectTo
,
previewImage
,
getRecorderManager
:
{
returnValue
(
fromRet
)
{
...
...
src/platforms/mp-kuaishou/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
import
previewImage
from
'
../../helpers/normalize-preview-image
'
export
const
protocols
=
{
redirectTo
,
previewImage
}
export
const
todos
=
[
...
...
src/platforms/mp-qq/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
export
const
protocols
=
{
redirectTo
,
previewImage
}
export
const
todos
=
[
...
...
src/platforms/mp-toutiao/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
// 不支持的 API 列表
...
...
@@ -99,6 +100,7 @@ const protocols = {
sizeType
:
false
}
},
redirectTo
,
previewImage
,
connectSocket
:
{
args
:
{
...
...
src/platforms/mp-weixin/helpers/redirect-to.js
0 → 100644
浏览文件 @
eb5c684c
import
{
findExistsPageIndex
}
from
'
uni-helpers/index
'
export
default
{
name
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
delta
)
{
return
'
navigateBack
'
}
return
'
redirectTo
'
},
args
(
fromArgs
)
{
if
(
fromArgs
.
exists
===
'
back
'
&&
fromArgs
.
url
)
{
const
existsPageIndex
=
findExistsPageIndex
(
fromArgs
.
url
)
if
(
existsPageIndex
!==
-
1
)
{
const
delta
=
getCurrentPages
().
length
-
1
-
existsPageIndex
if
(
delta
>
0
)
{
fromArgs
.
delta
=
delta
}
}
}
}
}
src/platforms/mp-weixin/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../helpers/redirect-to
'
import
previewImage
from
'
../../helpers/normalize-preview-image
'
function
addSafeAreaInsets
(
result
)
{
...
...
@@ -12,6 +13,7 @@ function addSafeAreaInsets (result) {
}
}
export
const
protocols
=
{
redirectTo
,
previewImage
,
getSystemInfo
:
{
returnValue
:
addSafeAreaInsets
...
...
src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js
浏览文件 @
eb5c684c
import
{
stringifyQuery
}
from
'
uni-shared/query
'
import
{
initHooks
,
PAGE_EVENT_HOOKS
...
...
@@ -24,9 +28,13 @@ export default function parseBasePage (vuePageOptions, {
initHooks
(
pageOptions
.
methods
,
hooks
,
vuePageOptions
)
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
)
pageOptions
.
methods
.
onLoad
=
function
(
query
)
{
this
.
options
=
query
this
.
$page
=
{
fullPath
:
'
/
'
+
this
.
route
+
stringifyQuery
(
query
)
}
this
.
$vm
.
$mp
.
query
=
query
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
query
)
}
return
pageOptions
...
...
src/platforms/quickapp-webview/runtime/api/protocols.js
浏览文件 @
eb5c684c
import
redirectTo
from
'
../../../mp-weixin/helpers/redirect-to
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
export
const
protocols
=
{
redirectTo
,
previewImage
}
export
const
todos
=
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录