Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
e85e60a6
U
uni-app
项目概览
陈庄旺
/
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,发现更多精彩内容 >>
提交
e85e60a6
编写于
6月 03, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app-plus-nvue): add sub-nvue,title-nview,post-message
上级
6d66e01d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
526 addition
and
68 deletion
+526
-68
packages/uni-app-plus-nvue/dist/service.legacy.js
packages/uni-app-plus-nvue/dist/service.legacy.js
+346
-63
src/platforms/app-plus-nvue/services/api/legacy/index.js
src/platforms/app-plus-nvue/services/api/legacy/index.js
+29
-3
src/platforms/app-plus-nvue/services/api/post-message.js
src/platforms/app-plus-nvue/services/api/post-message.js
+11
-0
src/platforms/app-plus-nvue/services/api/sub-nvue.js
src/platforms/app-plus-nvue/services/api/sub-nvue.js
+109
-0
src/platforms/app-plus-nvue/services/api/title-nview.js
src/platforms/app-plus-nvue/services/api/title-nview.js
+23
-0
src/platforms/app-plus-nvue/services/api/util.js
src/platforms/app-plus-nvue/services/api/util.js
+6
-0
src/platforms/app-plus-nvue/services/index.legacy.js
src/platforms/app-plus-nvue/services/index.legacy.js
+2
-2
未找到文件。
packages/uni-app-plus-nvue/dist/service.legacy.js
浏览文件 @
e85e60a6
...
...
@@ -72,67 +72,16 @@ function promisify (name, api) {
}
}
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
deviceWidth
=
0
;
let
deviceDPR
=
0
;
function
upx2px
(
number
,
newDeviceWidth
)
{
number
=
Number
(
number
);
if
(
number
===
0
)
{
return
0
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
result
=
-
result
;
}
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
return
1
}
else
{
return
0.5
}
}
return
number
<
0
?
-
result
:
result
}
function
initUpx2px
(
nvue
)
{
const
env
=
nvue
.
config
.
env
;
deviceDPR
=
env
.
scale
;
deviceWidth
=
Math
.
ceil
(
env
.
deviceWidth
/
deviceDPR
);
isIOS
=
env
.
platform
===
'
iOS
'
;
}
let
getEmitter
;
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
function
$on
()
{
return
apply
(
getEmitter
(),
'
$on
'
,
[...
arguments
])
}
function
$off
()
{
return
apply
(
getEmitter
(),
'
$off
'
,
[...
arguments
])
}
function
$once
()
{
return
apply
(
getEmitter
(),
'
$once
'
,
[...
arguments
])
}
function
$emit
()
{
return
apply
(
getEmitter
(),
'
$emit
'
,
[...
arguments
])
}
function
initEventBus
(
getGlobalEmitter
)
{
getEmitter
=
getGlobalEmitter
;
}
const
SUCCESS
=
'
success
'
;
const
FAIL
=
'
fail
'
;
const
COMPLETE
=
'
complete
'
;
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
];
const
UNIAPP_SERVICE_NVUE_ID
=
'
__uniapp__service
'
;
function
noop$1
()
{
}
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
...
...
@@ -239,6 +188,198 @@ function normalizeCallback (method, callbacks) {
}
}
function
initSubNVue
(
nvue
,
plus
,
BroadcastChannel
)
{
let
origin
;
const
onMessageCallbacks
=
[];
const
onSubNVueMessage
=
function
onSubNVueMessage
(
data
)
{
onMessageCallbacks
.
forEach
(
callback
=>
callback
({
origin
,
data
}));
};
nvue
.
requireModule
(
'
globalEvent
'
).
addEventListener
(
'
plusMessage
'
,
e
=>
{
if
(
e
.
data
.
type
===
'
UniAppSubNVue
'
)
{
onSubNVueMessage
(
e
.
data
.
data
,
e
.
data
.
options
);
}
});
const
webviewId
=
plus
.
webview
.
currentWebview
().
id
;
const
channel
=
new
BroadcastChannel
(
'
UNI-APP-SUBNVUE
'
);
channel
.
onmessage
=
function
(
event
)
{
if
(
event
.
data
.
to
===
webviewId
)
{
onSubNVueMessage
(
event
.
data
.
data
);
}
};
const
wrapper
=
function
wrapper
(
webview
)
{
webview
.
$processed
=
true
;
const
currentWebviewId
=
plus
.
webview
.
currentWebview
().
id
;
const
isPopupNVue
=
currentWebviewId
===
webview
.
id
;
const
hostNVueId
=
webview
.
__uniapp_origin_type
===
'
uniNView
'
&&
webview
.
__uniapp_origin_id
;
const
popupNVueId
=
webview
.
id
;
webview
.
postMessage
=
function
(
data
)
{
if
(
hostNVueId
)
{
channel
.
postMessage
({
data
,
to
:
isPopupNVue
?
hostNVueId
:
popupNVueId
});
}
else
{
plus
.
postMessage
({
type
:
'
UniAppSubNVue
'
,
data
:
data
},
UNIAPP_SERVICE_NVUE_ID
);
}
};
webview
.
onMessage
=
function
(
callback
)
{
onMessageCallbacks
.
push
(
callback
);
};
if
(
!
webview
.
__uniapp_mask_id
)
{
return
}
origin
=
webview
.
__uniapp_host
;
const
maskColor
=
webview
.
__uniapp_mask
;
let
maskWebview
=
plus
.
webview
.
getWebviewById
(
webview
.
__uniapp_mask_id
);
maskWebview
=
maskWebview
.
parent
()
||
maskWebview
;
// 再次检测父
const
oldShow
=
webview
.
show
;
const
oldHide
=
webview
.
hide
;
const
oldClose
=
webview
.
close
;
const
showMask
=
function
()
{
maskWebview
.
setStyle
({
mask
:
maskColor
});
};
const
closeMask
=
function
()
{
maskWebview
.
setStyle
({
mask
:
'
none
'
});
};
webview
.
show
=
function
(...
args
)
{
showMask
();
return
oldShow
.
apply
(
webview
,
args
)
};
webview
.
hide
=
function
(...
args
)
{
closeMask
();
return
oldHide
.
apply
(
webview
,
args
)
};
webview
.
close
=
function
(...
args
)
{
closeMask
();
return
oldClose
.
apply
(
webview
,
args
)
};
};
const
getSubNVueById
=
function
getSubNVueById
(
id
)
{
const
webview
=
plus
.
webview
.
getWebviewById
(
id
);
if
(
webview
&&
!
webview
.
$processed
)
{
wrapper
(
webview
);
}
return
webview
};
return
{
getSubNVueById
,
getCurrentSubNVue
()
{
return
getSubNVueById
(
plus
.
webview
.
currentWebview
().
id
)
}
}
}
function
initPostMessage
(
plus
)
{
return
{
postMessage
(
data
)
{
plus
.
postMessage
(
data
,
UNIAPP_SERVICE_NVUE_ID
);
}
}
}
function
initTitleNView
(
nvue
)
{
const
eventMaps
=
{
onNavigationBarButtonTap
:
noop$1
,
onNavigationBarSearchInputChanged
:
noop$1
,
onNavigationBarSearchInputConfirmed
:
noop$1
,
onNavigationBarSearchInputClicked
:
noop$1
};
nvue
.
requireModule
(
'
globalEvent
'
).
addEventListener
(
'
plusMessage
'
,
e
=>
{
if
(
eventMaps
[
e
.
data
.
type
])
{
eventMaps
[
e
.
data
.
type
](
e
.
data
.
data
);
}
});
const
ret
=
Object
.
create
(
null
);
Object
.
keys
(
eventMaps
).
forEach
(
eventType
=>
{
ret
[
eventType
]
=
function
(
callback
)
{
eventMaps
[
eventType
]
=
callback
;
};
});
return
ret
}
const
EPS
=
1
e
-
4
;
const
BASE_DEVICE_WIDTH
=
750
;
let
isIOS
=
false
;
let
deviceWidth
=
0
;
let
deviceDPR
=
0
;
function
upx2px
(
number
,
newDeviceWidth
)
{
number
=
Number
(
number
);
if
(
number
===
0
)
{
return
0
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
result
=
-
result
;
}
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
return
1
}
else
{
return
0.5
}
}
return
number
<
0
?
-
result
:
result
}
function
initUpx2px
(
nvue
)
{
const
env
=
nvue
.
config
.
env
;
deviceDPR
=
env
.
scale
;
deviceWidth
=
Math
.
ceil
(
env
.
deviceWidth
/
deviceDPR
);
isIOS
=
env
.
platform
===
'
iOS
'
;
}
let
getEmitter
;
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
function
$on
()
{
return
apply
(
getEmitter
(),
'
$on
'
,
[...
arguments
])
}
function
$off
()
{
return
apply
(
getEmitter
(),
'
$off
'
,
[...
arguments
])
}
function
$once
()
{
return
apply
(
getEmitter
(),
'
$once
'
,
[...
arguments
])
}
function
$emit
()
{
return
apply
(
getEmitter
(),
'
$emit
'
,
[...
arguments
])
}
function
initEventBus
(
getGlobalEmitter
)
{
getEmitter
=
getGlobalEmitter
;
}
class
MapContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
...
...
@@ -278,6 +419,132 @@ function createMapContext (id, vm) {
return
new
MapContext
(
id
,
vm
.
$refs
[
ref
])
}
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
}
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
}
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
}
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
}
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
}
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
}
}
function
createVideoContext
(
id
,
vm
)
{
const
ref
=
findRefById
(
id
,
vm
);
if
(
!
ref
)
{
global
.
nativeLog
(
'
Can not find `
'
+
id
+
'
`
'
,
'
__WARN
'
);
}
return
new
VideoContext
(
id
,
vm
.
$refs
[
ref
])
}
class
LivePusherContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
start
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
start
'
,
cbs
)
}
stop
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
,
cbs
)
}
pause
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
,
cbs
)
}
resume
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resume
'
,
cbs
)
}
switchCamera
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
switchCamera
'
,
cbs
)
}
snapshot
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
snapshot
'
,
cbs
)
}
toggleTorch
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
toggleTorch
'
,
cbs
)
}
playBGM
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playBGM
'
,
args
)
}
stopBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopBGM
'
,
cbs
)
}
pauseBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pauseBGM
'
,
cbs
)
}
resumeBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resumeBGM
'
,
cbs
)
}
setBGMVolume
(
cbs
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
setBGMVolume
'
,
cbs
)
}
startPreview
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
startPreview
'
,
cbs
)
}
stopPreview
(
args
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopPreview
'
,
args
)
}
}
function
createLivePusherContext
(
id
,
vm
)
{
const
ref
=
findRefById
(
id
,
vm
);
if
(
!
ref
)
{
global
.
nativeLog
(
'
Can not find `
'
+
id
+
'
`
'
,
'
__WARN
'
);
}
return
new
LivePusherContext
(
id
,
vm
.
$refs
[
ref
])
}
var
apis
=
/*#__PURE__*/
Object
.
freeze
({
...
...
@@ -286,18 +553,31 @@ var apis = /*#__PURE__*/Object.freeze({
$once
:
$once
,
$off
:
$off
,
$emit
:
$emit
,
createMapContext
:
createMapContext
createMapContext
:
createMapContext
,
createVideoContext
:
createVideoContext
,
createLivePusherContext
:
createLivePusherContext
});
function
initUni
(
uni
,
nvue
)
{
function
initUni
(
uni
,
nvue
,
plus
,
BroadcastChannel
)
{
const
{
getSubNVueById
,
getCurrentSubNVue
}
=
initSubNVue
(
nvue
,
plus
,
BroadcastChannel
);
const
scopedApis
=
Object
.
assign
({
getSubNVueById
,
getCurrentSubNVue
,
requireNativePlugin
:
nvue
.
requireModule
},
initTitleNView
(
nvue
),
initPostMessage
(
plus
));
if
(
typeof
Proxy
!==
'
undefined
'
)
{
return
new
Proxy
({},
{
get
(
target
,
name
)
{
if
(
apis
[
name
])
{
return
apis
[
name
]
}
if
(
name
===
'
requireNativePlugin
'
)
{
return
nvue
.
requireModule
if
(
scopedApis
[
name
]
)
{
return
scopedApis
[
name
]
}
if
(
!
hasOwn
(
uni
,
name
))
{
return
...
...
@@ -312,6 +592,9 @@ function initUni (uni, nvue) {
Object
.
keys
(
apis
).
forEach
(
name
=>
{
ret
[
name
]
=
apis
[
name
];
});
Object
.
keys
(
scopedApis
).
forEach
(
name
=>
{
ret
[
name
]
=
scopedApis
[
name
];
});
Object
.
keys
(
uni
).
forEach
(
name
=>
{
ret
[
name
]
=
promisify
(
name
,
uni
[
name
]);
});
...
...
@@ -342,8 +625,8 @@ var index_legacy = {
initEventBus
(
getUniEmitter
);
},
instance
:
{
getUni
(
nvue
)
{
return
initUni
(
getGlobalUni
(),
nvue
)
getUni
(
nvue
,
plus
,
BroadcastChannel
)
{
return
initUni
(
getGlobalUni
(),
nvue
,
plus
,
BroadcastChannel
)
},
getApp
()
{
return
getGlobalApp
()
...
...
src/platforms/app-plus-nvue/services/api/legacy/index.js
浏览文件 @
e85e60a6
...
...
@@ -6,17 +6,40 @@ import {
promisify
}
from
'
uni-core/helpers/promise
'
import
{
initSubNVue
}
from
'
../sub-nvue
'
import
{
initPostMessage
}
from
'
../post-message
'
import
{
initTitleNView
}
from
'
../title-nview
'
import
*
as
apis
from
'
./api
'
export
default
function
initUni
(
uni
,
nvue
)
{
export
default
function
initUni
(
uni
,
nvue
,
plus
,
BroadcastChannel
)
{
const
{
getSubNVueById
,
getCurrentSubNVue
}
=
initSubNVue
(
nvue
,
plus
,
BroadcastChannel
)
const
scopedApis
=
Object
.
assign
({
getSubNVueById
,
getCurrentSubNVue
,
requireNativePlugin
:
nvue
.
requireModule
},
initTitleNView
(
nvue
),
initPostMessage
(
plus
))
if
(
typeof
Proxy
!==
'
undefined
'
)
{
return
new
Proxy
({},
{
get
(
target
,
name
)
{
if
(
apis
[
name
])
{
return
apis
[
name
]
}
if
(
name
===
'
requireNativePlugin
'
)
{
return
nvue
.
requireModule
if
(
scopedApis
[
name
]
)
{
return
scopedApis
[
name
]
}
if
(
!
hasOwn
(
uni
,
name
))
{
return
...
...
@@ -31,6 +54,9 @@ export default function initUni (uni, nvue) {
Object
.
keys
(
apis
).
forEach
(
name
=>
{
ret
[
name
]
=
apis
[
name
]
})
Object
.
keys
(
scopedApis
).
forEach
(
name
=>
{
ret
[
name
]
=
scopedApis
[
name
]
})
Object
.
keys
(
uni
).
forEach
(
name
=>
{
ret
[
name
]
=
promisify
(
name
,
uni
[
name
])
})
...
...
src/platforms/app-plus-nvue/services/api/post-message.js
0 → 100644
浏览文件 @
e85e60a6
import
{
UNIAPP_SERVICE_NVUE_ID
}
from
'
./util
'
export
function
initPostMessage
(
plus
)
{
return
{
postMessage
(
data
)
{
plus
.
postMessage
(
data
,
UNIAPP_SERVICE_NVUE_ID
)
}
}
}
src/platforms/app-plus-nvue/services/api/sub-nvue.js
0 → 100644
浏览文件 @
e85e60a6
import
{
UNIAPP_SERVICE_NVUE_ID
}
from
'
./util
'
export
function
initSubNVue
(
nvue
,
plus
,
BroadcastChannel
)
{
let
origin
const
onMessageCallbacks
=
[]
const
onSubNVueMessage
=
function
onSubNVueMessage
(
data
)
{
onMessageCallbacks
.
forEach
(
callback
=>
callback
({
origin
,
data
}))
}
nvue
.
requireModule
(
'
globalEvent
'
).
addEventListener
(
'
plusMessage
'
,
e
=>
{
if
(
e
.
data
.
type
===
'
UniAppSubNVue
'
)
{
onSubNVueMessage
(
e
.
data
.
data
,
e
.
data
.
options
)
}
})
const
webviewId
=
plus
.
webview
.
currentWebview
().
id
const
channel
=
new
BroadcastChannel
(
'
UNI-APP-SUBNVUE
'
)
channel
.
onmessage
=
function
(
event
)
{
if
(
event
.
data
.
to
===
webviewId
)
{
onSubNVueMessage
(
event
.
data
.
data
)
}
}
const
wrapper
=
function
wrapper
(
webview
)
{
webview
.
$processed
=
true
const
currentWebviewId
=
plus
.
webview
.
currentWebview
().
id
const
isPopupNVue
=
currentWebviewId
===
webview
.
id
const
hostNVueId
=
webview
.
__uniapp_origin_type
===
'
uniNView
'
&&
webview
.
__uniapp_origin_id
const
popupNVueId
=
webview
.
id
webview
.
postMessage
=
function
(
data
)
{
if
(
hostNVueId
)
{
channel
.
postMessage
({
data
,
to
:
isPopupNVue
?
hostNVueId
:
popupNVueId
})
}
else
{
plus
.
postMessage
({
type
:
'
UniAppSubNVue
'
,
data
:
data
},
UNIAPP_SERVICE_NVUE_ID
)
}
}
webview
.
onMessage
=
function
(
callback
)
{
onMessageCallbacks
.
push
(
callback
)
}
if
(
!
webview
.
__uniapp_mask_id
)
{
return
}
origin
=
webview
.
__uniapp_host
const
maskColor
=
webview
.
__uniapp_mask
let
maskWebview
=
plus
.
webview
.
getWebviewById
(
webview
.
__uniapp_mask_id
)
maskWebview
=
maskWebview
.
parent
()
||
maskWebview
// 再次检测父
const
oldShow
=
webview
.
show
const
oldHide
=
webview
.
hide
const
oldClose
=
webview
.
close
const
showMask
=
function
()
{
maskWebview
.
setStyle
({
mask
:
maskColor
})
}
const
closeMask
=
function
()
{
maskWebview
.
setStyle
({
mask
:
'
none
'
})
}
webview
.
show
=
function
(...
args
)
{
showMask
()
return
oldShow
.
apply
(
webview
,
args
)
}
webview
.
hide
=
function
(...
args
)
{
closeMask
()
return
oldHide
.
apply
(
webview
,
args
)
}
webview
.
close
=
function
(...
args
)
{
closeMask
()
return
oldClose
.
apply
(
webview
,
args
)
}
}
const
getSubNVueById
=
function
getSubNVueById
(
id
)
{
const
webview
=
plus
.
webview
.
getWebviewById
(
id
)
if
(
webview
&&
!
webview
.
$processed
)
{
wrapper
(
webview
)
}
return
webview
}
return
{
getSubNVueById
,
getCurrentSubNVue
()
{
return
getSubNVueById
(
plus
.
webview
.
currentWebview
().
id
)
}
}
}
src/platforms/app-plus-nvue/services/api/title-nview.js
0 → 100644
浏览文件 @
e85e60a6
import
{
noop
}
from
'
./util
'
export
function
initTitleNView
(
nvue
)
{
const
eventMaps
=
{
onNavigationBarButtonTap
:
noop
,
onNavigationBarSearchInputChanged
:
noop
,
onNavigationBarSearchInputConfirmed
:
noop
,
onNavigationBarSearchInputClicked
:
noop
}
nvue
.
requireModule
(
'
globalEvent
'
).
addEventListener
(
'
plusMessage
'
,
e
=>
{
if
(
eventMaps
[
e
.
data
.
type
])
{
eventMaps
[
e
.
data
.
type
](
e
.
data
.
data
)
}
})
const
ret
=
Object
.
create
(
null
)
Object
.
keys
(
eventMaps
).
forEach
(
eventType
=>
{
ret
[
eventType
]
=
function
(
callback
)
{
eventMaps
[
eventType
]
=
callback
}
})
return
ret
}
src/platforms/app-plus-nvue/services/api/util.js
浏览文件 @
e85e60a6
...
...
@@ -6,6 +6,12 @@ const SUCCESS = 'success'
const
FAIL
=
'
fail
'
const
COMPLETE
=
'
complete
'
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
]
export
const
UNIAPP_SERVICE_NVUE_ID
=
'
__uniapp__service
'
export
function
noop
()
{
}
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
...
...
src/platforms/app-plus-nvue/services/index.legacy.js
浏览文件 @
e85e60a6
...
...
@@ -26,8 +26,8 @@ export default {
initEventBus
(
getUniEmitter
)
},
instance
:
{
getUni
(
nvue
)
{
return
initUni
(
getGlobalUni
(),
nvue
)
getUni
(
nvue
,
plus
,
BroadcastChannel
)
{
return
initUni
(
getGlobalUni
(),
nvue
,
plus
,
BroadcastChannel
)
},
getApp
()
{
return
getGlobalApp
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录