Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
b0e7ac94
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
b0e7ac94
编写于
11月 28, 2019
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: webview组件返回问题
webview在canBack时应优先返回webview内的页面
上级
31f0cbdc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
11 deletion
+48
-11
src/platforms/app-plus/constants.js
src/platforms/app-plus/constants.js
+2
-0
src/platforms/app-plus/service/api/route/navigate-back.js
src/platforms/app-plus/service/api/route/navigate-back.js
+11
-8
src/platforms/app-plus/service/framework/subscribe-handlers/index.js
...ms/app-plus/service/framework/subscribe-handlers/index.js
+12
-2
src/platforms/app-plus/service/framework/subscribe-handlers/on-webview-lifecycle.js
...vice/framework/subscribe-handlers/on-webview-lifecycle.js
+16
-0
src/platforms/app-plus/view/components/web-view/index.vue
src/platforms/app-plus/view/components/web-view/index.vue
+7
-1
未找到文件。
src/platforms/app-plus/constants.js
浏览文件 @
b0e7ac94
...
...
@@ -16,3 +16,5 @@ export const WEBVIEW_UI_EVENT = 'webviewUIEvent'
export
const
VD_SYNC_CALLBACK
=
'
vdSyncCallback
'
export
const
INVOKE_API
=
'
invokeApi
'
export
const
WEB_INVOKE_APPSERVICE
=
'
WEB_INVOKE_APPSERVICE
'
export
const
WEBVIEW_INSERTED
=
'
webviewInserted
'
export
const
WEBVIEW_REMOVED
=
'
webviewRemoved
'
src/platforms/app-plus/service/api/route/navigate-back.js
浏览文件 @
b0e7ac94
...
...
@@ -22,9 +22,6 @@ function quit () {
}
function
backWebview
(
webview
,
callback
)
{
if
(
!
webview
.
__uniapp_webview
)
{
return
callback
()
}
const
children
=
webview
.
children
()
if
(
!
children
||
!
children
.
length
)
{
// 有子 webview
return
callback
()
...
...
@@ -53,14 +50,14 @@ function back (delta, animationType, animationDuration) {
})
}
backWebview
(
currentPage
,
()
=>
{
const
backPage
=
function
()
{
if
(
animationType
)
{
currentPage
.
$getAppWebview
()
.
close
(
animationType
,
animationDuration
||
ANI_DURATION
)
webview
.
close
(
animationType
,
animationDuration
||
ANI_DURATION
)
}
else
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 如果是 redirectTo 跳转的,需要制定 back 动画
currentPage
.
$getAppWebview
()
.
close
(
ANI_CLOSE
,
ANI_DURATION
)
webview
.
close
(
ANI_CLOSE
,
ANI_DURATION
)
}
currentPage
.
$getAppWebview
()
.
close
(
'
auto
'
)
webview
.
close
(
'
auto
'
)
}
pages
.
slice
(
len
-
delta
,
len
).
forEach
(
page
=>
page
.
$remove
())
...
...
@@ -70,7 +67,13 @@ function back (delta, animationType, animationDuration) {
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
})
})
}
if
(
!
currentPage
.
__uniapp_webview
)
{
return
backPage
()
}
const
webview
=
currentPage
.
$getAppWebview
()
backWebview
(
webview
,
backPage
)
}
export
function
navigateBack
({
...
...
src/platforms/app-plus/service/framework/subscribe-handlers/index.js
浏览文件 @
b0e7ac94
...
...
@@ -5,7 +5,9 @@ import {
VD_SYNC_CALLBACK
,
INVOKE_API
,
WEBVIEW_READY
,
WEB_INVOKE_APPSERVICE
WEB_INVOKE_APPSERVICE
,
WEBVIEW_INSERTED
,
WEBVIEW_REMOVED
}
from
'
../../../constants
'
import
{
...
...
@@ -20,6 +22,11 @@ import onVdSyncCallback from './on-vd-sync-callback'
import
onInvokeApi
from
'
./on-invoke-api
'
import
onWebInvokeAppService
from
'
./on-web-invoke-app-service
'
import
onWxsInvokeCallMethod
from
'
./on-wxs-invoke-call-method
'
import
{
onWebviewInserted
,
onWebviewRemoved
}
from
'
./on-webview-lifecycle
'
export
function
initSubscribeHandlers
()
{
const
{
...
...
@@ -59,5 +66,8 @@ export function initSubscribeHandlers () {
subscribe
(
VD_SYNC
,
onVdSync
)
subscribe
(
VD_SYNC_CALLBACK
,
onVdSyncCallback
)
subscribe
(
INVOKE_API
,
onInvokeApi
)
subscribe
(
INVOKE_API
,
onInvokeApi
)
subscribe
(
WEBVIEW_INSERTED
,
onWebviewInserted
)
subscribe
(
WEBVIEW_REMOVED
,
onWebviewRemoved
)
}
src/platforms/app-plus/service/framework/subscribe-handlers/on-webview-lifecycle.js
0 → 100644
浏览文件 @
b0e7ac94
function
findPage
(
pageId
)
{
pageId
=
parseInt
(
pageId
)
const
page
=
getCurrentPages
(
true
).
find
(
page
=>
page
.
$page
.
id
===
pageId
)
if
(
!
page
)
{
return
console
.
error
(
`Page[
${
pageId
}
] not found`
)
}
return
page
}
export
function
onWebviewInserted
(
data
,
pageId
)
{
const
page
=
findPage
(
pageId
)
page
&&
(
page
.
__uniapp_webview
=
true
)
}
export
function
onWebviewRemoved
(
data
,
pageId
)
{
const
page
=
findPage
(
pageId
)
page
&&
(
delete
page
.
__uniapp_webview
)
}
src/platforms/app-plus/view/components/web-view/index.vue
浏览文件 @
b0e7ac94
<
template
>
<uni-web-view
/>
</
template
>
<
script
>
<
script
>
import
{
WEBVIEW_INSERTED
,
WEBVIEW_REMOVED
}
from
'
../../../constants
'
let
webview
=
false
const
insertHTMLWebView
=
({
htmlId
...
...
@@ -87,9 +91,11 @@ export default {
src
:
this
.
$getRealPath
(
this
.
src
),
webviewStyles
:
this
.
webviewStyles
})
UniViewJSBridge
.
publishHandler
(
WEBVIEW_INSERTED
,
{},
this
.
$page
.
id
)
},
beforeDestroy
()
{
removeHTMLWebView
()
UniViewJSBridge
.
publishHandler
(
WEBVIEW_REMOVED
,
{},
this
.
$page
.
id
)
}
}
</
script
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录