Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
211086b1
U
uni-app
项目概览
Velpro187
/
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,发现更多精彩内容 >>
提交
211086b1
编写于
12月 27, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(sdk): add onHostEventReceive
上级
800152d8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
11 deletion
+45
-11
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+20
-8
packages/uni-app-plus/src/service/api/plugin/sdk.ts
packages/uni-app-plus/src/service/api/plugin/sdk.ts
+10
-0
packages/uni-app-plus/src/service/constants.ts
packages/uni-app-plus/src/service/constants.ts
+2
-0
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
...uni-app-plus/src/service/framework/app/initGlobalEvent.ts
+10
-0
packages/uni-h5-vite/src/index.ts
packages/uni-h5-vite/src/index.ts
+2
-2
packages/uni-h5-vite/src/plugin/index.ts
packages/uni-h5-vite/src/plugin/index.ts
+1
-1
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
211086b1
...
...
@@ -17216,6 +17216,14 @@ var serviceContext = (function (vue) {
}
}
const downgrade = plus.os.name === 'Android' && parseInt(plus.os.version) < 6;
const ANI_SHOW = downgrade ? 'slide-in-right' : 'pop-in';
const ANI_DURATION = 300;
const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out';
const VIEW_WEBVIEW_PATH = '_www/__uniappview.html';
const WEBVIEW_ID_PREFIX = 'webviewId';
const SDK_UNI_MP_NATIVE_EVENT = 'uniMPNativeEvent';
function initGlobalEvent() {
const plusGlobalEvent = plus.globalEvent;
const weexGlobalEvent = weex.requireModule('globalEvent');
...
...
@@ -17254,6 +17262,11 @@ 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);
}
});
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage);
// nvue webview post message
plusGlobalEvent.addEventListener('WebviewPostMessage', subscribePlusMessage);
...
...
@@ -17484,13 +17497,6 @@ var serviceContext = (function (vue) {
});
}
const downgrade = plus.os.name === 'Android' && parseInt(plus.os.version) < 6;
const ANI_SHOW = downgrade ? 'slide-in-right' : 'pop-in';
const ANI_DURATION = 300;
const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out';
const VIEW_WEBVIEW_PATH = '_www/__uniappview.html';
const WEBVIEW_ID_PREFIX = 'webviewId';
function initNVue(webviewStyle, routeMeta, path) {
if (path && routeMeta.isNVue) {
webviewStyle.uniNView = {
...
...
@@ -19160,7 +19166,11 @@ var serviceContext = (function (vue) {
}
resolve();
});
});
});
function onHostEventReceive(name, fn) {
UniServiceJSBridge.on(SDK_UNI_MP_NATIVE_EVENT + '.' + name, fn);
}
const onNativeEventReceive = onHostEventReceive;
const EventType = {
load: 'load',
...
...
@@ -19929,6 +19939,8 @@ var serviceContext = (function (vue) {
restoreGlobal: restoreGlobal,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd,
...
...
packages/uni-app-plus/src/service/api/plugin/sdk.ts
浏览文件 @
211086b1
import
{
defineAsyncApi
}
from
'
@dcloudio/uni-api
'
import
{
sendNativeEvent
}
from
'
./requireNativePlugin
'
import
{
SDK_UNI_MP_NATIVE_EVENT
}
from
'
../../constants
'
export
const
sendHostEvent
=
sendNativeEvent
...
...
@@ -26,3 +27,12 @@ export const navigateToMiniProgram =
})
}
)
export
function
onHostEventReceive
(
name
:
string
,
fn
:
(...
args
:
unknown
[])
=>
void
)
{
UniServiceJSBridge
.
on
(
SDK_UNI_MP_NATIVE_EVENT
+
'
.
'
+
name
,
fn
)
}
export
const
onNativeEventReceive
=
onHostEventReceive
packages/uni-app-plus/src/service/constants.ts
浏览文件 @
211086b1
...
...
@@ -8,3 +8,5 @@ export const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out'
export
const
VIEW_WEBVIEW_PATH
=
'
_www/__uniappview.html
'
export
const
WEBVIEW_ID_PREFIX
=
'
webviewId
'
export
const
SDK_UNI_MP_NATIVE_EVENT
=
'
uniMPNativeEvent
'
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
浏览文件 @
211086b1
...
...
@@ -5,6 +5,7 @@ import {
ON_THEME_CHANGE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
}
from
'
@dcloudio/uni-shared
'
import
{
SDK_UNI_MP_NATIVE_EVENT
}
from
'
../../constants
'
import
{
EVENT_BACKBUTTON
,
backbuttonListener
,
...
...
@@ -62,6 +63,15 @@ export function initGlobalEvent() {
}
)
weexGlobalEvent
.
addEventListener
(
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
)
}
}
)
plusGlobalEvent
.
addEventListener
(
'
plusMessage
'
,
subscribePlusMessage
)
// nvue webview post message
plusGlobalEvent
.
addEventListener
(
'
WebviewPostMessage
'
,
subscribePlusMessage
)
...
...
packages/uni-h5-vite/src/index.ts
浏览文件 @
211086b1
...
...
@@ -6,7 +6,7 @@ import {
uniViteInjectPlugin
,
UNI_EASYCOM_EXCLUDE
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
uniH5P
L
ugin
}
from
'
./plugin
'
import
{
uniH5P
l
ugin
}
from
'
./plugin
'
import
{
uniCssPlugin
}
from
'
./plugins/css
'
import
{
uniEasycomPlugin
}
from
'
./plugins/easycom
'
import
{
uniInjectPlugin
}
from
'
./plugins/inject
'
...
...
@@ -35,5 +35,5 @@ export default [
uniSSRPlugin
(),
uniSetupPlugin
(),
uniRenderjsPlugin
(),
uniH5P
L
ugin
(),
uniH5P
l
ugin
(),
]
packages/uni-h5-vite/src/plugin/index.ts
浏览文件 @
211086b1
...
...
@@ -10,7 +10,7 @@ import { createUni } from './uni'
import
{
createConfig
}
from
'
./config
'
import
{
isString
}
from
'
@vue/shared
'
export
function
uniH5P
L
ugin
():
UniVitePlugin
{
export
function
uniH5P
l
ugin
():
UniVitePlugin
{
const
configOptions
:
{
resolvedConfig
:
ResolvedConfig
|
null
}
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录