Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
71e3a407
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
71e3a407
编写于
7月 15, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): createPushMessage
上级
dd616eec
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
67 addition
and
16 deletion
+67
-16
lib/apis.js
lib/apis.js
+2
-1
packages/uni-cli-shared/lib/manifest.js
packages/uni-cli-shared/lib/manifest.js
+24
-2
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+2
-2
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+5
-2
src/platforms/app-plus/service/api/device/get-app-authorize-setting.js
.../app-plus/service/api/device/get-app-authorize-setting.js
+3
-4
src/platforms/app-plus/service/api/device/get-system-setting.js
...atforms/app-plus/service/api/device/get-system-setting.js
+3
-4
src/platforms/app-plus/service/api/plugin/push.js
src/platforms/app-plus/service/api/plugin/push.js
+28
-1
未找到文件。
lib/apis.js
浏览文件 @
71e3a407
...
...
@@ -270,6 +270,7 @@ const plugin = [
'
getPushClientId
'
,
'
onPushMessage
'
,
'
offPushMessage
'
,
'
createPushMessage
'
]
const
apis
=
[
...
...
packages/uni-cli-shared/lib/manifest.js
浏览文件 @
71e3a407
const
path
=
require
(
'
path
'
)
const
{
hasOwn
}
=
require
(
'
./util
'
)
const
{
getJson
,
...
...
@@ -98,6 +101,24 @@ function getH5Options (manifestJson) {
return
h5
}
function
isEnableUniPushV1
(
manifestJson
,
platform
)
{
if
(
!
manifestJson
)
{
manifestJson
=
getManifestJson
()
}
if
(
isEnableUniPushV2
(
manifestJson
,
platform
))
{
return
false
}
if
(
platform
===
'
app-plus
'
)
{
const
platformOptions
=
manifestJson
[
platform
]
const
sdkConfigs
=
platformOptions
&&
platformOptions
.
distribute
&&
platformOptions
.
distribute
.
sdkConfigs
const
push
=
sdkConfigs
&&
sdkConfigs
.
push
if
(
push
&&
hasOwn
(
push
,
'
unipush
'
))
{
return
true
}
}
return
false
}
function
isEnableUniPushV2
(
manifestJson
,
platform
)
{
if
(
!
manifestJson
)
{
manifestJson
=
getManifestJson
()
...
...
@@ -129,6 +150,7 @@ module.exports = {
parseManifestJson
,
getNetworkTimeout
,
getH5Options
,
isEnableUniPushV1
,
isEnableUniPushV2
,
isUniPushOffline
}
packages/uni-cli-shared/lib/platform.js
浏览文件 @
71e3a407
...
...
@@ -168,7 +168,7 @@ module.exports = {
:
'
import
\'
@dcloudio/uni-stat/dist/uni-stat.es.js
\'
;
'
},
getPlatformPush
()
{
if
(
process
.
env
.
UNI_PUSH_V2_OFFLINE
)
{
if
(
process
.
env
.
UNI_PUSH_V2_OFFLINE
||
process
.
env
.
UNI_PUSH_V1
)
{
return
'
;import
\'
@dcloudio/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.plus.es.js
\'
;
'
}
else
if
(
process
.
env
.
UNI_PUSH_V2
)
{
return
'
;import
\'
@dcloudio/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.es.js
\'
;
'
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
71e3a407
...
...
@@ -22,6 +22,7 @@ process.env.UNI_INPUT_DIR = process.env.UNI_INPUT_DIR || path.resolve(process.cw
const
{
getManifestJson
,
isEnableUniPushV1
,
isEnableUniPushV2
,
isUniPushOffline
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/manifest
'
)
...
...
@@ -47,6 +48,8 @@ if (isEnableUniPushV2(manifestJsonObj, process.env.UNI_PLATFORM)) {
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
isUniPushOffline
(
manifestJsonObj
))
{
process
.
env
.
UNI_PUSH_V2_OFFLINE
=
true
}
}
else
if
(
isEnableUniPushV1
(
manifestJsonObj
,
process
.
env
.
UNI_PLATFORM
))
{
process
.
env
.
UNI_PUSH_V1
=
true
}
// 初始化全局插件对象
...
...
src/platforms/app-plus/service/api/device/get-app-authorize-setting.js
浏览文件 @
71e3a407
export
function
getAppAuthorizeSetting
()
{
export
function
getAppAuthorizeSetting
()
{
const
{
getAppAuthorizeSetting
}
=
weex
.
requireModule
(
'
plus
'
)
let
appAuthorizeSetting
=
getAppAuthorizeSetting
()
try
{
if
(
typeof
appAuthorizeSetting
===
'
string
'
)
appAuthorizeSetting
=
JSON
.
parse
(
appAuthorizeSetting
)
if
(
typeof
appAuthorizeSetting
===
'
string
'
)
{
appAuthorizeSetting
=
JSON
.
parse
(
appAuthorizeSetting
)
}
}
catch
(
error
)
{
}
return
appAuthorizeSetting
...
...
src/platforms/app-plus/service/api/device/get-system-setting.js
浏览文件 @
71e3a407
export
function
getSystemSetting
()
{
export
function
getSystemSetting
()
{
const
{
getSystemSetting
}
=
weex
.
requireModule
(
'
plus
'
)
let
systemSetting
=
getSystemSetting
()
try
{
if
(
typeof
systemSetting
===
'
string
'
)
systemSetting
=
JSON
.
parse
(
systemSetting
)
if
(
typeof
systemSetting
===
'
string
'
)
{
systemSetting
=
JSON
.
parse
(
systemSetting
)
}
}
catch
(
error
)
{
}
return
systemSetting
...
...
src/platforms/app-plus/service/api/plugin/push.js
浏览文件 @
71e3a407
import
{
hasOwn
}
from
'
uni-shared
'
import
{
invoke
,
publish
}
from
'
../../bridge
'
import
{
getAppAuthorizeSetting
}
from
'
../device/get-app-authorize-setting
'
let
onPushing
let
isListening
=
false
...
...
@@ -63,3 +69,24 @@ export function offPush (params) {
errMsg
:
'
offPush:ok
'
}
}
export
function
createPushMessage
(
params
,
callbackId
)
{
const
setting
=
getAppAuthorizeSetting
()
if
(
!
hasOwn
(
setting
,
'
notificationAuthorized
'
))
{
return
invoke
(
callbackId
,
{
errMsg
:
'
createPushMessage:fail missing push module
'
})
}
if
(
setting
.
notificationAuthorized
!==
'
authorized
'
)
{
return
invoke
(
callbackId
,
{
errMsg
:
'
createPushMessage:fail
'
+
setting
.
notificationAuthorized
})
}
const
options
=
Object
.
assign
({},
params
)
delete
options
.
content
delete
options
.
payload
plus
.
push
.
createMessage
(
params
.
content
,
params
.
payload
,
options
)
invoke
(
callbackId
,
{
errMsg
:
'
createPushMessage:ok
'
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录