Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenYFan_OHHH
uni-app
提交
0d56f757
U
uni-app
项目概览
ChenYFan_OHHH
/
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,发现更多精彩内容 >>
提交
0d56f757
编写于
7月 15, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): createPushMessage
上级
37e44116
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
213 addition
and
12 deletion
+213
-12
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+1
-0
packages/uni-api/src/protocols/plugin/push.ts
packages/uni-api/src/protocols/plugin/push.ts
+82
-0
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+55
-0
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+1
-0
packages/uni-app-plus/src/service/api/plugin/push.ts
packages/uni-app-plus/src/service/api/plugin/push.ts
+27
-0
packages/uni-cli-shared/src/json/manifest.ts
packages/uni-cli-shared/src/json/manifest.ts
+15
-1
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+1
-1
packages/uni-push/lib/uni.plugin.js
packages/uni-push/lib/uni.plugin.js
+14
-5
packages/uni-push/src/plugin/index.ts
packages/uni-push/src/plugin/index.ts
+15
-5
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+1
-0
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+1
-0
未找到文件。
packages/uni-api/src/index.ts
浏览文件 @
0d56f757
...
...
@@ -98,6 +98,7 @@ export * from './protocols/plugin/getProvider'
export
*
from
'
./protocols/plugin/oauth
'
export
*
from
'
./protocols/plugin/share
'
export
*
from
'
./protocols/plugin/requestPayment
'
export
*
from
'
./protocols/plugin/push
'
// ad
export
*
from
'
./protocols/ad/rewardedVideoAd
'
...
...
packages/uni-api/src/protocols/plugin/push.ts
0 → 100644
浏览文件 @
0d56f757
interface
CreatePushMessageOptions
{
/**
* 是否覆盖上一次提示的消息
* 可取值true或false,true为覆盖,false不覆盖,默认为permission中设置的cover值
* Android - ALL (支持)
* iOS - 5.0+ (不支持): 不支持覆盖消息,只能创建新的消息。
*/
cover
?:
boolean
/**
* 提示消息延迟显示的时间
* 当设备接收到推送消息后,可不立即显示,而是延迟一段时间显示,延迟时间单位为s,默认为0s,立即显示。
*/
delay
?:
number
/**
* 推送消息的图标
* 本地图片地址,相对路径 - 相对于当前页面的host位置,如"a.jpg",注意当前页面为网络地址则不支持; 绝对路径 - 系统绝对路径,如Android平台"/sdcard/logo.png",此类路径通常通过其它5+ API获取的; 扩展相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.jpg"; 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。
* Android - 2.3+ (支持)
* iOS - ALL (不支持): 不支持自定义图片,固定使用应用图标。
*/
icon
?:
string
/**
* 推送消息的提示音
* 显示消息时的播放的提示音,可取值: “system”-表示使用系统通知提示音; “none”-表示不使用提示音; 默认值为“system”。
* Android - 2.3+ (支持)
* iOS - 5.1+ (支持): 当程序在前台运行时,提示音不生效。 注:通常应该设置延迟时间,当程序切换到后台才创建本地推送消息时生效。
*/
sound
?:
'
system
'
|
'
none
'
/**
* 推送消息的标题
* 在系统消息中心显示的通知消息标题,默认值为程序的名称。
* Android - ALL (支持)
* iOS - 5.0+ (不支持): 不支持设置消息的标题,固定为程序的名称。
*/
title
?:
string
// 推送消息的标题
/**
* 消息显示的内容,在系统通知中心中显示的文本内容。
*/
content
:
string
/**
* 消息承载的数据,可根据业务逻辑自定义数据格式。
*/
payload
?:
unknown
/**
* 直达的页面路径
* 支持普通页面和tabBar页面,普通页面支持通过`?param1=value1`方式传参(tabBar页面不支持)
*/
path
?:
string
/**
* 消息上显示的提示时间
* 默认为当前时间,如果延迟显示则使用延时后显示消息的时间。
* Android - ALL (支持)
* iOS - 5.0+ (不支持): 不支持设定消息的显示时间,由系统自动管理消息的创建时间。
*/
when
?:
Date
/**
* 接口调用成功的回调函数
*/
success
?:
(
result
:
unknown
)
=>
void
/**
* 接口调用失败的回调函数
*/
fail
?:
(
result
:
unknown
)
=>
void
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete
?:
(
result
:
unknown
)
=>
void
}
export
const
API_CREATE_PUSH_MESSAGE
=
'
createPushMessage
'
export
type
API_TYPE_CREATE_PUSH_MESSAGE
=
(
options
:
CreatePushMessageOptions
)
=>
void
export
const
CreatePushMessageOptions
:
ApiOptions
<
API_TYPE_CREATE_PUSH_MESSAGE
>
=
{
formatArgs
:
{
content
(
value
)
{
if
(
!
value
)
{
return
`content is required`
}
},
},
}
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
0d56f757
...
...
@@ -11458,6 +11458,10 @@ const ScanCodeOptions = {
},
};
const API_GET_SYSTEM_SETTING = 'getSystemSetting';
const API_GET_APP_AUTHORIZE_SETTING = 'getAppAuthorizeSetting';
const API_GET_STORAGE = 'getStorage';
const GetStorageProtocol = {
key: {
...
...
@@ -12628,6 +12632,17 @@ const RequestPaymentProtocol = {
paySign: String,
};
const API_CREATE_PUSH_MESSAGE = 'createPushMessage';
const CreatePushMessageOptions = {
formatArgs: {
content(value) {
if (!value) {
return `content is required`;
}
},
},
};
const API_CREATE_REWARDED_VIDEO_AD = 'createRewardedVideoAd';
const CreateRewardedVideoAdOptions = {
formatArgs: {
...
...
@@ -14074,6 +14089,28 @@ const setKeepScreenOn = defineAsyncApi(API_SET_KEEP_SCREEN_ON, (options, { resol
resolve();
});
const getSystemSetting = defineSyncApi(API_GET_SYSTEM_SETTING, () => {
const { getSystemSetting } = weex.requireModule('plus');
let systemSetting = getSystemSetting();
try {
if (typeof systemSetting === 'string')
systemSetting = JSON.parse(systemSetting);
}
catch (error) { }
return systemSetting;
});
const getAppAuthorizeSetting = defineSyncApi(API_GET_APP_AUTHORIZE_SETTING, () => {
const { getAppAuthorizeSetting } = weex.requireModule('plus');
let appAuthorizeSetting = getAppAuthorizeSetting();
try {
if (typeof appAuthorizeSetting === 'string')
appAuthorizeSetting = JSON.parse(appAuthorizeSetting);
}
catch (error) { }
return appAuthorizeSetting;
});
const getImageInfo = defineAsyncApi(API_GET_IMAGE_INFO, (options, { resolve, reject }) => {
const path = TEMP_PATH + '/download/';
plus.io.getImageInfo(extend(options, {
...
...
@@ -16736,6 +16773,21 @@ const getUniverifyManager = defineSyncApi(API_GET_UNIVERIFY_MANAGER, () => {
return univerifyManager || (univerifyManager = new UniverifyManager());
});
const createPushMessage = defineAsyncApi(API_CREATE_PUSH_MESSAGE, (opts, { resolve, reject }) => {
const setting = getAppAuthorizeSetting();
if (!hasOwn$1(setting, 'notificationAuthorized')) {
return reject(`missing push module`);
}
if (setting.notificationAuthorized !== 'authorized') {
return reject(setting.notificationAuthorized);
}
const options = extend({}, opts);
delete options.content;
delete options.payload;
plus.push.createMessage(opts.content, opts.payload, options);
resolve();
}, undefined, CreatePushMessageOptions);
const registerRuntime = defineSyncApi('registerRuntime', (runtime) => {
// @ts-expect-error
extend(jsRuntime, runtime);
...
...
@@ -19162,6 +19214,8 @@ var uni$1 = {
setScreenBrightness: setScreenBrightness,
setKeepScreenOn: setKeepScreenOn,
getWindowInfo: getWindowInfo,
getSystemSetting: getSystemSetting,
getAppAuthorizeSetting: getAppAuthorizeSetting,
getImageInfo: getImageInfo,
getVideoInfo: getVideoInfo,
previewImage: previewImage,
...
...
@@ -19227,6 +19281,7 @@ var uni$1 = {
closeAuthView: closeAuthView,
getCheckBoxState: getCheckBoxState,
getUniverifyManager: getUniverifyManager,
createPushMessage: createPushMessage,
registerRuntime: registerRuntime,
share: share,
shareWithSystem: shareWithSystem,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
0d56f757
...
...
@@ -68,6 +68,7 @@ export * from './internal/global'
export
*
from
'
./plugin/getProvider
'
export
*
from
'
./plugin/oauth
'
export
*
from
'
./plugin/push
'
export
*
from
'
./plugin/registerRuntime
'
export
*
from
'
./plugin/share
'
export
*
from
'
./plugin/requestPayment
'
...
...
packages/uni-app-plus/src/service/api/plugin/push.ts
0 → 100644
浏览文件 @
0d56f757
import
{
hasOwn
,
extend
}
from
'
@vue/shared
'
import
{
API_CREATE_PUSH_MESSAGE
,
API_TYPE_CREATE_PUSH_MESSAGE
,
CreatePushMessageOptions
,
defineAsyncApi
,
}
from
'
@dcloudio/uni-api
'
import
{
getAppAuthorizeSetting
}
from
'
../device/getAppAuthorizeSetting
'
export
const
createPushMessage
=
defineAsyncApi
<
API_TYPE_CREATE_PUSH_MESSAGE
>
(
API_CREATE_PUSH_MESSAGE
,
(
opts
,
{
resolve
,
reject
})
=>
{
const
setting
=
getAppAuthorizeSetting
()
if
(
!
hasOwn
(
setting
,
'
notificationAuthorized
'
))
{
return
reject
(
`missing push module`
)
}
if
(
setting
.
notificationAuthorized
!==
'
authorized
'
)
{
return
reject
(
setting
.
notificationAuthorized
)
}
const
options
=
extend
({},
opts
)
delete
(
options
as
any
).
content
delete
options
.
payload
plus
.
push
.
createMessage
(
opts
.
content
,
opts
.
payload
as
string
,
options
)
resolve
()
},
undefined
,
CreatePushMessageOptions
)
packages/uni-cli-shared/src/json/manifest.ts
浏览文件 @
0d56f757
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
extend
}
from
'
@vue/shared
'
import
{
extend
,
hasOwn
}
from
'
@vue/shared
'
import
{
once
,
defaultRpx2Unit
,
...
...
@@ -66,6 +66,20 @@ export function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM) {
)
}
export
function
isEnableUniPushV1
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
if
(
isEnableUniPushV2
(
inputDir
,
platform
))
{
return
false
}
const
manifest
=
parseManifestJsonOnce
(
inputDir
)
if
(
platform
===
'
app
'
)
{
const
push
=
manifest
[
'
app-plus
'
]?.
distribute
?.
sdkConfigs
?.
push
if
(
push
&&
hasOwn
(
push
,
'
unipush
'
))
{
return
true
}
}
return
false
}
export
function
isEnableUniPushV2
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
const
manifest
=
parseManifestJsonOnce
(
inputDir
)
if
(
platform
===
'
app
'
)
{
...
...
packages/uni-components/dist/components.js
浏览文件 @
0d56f757
...
...
@@ -4400,7 +4400,7 @@ var RichText = defineComponent({
if
(
isString
(
nodes
))
{
nodes
=
parseHtml
(
nodes
);
}
return
createVNode
(
resolveComponent
(
"
u-rich-text
"
)
,
{
return
createVNode
(
"
u-rich-text
"
,
{
value
:
normalizeNodes
(
nodes
||
[],
instance
.
root
,
{
defaultFontSize
})
...
...
packages/uni-push/lib/uni.plugin.js
浏览文件 @
0d56f757
...
...
@@ -9,7 +9,8 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var
index
=
()
=>
[
uniCliShared
.
defineUniMainJsPlugin
((
opts
)
=>
{
let
isEnable
=
false
;
let
isEnableV1
=
false
;
let
isEnableV2
=
false
;
let
isOffline
=
false
;
return
{
name
:
'
uni:push
'
,
...
...
@@ -20,10 +21,16 @@ var index = () => [
}
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
;
const
platform
=
process
.
env
.
UNI_PLATFORM
;
isEnable
=
uniCliShared
.
isEnableUniPushV2
(
inputDir
,
platform
);
if
(
!
isEnable
)
{
isEnableV1
=
uniCliShared
.
isEnableUniPushV1
(
inputDir
,
platform
);
isEnableV2
=
uniCliShared
.
isEnableUniPushV2
(
inputDir
,
platform
);
// v1
if
(
isEnableV1
)
{
return
;
}
if
(
!
isEnableV2
)
{
return
;
}
// v2
isOffline
=
platform
===
'
app
'
&&
uniCliShared
.
isUniPushOffline
(
inputDir
);
if
(
isOffline
)
{
return
;
...
...
@@ -36,14 +43,16 @@ var index = () => [
},
resolveId
(
id
)
{
if
(
id
===
'
@dcloudio/uni-push
'
)
{
return
uniCliShared
.
resolveBuiltIn
(
path__default
[
"
default
"
].
join
(
'
@dcloudio/uni-push
'
,
isOffline
?
'
dist/uni-push.plus.es.js
'
:
'
dist/uni-push.es.js
'
));
return
uniCliShared
.
resolveBuiltIn
(
path__default
[
"
default
"
].
join
(
'
@dcloudio/uni-push
'
,
isOffline
||
isEnableV1
?
'
dist/uni-push.plus.es.js
'
:
'
dist/uni-push.es.js
'
));
}
},
transform
(
code
,
id
)
{
if
(
!
opts
.
filter
(
id
))
{
return
;
}
if
(
isEnable
)
{
if
(
isEnable
V1
||
isEnableV2
)
{
return
{
code
:
`import '@dcloudio/uni-push';`
+
code
,
map
:
null
,
...
...
packages/uni-push/src/plugin/index.ts
浏览文件 @
0d56f757
...
...
@@ -2,6 +2,7 @@ import path from 'path'
import
{
defineUniMainJsPlugin
,
isSsr
,
isEnableUniPushV1
,
isEnableUniPushV2
,
isUniPushOffline
,
resolveBuiltIn
,
...
...
@@ -9,7 +10,8 @@ import {
export
default
()
=>
[
defineUniMainJsPlugin
((
opts
)
=>
{
let
isEnable
=
false
let
isEnableV1
=
false
let
isEnableV2
=
false
let
isOffline
=
false
return
{
name
:
'
uni:push
'
,
...
...
@@ -20,10 +22,16 @@ export default () => [
}
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
!
const
platform
=
process
.
env
.
UNI_PLATFORM
!
isEnable
=
isEnableUniPushV2
(
inputDir
,
platform
)
if
(
!
isEnable
)
{
isEnableV1
=
isEnableUniPushV1
(
inputDir
,
platform
)
isEnableV2
=
isEnableUniPushV2
(
inputDir
,
platform
)
// v1
if
(
isEnableV1
)
{
return
}
if
(
!
isEnableV2
)
{
return
}
// v2
isOffline
=
platform
===
'
app
'
&&
isUniPushOffline
(
inputDir
)
if
(
isOffline
)
{
return
...
...
@@ -39,7 +47,9 @@ export default () => [
return
resolveBuiltIn
(
path
.
join
(
'
@dcloudio/uni-push
'
,
isOffline
?
'
dist/uni-push.plus.es.js
'
:
'
dist/uni-push.es.js
'
isOffline
||
isEnableV1
?
'
dist/uni-push.plus.es.js
'
:
'
dist/uni-push.es.js
'
)
)
}
...
...
@@ -48,7 +58,7 @@ export default () => [
if
(
!
opts
.
filter
(
id
))
{
return
}
if
(
isEnable
)
{
if
(
isEnable
V1
||
isEnableV2
)
{
return
{
code
:
`import '@dcloudio/uni-push';`
+
code
,
map
:
null
,
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
0d56f757
...
...
@@ -122,6 +122,7 @@ const NVUE_U_BUILT_IN_TAGS = [
'
u-slider
'
,
'
u-ad
'
,
'
u-ad-draw
'
,
'
u-rich-text
'
,
];
function
isBuiltInComponent
(
tag
)
{
// h5 平台会被转换为 v-uni-
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
0d56f757
...
...
@@ -118,6 +118,7 @@ const NVUE_U_BUILT_IN_TAGS = [
'
u-slider
'
,
'
u-ad
'
,
'
u-ad-draw
'
,
'
u-rich-text
'
,
];
function
isBuiltInComponent
(
tag
)
{
// h5 平台会被转换为 v-uni-
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录