Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
38200acb
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
38200acb
编写于
1月 10, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(app): onHostEventReceive
上级
a894d508
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
28 deletion
+41
-28
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+24
-20
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+6
-1
packages/uni-app-plus/src/service/api/plugin/sdk.ts
packages/uni-app-plus/src/service/api/plugin/sdk.ts
+9
-6
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
...uni-app-plus/src/service/framework/app/initGlobalEvent.ts
+2
-1
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
38200acb
...
...
@@ -17240,6 +17240,25 @@ var serviceContext = (function (vue) {
}
}
const sendHostEvent = sendNativeEvent;
const API_NAVIGATE_TO_MINI_PROGRAM = 'navigateToMiniProgram';
const navigateToMiniProgram = defineAsyncApi(API_NAVIGATE_TO_MINI_PROGRAM, (data, { resolve, reject }) => {
sendHostEvent('navigateToUniMP', data, (res) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
return reject(res.errMsg.split(' ')[1]);
}
resolve();
});
});
const hostEventCallbacks = [];
function onHostEventReceive(fn) {
hostEventCallbacks.push(fn);
}
const onNativeEventReceive = onHostEventReceive;
function invokeHostEvent(event, data) {
hostEventCallbacks.forEach((fn) => fn(event, data));
}
const downgrade = plus.os.name === 'Android' && parseInt(plus.os.version) < 6;
const ANI_SHOW = downgrade ? 'slide-in-right' : 'pop-in';
const ANI_DURATION = 300;
...
...
@@ -17288,7 +17307,7 @@ var serviceContext = (function (vue) {
});
weexGlobalEvent.addEventListener(SDK_UNI_MP_NATIVE_EVENT, function (res) {
if (res && res.event) {
emit(SDK_UNI_MP_NATIVE_EVENT + '.' +
res.event, res.data);
invokeHostEvent(
res.event, res.data);
}
});
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage);
...
...
@@ -19178,21 +19197,6 @@ var serviceContext = (function (vue) {
__uniConfig.serviceReady = true;
}
const sendHostEvent = sendNativeEvent;
const API_NAVIGATE_TO_MINI_PROGRAM = 'navigateToMiniProgram';
const navigateToMiniProgram = defineAsyncApi(API_NAVIGATE_TO_MINI_PROGRAM, (data, { resolve, reject }) => {
sendHostEvent('navigateToUniMP', data, (res) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
return reject(res.errMsg.split(' ')[1]);
}
resolve();
});
});
function onHostEventReceive(name, fn) {
UniServiceJSBridge.on(SDK_UNI_MP_NATIVE_EVENT + '.' + name, fn);
}
const onNativeEventReceive = onHostEventReceive;
const EventType = {
load: 'load',
close: 'close',
...
...
@@ -19788,6 +19792,10 @@ var serviceContext = (function (vue) {
var uni$1 = {
__proto__: null,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
navigateTo: navigateTo,
reLaunch: reLaunch,
switchTab: switchTab,
...
...
@@ -19958,10 +19966,6 @@ var serviceContext = (function (vue) {
sendNativeEvent: sendNativeEvent,
__vuePlugin: index$1,
restoreGlobal: restoreGlobal,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
38200acb
...
...
@@ -63,7 +63,12 @@ export * from './plugin/requestPayment'
export
*
from
'
./plugin/requireNativePlugin
'
export
*
from
'
./plugin/vuePlugin
'
export
*
from
'
./plugin/restoreGlobal
'
export
*
from
'
./plugin/sdk
'
export
{
sendHostEvent
,
navigateToMiniProgram
,
onHostEventReceive
,
onNativeEventReceive
,
}
from
'
./plugin/sdk
'
export
*
from
'
./ad/rewardedVideoAd
'
export
*
from
'
./ad/fullScreenVideoAd
'
...
...
packages/uni-app-plus/src/service/api/plugin/sdk.ts
浏览文件 @
38200acb
import
{
defineAsyncApi
}
from
'
@dcloudio/uni-api
'
import
{
sendNativeEvent
}
from
'
./requireNativePlugin
'
import
{
SDK_UNI_MP_NATIVE_EVENT
}
from
'
../../constants
'
export
const
sendHostEvent
=
sendNativeEvent
...
...
@@ -28,11 +27,15 @@ export const navigateToMiniProgram =
}
)
export
function
onHostEventReceive
(
name
:
string
,
fn
:
(...
args
:
unknown
[])
=>
void
)
{
UniServiceJSBridge
.
on
(
SDK_UNI_MP_NATIVE_EVENT
+
'
.
'
+
name
,
fn
)
type
HostEventCallback
=
(
event
:
string
,
data
:
unknown
)
=>
void
const
hostEventCallbacks
:
HostEventCallback
[]
=
[]
export
function
onHostEventReceive
(
fn
:
HostEventCallback
)
{
hostEventCallbacks
.
push
(
fn
)
}
export
const
onNativeEventReceive
=
onHostEventReceive
export
function
invokeHostEvent
(
event
:
string
,
data
:
unknown
)
{
hostEventCallbacks
.
forEach
((
fn
)
=>
fn
(
event
,
data
))
}
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
浏览文件 @
38200acb
...
...
@@ -5,6 +5,7 @@ import {
ON_THEME_CHANGE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
}
from
'
@dcloudio/uni-shared
'
import
{
invokeHostEvent
}
from
'
../../api/plugin/sdk
'
import
{
SDK_UNI_MP_NATIVE_EVENT
}
from
'
../../constants
'
import
{
EVENT_BACKBUTTON
,
...
...
@@ -67,7 +68,7 @@ export function initGlobalEvent() {
SDK_UNI_MP_NATIVE_EVENT
,
function
(
res
:
{
event
:
string
;
data
:
unknown
})
{
if
(
res
&&
res
.
event
)
{
emit
(
SDK_UNI_MP_NATIVE_EVENT
+
'
.
'
+
res
.
event
,
res
.
data
)
invokeHostEvent
(
res
.
event
,
res
.
data
)
}
}
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录