Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
2aa9cd32
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
716
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2aa9cd32
编写于
7月 07, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): getLaunchOptionsSync、getEnterOptionsSync 实现
上级
25549905
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
28 deletion
+62
-28
src/core/service/bridge/on.js
src/core/service/bridge/on.js
+5
-2
src/core/service/plugins/app/index.js
src/core/service/plugins/app/index.js
+53
-23
src/platforms/h5/service/api/plugin/get-launch-options-sync.js
...latforms/h5/service/api/plugin/get-launch-options-sync.js
+4
-3
未找到文件。
src/core/service/bridge/on.js
浏览文件 @
2aa9cd32
...
@@ -9,6 +9,8 @@ import {
...
@@ -9,6 +9,8 @@ import {
import
onWebInvokeAppService
from
'
uni-platform/service/on-web-invoke-app-service
'
import
onWebInvokeAppService
from
'
uni-platform/service/on-web-invoke-app-service
'
import
{
initEnterOptions
,
getEnterOptions
}
from
'
../plugins/app
'
export
default
function
initOn
(
on
,
{
export
default
function
initOn
(
on
,
{
getApp
,
getApp
,
getCurrentPages
getCurrentPages
...
@@ -53,7 +55,8 @@ export default function initOn (on, {
...
@@ -53,7 +55,8 @@ export default function initOn (on, {
}
}
function
onAppEnterForeground
(
enterOptions
)
{
function
onAppEnterForeground
(
enterOptions
)
{
callAppHook
(
getApp
(),
'
onShow
'
,
enterOptions
)
initEnterOptions
(
enterOptions
)
callAppHook
(
getApp
(),
'
onShow
'
,
getEnterOptions
())
const
pages
=
getCurrentPages
()
const
pages
=
getCurrentPages
()
if
(
pages
.
length
===
0
)
{
if
(
pages
.
length
===
0
)
{
return
return
...
@@ -99,4 +102,4 @@ export default function initOn (on, {
...
@@ -99,4 +102,4 @@ export default function initOn (on, {
on
(
'
onNavigationBarSearchInputFocusChanged
'
,
createCallCurrentPageHook
(
'
onNavigationBarSearchInputFocusChanged
'
))
on
(
'
onNavigationBarSearchInputFocusChanged
'
,
createCallCurrentPageHook
(
'
onNavigationBarSearchInputFocusChanged
'
))
on
(
'
onWebInvokeAppService
'
,
onWebInvokeAppService
)
on
(
'
onWebInvokeAppService
'
,
onWebInvokeAppService
)
}
}
src/core/service/plugins/app/index.js
浏览文件 @
2aa9cd32
...
@@ -10,29 +10,57 @@ export {
...
@@ -10,29 +10,57 @@ export {
}
}
from
'
./create-app
'
from
'
./create-app
'
export
let
createLaunchOptions
=
function
()
{
const
extend
=
Object
.
assign
const
scene
=
1001
const
referrerInfo
=
{
function
createLaunchOptions
()
{
appId
:
''
,
return
{
extraData
:
{}
path
:
''
,
}
query
:
{},
try
{
scene
:
1001
,
return
{
referrerInfo
:
{
path
:
this
.
$route
.
meta
&&
this
.
$route
.
meta
.
pagePath
,
appId
:
''
,
query
:
this
.
$route
.
query
,
extraData
:
{}
scene
,
referrerInfo
}
}
catch
(
error
)
{
return
{
path
:
''
,
query
:
{},
scene
,
referrerInfo
}
}
}
}
}
}
const
enterOptions
=
createLaunchOptions
()
const
launchOptions
=
createLaunchOptions
()
export
function
getLaunchOptions
()
{
return
launchOptions
}
export
function
getEnterOptions
()
{
return
enterOptions
}
export
function
initEnterOptions
({
path
,
query
,
referrerInfo
})
{
extend
(
enterOptions
,
{
path
,
query
:
query
||
{},
referrerInfo
:
referrerInfo
||
{}
})
}
export
function
initLaunchOptions
({
path
,
query
,
referrerInfo
})
{
extend
(
launchOptions
,
{
path
,
query
:
query
||
{},
referrerInfo
:
referrerInfo
||
{}
})
extend
(
enterOptions
,
launchOptions
)
return
launchOptions
}
export
function
createAppMixin
(
Vue
,
routes
,
entryRoute
)
{
export
function
createAppMixin
(
Vue
,
routes
,
entryRoute
)
{
return
{
return
{
created
:
function
AppCreated
()
{
created
:
function
AppCreated
()
{
...
@@ -54,10 +82,12 @@ export function createAppMixin (Vue, routes, entryRoute) {
...
@@ -54,10 +82,12 @@ export function createAppMixin (Vue, routes, entryRoute) {
},
},
mounted
:
function
appMounted
()
{
mounted
:
function
appMounted
()
{
// 稍微靠后点,让 App 有机会在 mounted 事件前注册一些全局事件监听,如 UI 显示(showModal)
// 稍微靠后点,让 App 有机会在 mounted 事件前注册一些全局事件监听,如 UI 显示(showModal)
createLaunchOptions
=
createLaunchOptions
.
bind
(
this
)
initLaunchOptions
({
const
args
=
createLaunchOptions
()
path
:
this
.
$route
.
meta
&&
this
.
$route
.
meta
.
pagePath
,
callAppHook
(
this
,
'
onLaunch
'
,
args
)
query
:
this
.
$route
.
query
callAppHook
(
this
,
'
onShow
'
,
args
)
})
callAppHook
(
this
,
'
onLaunch
'
,
launchOptions
)
callAppHook
(
this
,
'
onShow
'
,
enterOptions
)
}
}
}
}
}
}
src/platforms/h5/service/api/plugin/get-launch-options-sync.js
浏览文件 @
2aa9cd32
import
{
import
{
createLaunchOptions
getLaunchOptions
,
getEnterOptions
}
from
'
uni-core/service/plugins/app
'
}
from
'
uni-core/service/plugins/app
'
export
function
getLaunchOptionsSync
()
{
export
function
getLaunchOptionsSync
()
{
return
create
LaunchOptions
()
return
get
LaunchOptions
()
}
}
export
function
getEnterOptionsSync
()
{
export
function
getEnterOptionsSync
()
{
return
createLaunch
Options
()
return
getEnter
Options
()
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录