Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ripplebb
uni-app
提交
87bbde3d
U
uni-app
项目概览
ripplebb
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87bbde3d
编写于
3月 06, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(v3): refactor debug refresh
上级
3be2f558
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
144 addition
and
43 deletion
+144
-43
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+113
-22
src/platforms/app-plus/service/framework/page.js
src/platforms/app-plus/service/framework/page.js
+3
-3
src/platforms/app-plus/service/framework/webview/index.js
src/platforms/app-plus/service/framework/webview/index.js
+23
-13
src/shared/query.js
src/shared/query.js
+5
-5
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
87bbde3d
...
...
@@ -199,6 +199,7 @@ var serviceContext = (function () {
'
checkSession
'
,
'
getUserInfo
'
,
'
share
'
,
'
shareWithSystem
'
,
'
showShareMenu
'
,
'
hideShareMenu
'
,
'
requestPayment
'
,
...
...
@@ -307,6 +308,17 @@ var serviceContext = (function () {
}
}
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
,
'
,
'
);
const
decode
=
decodeURIComponent
;
function
parseQuery
(
query
)
{
...
...
@@ -335,6 +347,38 @@ var serviceContext = (function () {
});
return
res
}
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
}
`
:
''
}
let
id
=
0
;
...
...
@@ -1284,9 +1328,9 @@ var serviceContext = (function () {
ARRAYBUFFER
:
'
arraybuffer
'
};
const
encode
=
encodeURIComponent
;
const
encode
$1
=
encodeURIComponent
;
function
stringifyQuery
(
url
,
data
)
{
function
stringifyQuery
$1
(
url
,
data
)
{
let
str
=
url
.
split
(
'
#
'
);
const
hash
=
str
[
1
]
||
''
;
str
=
str
[
0
].
split
(
'
?
'
);
...
...
@@ -1301,9 +1345,9 @@ var serviceContext = (function () {
for
(
let
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
))
{
if
(
isPlainObject
(
data
[
key
]))
{
query
[
encode
(
key
)]
=
encode
(
JSON
.
stringify
(
data
[
key
]));
query
[
encode
$1
(
key
)]
=
encode$1
(
JSON
.
stringify
(
data
[
key
]));
}
else
{
query
[
encode
(
key
)]
=
encode
(
data
[
key
]);
query
[
encode
$1
(
key
)]
=
encode$1
(
data
[
key
]);
}
}
}
...
...
@@ -1334,7 +1378,7 @@ var serviceContext = (function () {
isPlainObject
(
params
.
data
)
&&
Object
.
keys
(
params
.
data
).
length
)
{
// 将 method,data 校验提前,保证 url 校验时,method,data 已被格式化
params
.
url
=
stringifyQuery
(
value
,
params
.
data
);
params
.
url
=
stringifyQuery
$1
(
value
,
params
.
data
);
}
}
},
...
...
@@ -7125,6 +7169,39 @@ var serviceContext = (function () {
});
}
);
}
function
shareWithSystem
(
params
,
callbackId
,
method
=
'
shareWithSystem
'
)
{
let
{
type
,
imageUrl
,
summary
:
content
,
href
}
=
params
;
type
=
type
||
'
text
'
;
const
allowedTypes
=
[
'
text
'
,
'
image
'
];
if
(
allowedTypes
.
indexOf
(
type
)
<
0
)
{
invoke$1
(
callbackId
,
{
errMsg
:
method
+
'
:fail:分享参数 type 不正确
'
});
}
if
(
typeof
imageUrl
===
'
string
'
&&
imageUrl
)
{
imageUrl
=
getRealPath$1
(
imageUrl
);
}
plus
.
share
.
sendWithSystem
({
type
,
pictures
:
imageUrl
?
[
imageUrl
]
:
[],
content
,
href
},
function
(
res
)
{
invoke$1
(
callbackId
,
{
errMsg
:
method
+
'
:ok
'
});
},
function
(
err
)
{
invoke$1
(
callbackId
,
{
errMsg
:
method
+
'
:fail:
'
+
err
.
message
});
});
}
function
restoreGlobal
(
...
...
@@ -7802,7 +7879,22 @@ var serviceContext = (function () {
preloadWebview
=
webview
;
}
function
createWebview
(
path
,
routeOptions
)
{
function
noop$1
(
str
)
{
return
str
}
function
getDebugRefresh
(
path
,
query
,
routeOptions
)
{
const
queryString
=
query
?
stringifyQuery
(
query
,
noop$1
)
:
''
;
return
{
isTab
:
routeOptions
.
meta
.
isTabBar
,
arguments
:
JSON
.
stringify
({
path
:
path
.
substr
(
1
),
query
:
queryString
?
queryString
.
substr
(
1
)
:
queryString
})
}
}
function
createWebview
(
path
,
routeOptions
,
query
)
{
if
(
routeOptions
.
meta
.
isNVue
)
{
const
webviewId
=
id$1
++
;
const
webviewStyle
=
parseWebviewStyle
(
...
...
@@ -7810,6 +7902,7 @@ var serviceContext = (function () {
path
,
routeOptions
);
webviewStyle
.
debugRefresh
=
getDebugRefresh
(
path
,
query
,
routeOptions
);
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] createWebview`
,
webviewId
,
path
,
webviewStyle
);
}
...
...
@@ -7824,7 +7917,7 @@ var serviceContext = (function () {
return
webview
}
function
initWebview
(
webview
,
routeOptions
,
url
=
''
)
{
function
initWebview
(
webview
,
routeOptions
,
path
,
query
)
{
// 首页或非 nvue 页面
if
(
webview
.
id
===
'
1
'
||
!
routeOptions
.
meta
.
isNVue
)
{
const
webviewStyle
=
parseWebviewStyle
(
...
...
@@ -7832,17 +7925,7 @@ var serviceContext = (function () {
''
,
routeOptions
);
if
(
url
)
{
const
part
=
url
.
split
(
'
?
'
);
webviewStyle
.
debugRefresh
=
{
isTab
:
routeOptions
.
meta
.
isTabBar
,
arguments
:
JSON
.
stringify
({
path
:
part
[
0
].
substr
(
1
),
query
:
part
[
1
]
||
''
})
};
}
webviewStyle
.
debugRefresh
=
getDebugRefresh
(
path
,
query
,
routeOptions
);
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] updateWebview`
,
webviewStyle
);
}
...
...
@@ -8038,7 +8121,7 @@ var serviceContext = (function () {
/**
* 首页需要主动registerPage,二级页面路由跳转时registerPage
*/
function
registerPage
({
function
registerPage
({
url
,
path
,
query
,
...
...
@@ -8060,7 +8143,7 @@ var serviceContext = (function () {
}
if
(
!
webview
)
{
webview
=
createWebview
(
path
,
routeOptions
);
webview
=
createWebview
(
path
,
routeOptions
,
query
);
}
else
{
webview
=
plus
.
webview
.
getWebviewById
(
webview
.
id
);
webview
.
nvue
=
routeOptions
.
meta
.
isNVue
;
...
...
@@ -8078,7 +8161,7 @@ var serviceContext = (function () {
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
);
}
initWebview
(
webview
,
routeOptions
,
url
);
initWebview
(
webview
,
routeOptions
,
path
,
query
);
const
route
=
path
.
slice
(
1
);
...
...
@@ -9095,6 +9178,7 @@ var serviceContext = (function () {
requireNativePlugin
:
requireNativePlugin$1
,
shareAppMessageDirectly
:
shareAppMessageDirectly
,
share
:
share
,
shareWithSystem
:
shareWithSystem
,
restoreGlobal
:
restoreGlobal
,
getSubNVueById
:
getSubNVueById
,
getCurrentSubNVue
:
getCurrentSubNVue
,
...
...
@@ -10911,7 +10995,14 @@ var serviceContext = (function () {
}
function
request$1
(
args
,
callbackId
)
{
if
(
args
.
method
!==
'
GET
'
&&
args
.
header
[
'
Content-Type
'
].
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
args
.
data
))
{
let
contentType
;
for
(
const
name
in
args
.
header
)
{
if
(
name
.
toLowerCase
()
===
'
content-type
'
)
{
contentType
=
args
.
header
[
name
];
break
}
}
if
(
args
.
method
!==
'
GET
'
&&
contentType
.
indexOf
(
'
application/json
'
)
===
0
&&
isPlainObject
(
args
.
data
))
{
args
.
data
=
JSON
.
stringify
(
args
.
data
);
}
const
{
...
...
src/platforms/app-plus/service/framework/page.js
浏览文件 @
87bbde3d
...
...
@@ -24,7 +24,7 @@ export function getCurrentPages (returnAll) {
/**
* 首页需要主动registerPage,二级页面路由跳转时registerPage
*/
export
function
registerPage
({
export
function
registerPage
({
url
,
path
,
query
,
...
...
@@ -46,7 +46,7 @@ export function registerPage ({
}
if
(
!
webview
)
{
webview
=
createWebview
(
path
,
routeOptions
)
webview
=
createWebview
(
path
,
routeOptions
,
query
)
}
else
{
webview
=
plus
.
webview
.
getWebviewById
(
webview
.
id
)
webview
.
nvue
=
routeOptions
.
meta
.
isNVue
...
...
@@ -64,7 +64,7 @@ export function registerPage ({
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
)
}
initWebview
(
webview
,
routeOptions
,
url
)
initWebview
(
webview
,
routeOptions
,
path
,
query
)
const
route
=
path
.
slice
(
1
)
...
...
src/platforms/app-plus/service/framework/webview/index.js
浏览文件 @
87bbde3d
import
{
stringifyQuery
}
from
'
uni-shared
'
import
{
parseWebviewStyle
}
from
'
./parser/webview-style-parser
'
...
...
@@ -41,7 +45,22 @@ export function setPreloadWebview (webview) {
preloadWebview
=
webview
}
export
function
createWebview
(
path
,
routeOptions
)
{
function
noop
(
str
)
{
return
str
}
function
getDebugRefresh
(
path
,
query
,
routeOptions
)
{
const
queryString
=
query
?
stringifyQuery
(
query
,
noop
)
:
''
return
{
isTab
:
routeOptions
.
meta
.
isTabBar
,
arguments
:
JSON
.
stringify
({
path
:
path
.
substr
(
1
),
query
:
queryString
?
queryString
.
substr
(
1
)
:
queryString
})
}
}
export
function
createWebview
(
path
,
routeOptions
,
query
)
{
if
(
routeOptions
.
meta
.
isNVue
)
{
const
webviewId
=
id
++
const
webviewStyle
=
parseWebviewStyle
(
...
...
@@ -49,6 +68,7 @@ export function createWebview (path, routeOptions) {
path
,
routeOptions
)
webviewStyle
.
debugRefresh
=
getDebugRefresh
(
path
,
query
,
routeOptions
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] createWebview`
,
webviewId
,
path
,
webviewStyle
)
}
...
...
@@ -63,7 +83,7 @@ export function createWebview (path, routeOptions) {
return
webview
}
export
function
initWebview
(
webview
,
routeOptions
,
url
=
''
)
{
export
function
initWebview
(
webview
,
routeOptions
,
path
,
query
)
{
// 首页或非 nvue 页面
if
(
webview
.
id
===
'
1
'
||
!
routeOptions
.
meta
.
isNVue
)
{
const
webviewStyle
=
parseWebviewStyle
(
...
...
@@ -71,17 +91,7 @@ export function initWebview (webview, routeOptions, url = '') {
''
,
routeOptions
)
if
(
url
)
{
const
part
=
url
.
split
(
'
?
'
)
webviewStyle
.
debugRefresh
=
{
isTab
:
routeOptions
.
meta
.
isTabBar
,
arguments
:
JSON
.
stringify
({
path
:
part
[
0
].
substr
(
1
),
query
:
part
[
1
]
||
''
})
}
}
webviewStyle
.
debugRefresh
=
getDebugRefresh
(
path
,
query
,
routeOptions
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] updateWebview`
,
webviewStyle
)
}
...
...
src/shared/query.js
浏览文件 @
87bbde3d
...
...
@@ -39,7 +39,7 @@ export function parseQuery (query) {
return
res
}
export
function
stringifyQuery
(
obj
)
{
export
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
const
res
=
obj
?
Object
.
keys
(
obj
).
map
(
key
=>
{
const
val
=
obj
[
key
]
...
...
@@ -48,7 +48,7 @@ export function stringifyQuery (obj) {
}
if
(
val
===
null
)
{
return
encode
(
key
)
return
encode
Str
(
key
)
}
if
(
Array
.
isArray
(
val
))
{
...
...
@@ -58,15 +58,15 @@ export function stringifyQuery (obj) {
return
}
if
(
val2
===
null
)
{
result
.
push
(
encode
(
key
))
result
.
push
(
encode
Str
(
key
))
}
else
{
result
.
push
(
encode
(
key
)
+
'
=
'
+
encode
(
val2
))
result
.
push
(
encode
Str
(
key
)
+
'
=
'
+
encodeStr
(
val2
))
}
})
return
result
.
join
(
'
&
'
)
}
return
encode
(
key
)
+
'
=
'
+
encode
(
val
)
return
encode
Str
(
key
)
+
'
=
'
+
encodeStr
(
val
)
}).
filter
(
x
=>
x
.
length
>
0
).
join
(
'
&
'
)
:
null
return
res
?
`?
${
res
}
`
:
''
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录