Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
0ea54487
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0ea54487
编写于
7月 14, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(push): support path
上级
584ec63d
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
244 addition
and
44 deletion
+244
-44
packages/uni-api/src/service/plugin/push.ts
packages/uni-api/src/service/plugin/push.ts
+10
-4
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+9
-4
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+8
-4
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+9
-4
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+9
-4
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+9
-4
packages/uni-mp-lark/dist/uni.api.esm.js
packages/uni-mp-lark/dist/uni.api.esm.js
+9
-4
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+9
-4
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+9
-4
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+9
-4
packages/uni-push/dist/uni-push.es.js
packages/uni-push/dist/uni-push.es.js
+46
-0
packages/uni-push/dist/uni-push.plus.es.js
packages/uni-push/dist/uni-push.plus.es.js
+36
-0
packages/uni-push/src/index.ts
packages/uni-push/src/index.ts
+12
-0
packages/uni-push/src/plus.ts
packages/uni-push/src/plus.ts
+3
-0
packages/uni-push/src/route.ts
packages/uni-push/src/route.ts
+48
-0
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+9
-4
未找到文件。
packages/uni-api/src/service/plugin/push.ts
浏览文件 @
0ea54487
...
...
@@ -54,12 +54,17 @@ export function invokePushCallback(
cidErrMsg
=
args
.
errMsg
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
)
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
:
OnPushMessageSuccess
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
})
})
}
onPushMessageCallbacks
[
i
](
msg
)
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
...
...
@@ -106,6 +111,7 @@ export const getPushClientId = defineAsyncApi(
interface
OnPushMessageSuccess
{
type
:
'
click
'
|
'
receive
'
data
:
unknown
stopped
?:
boolean
}
type
OnPushMessageCallback
=
(
result
:
OnPushMessageSuccess
)
=>
void
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
0ea54487
...
...
@@ -11096,12 +11096,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks(cid, args.errMsg);
}
else if (args.type === 'pushMsg') {
onPushMessageCallbacks.forEach((callback) =>
{
c
allback(
{
for (let i = 0; i < onPushMessageCallbacks.length; i++)
{
c
onst msg =
{
type: 'receive',
data: normalizePushMessage(args.message),
});
});
};
onPushMessageCallbacks[i](msg);
if (msg.stopped) {
// 消息被中断,比如页面直达的 push 信息
break;
}
}
}
else if (args.type === 'click') {
onPushMessageCallbacks.forEach((callback) => {
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
0ea54487
...
...
@@ -4625,12 +4625,16 @@ function invokePushCallback(args) {
cidErrMsg = args.errMsg;
invokeGetPushCidCallbacks(cid, args.errMsg);
} else if (args.type === "pushMsg") {
onPushMessageCallbacks.forEach((callback) =>
{
c
allback(
{
for (let i = 0; i < onPushMessageCallbacks.length; i++)
{
c
onst msg =
{
type: "receive",
data: normalizePushMessage(args.message)
});
});
};
onPushMessageCallbacks[i](msg);
if (msg.stopped) {
break;
}
}
} else if (args.type === "click") {
onPushMessageCallbacks.forEach((callback) => {
callback({
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-lark/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -635,12 +635,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
packages/uni-push/dist/uni-push.es.js
浏览文件 @
0ea54487
...
...
@@ -100,6 +100,41 @@ e?.onClose(t);
var
GtPush
=
/*@__PURE__*/
getDefaultExportFromCjs
(
gtpushMin
);
function
initPushRoute
()
{
// @ts-expect-error
uni
.
onPushMessage
((
res
)
=>
{
if
(
res
.
data
&&
res
.
data
.
path
)
{
if
(
res
.
type
===
'
click
'
)
{
const
url
=
res
.
data
.
path
;
// 优先使用 navigateTo
uni
.
navigateTo
({
url
,
fail
(
result
)
{
// 说明是 tabBar 页面,必须使用 switchTab
if
(
result
.
errMsg
.
indexOf
(
'
tabbar
'
))
{
uni
.
switchTab
({
url
,
});
}
},
});
}
else
if
(
res
.
type
===
'
receive
'
)
{
// 仅 App 端
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
push
)
{
// 创建通知栏,并屏蔽消息的继续传递
plus
.
push
.
createMessage
(
res
.
data
.
content
,
JSON
.
stringify
(
res
.
data
.
payload
),
{
title
:
res
.
data
.
title
,
path
:
res
.
data
.
path
,
});
// 内部属性,停止传播
res
.
stopped
=
true
;
}
}
}
});
}
// if (process.env.UNI_PUSH_DEBUG) {
// GtPush.setDebugMode(true)
// }
...
...
@@ -152,4 +187,15 @@ else {
});
},
});
initPushRoute
();
// 不用条件编译。App端仍需监听
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
push
)
{
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
});
});
}
}
packages/uni-push/dist/uni-push.plus.es.js
浏览文件 @
0ea54487
function
initPushRoute
()
{
// @ts-expect-error
uni
.
onPushMessage
((
res
)
=>
{
if
(
res
.
data
&&
res
.
data
.
path
)
{
if
(
res
.
type
===
'
click
'
)
{
const
url
=
res
.
data
.
path
;
// 优先使用 navigateTo
uni
.
navigateTo
({
url
,
fail
(
result
)
{
// 说明是 tabBar 页面,必须使用 switchTab
if
(
result
.
errMsg
.
indexOf
(
'
tabbar
'
))
{
uni
.
switchTab
({
url
,
});
}
},
});
}
else
if
(
res
.
type
===
'
receive
'
)
{
// 仅 App 端
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
push
)
{
// 创建通知栏,并屏蔽消息的继续传递
plus
.
push
.
createMessage
(
res
.
data
.
content
,
JSON
.
stringify
(
res
.
data
.
payload
),
{
title
:
res
.
data
.
title
,
path
:
res
.
data
.
path
,
});
// 内部属性,停止传播
res
.
stopped
=
true
;
}
}
}
});
}
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
enabled
'
,
});
initPushRoute
();
Promise
.
resolve
().
then
(()
=>
{
plus
.
push
.
setAutoNotification
&&
plus
.
push
.
setAutoNotification
(
false
);
const
info
=
plus
.
push
.
getClientInfo
();
...
...
packages/uni-push/src/index.ts
浏览文件 @
0ea54487
import
GtPush
from
'
../lib/gtpush-min
'
import
{
initPushRoute
}
from
'
./route
'
// if (process.env.UNI_PUSH_DEBUG) {
// GtPush.setDebugMode(true)
...
...
@@ -53,4 +54,15 @@ if (!appid) {
})
},
})
initPushRoute
()
// 不用条件编译。App端仍需监听
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
push
)
{
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
})
})
}
}
packages/uni-push/src/plus.ts
浏览文件 @
0ea54487
import
{
initPushRoute
}
from
'
./route
'
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
enabled
'
,
})
initPushRoute
()
Promise
.
resolve
().
then
(()
=>
{
plus
.
push
.
setAutoNotification
&&
plus
.
push
.
setAutoNotification
(
false
)
const
info
=
plus
.
push
.
getClientInfo
()
...
...
packages/uni-push/src/route.ts
0 → 100644
浏览文件 @
0ea54487
interface
OnPushMessageSuccess
{
type
:
'
click
'
|
'
receive
'
data
:
{
title
:
string
content
:
string
payload
:
unknown
forceNotification
?:
boolean
path
?:
string
}
stopped
?:
boolean
}
export
function
initPushRoute
()
{
// @ts-expect-error
uni
.
onPushMessage
((
res
:
OnPushMessageSuccess
)
=>
{
if
(
res
.
data
&&
res
.
data
.
path
)
{
if
(
res
.
type
===
'
click
'
)
{
const
url
=
res
.
data
.
path
// 优先使用 navigateTo
uni
.
navigateTo
({
url
,
fail
(
result
)
{
// 说明是 tabBar 页面,必须使用 switchTab
if
(
result
.
errMsg
.
indexOf
(
'
tabbar
'
))
{
uni
.
switchTab
({
url
,
})
}
},
})
}
else
if
(
res
.
type
===
'
receive
'
)
{
// 仅 App 端
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
push
)
{
// 创建通知栏,并屏蔽消息的继续传递
plus
.
push
.
createMessage
(
res
.
data
.
content
,
JSON
.
stringify
(
res
.
data
.
payload
),
{
title
:
res
.
data
.
title
,
path
:
res
.
data
.
path
,
}
as
any
)
// 内部属性,停止传播
res
.
stopped
=
true
}
}
}
})
}
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
0ea54487
...
...
@@ -671,12 +671,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
c
allback
(
{
for
(
let
i
=
0
;
i
<
onPushMessageCallbacks
.
length
;
i
++
)
{
c
onst
msg
=
{
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
),
});
});
};
onPushMessageCallbacks
[
i
](
msg
);
if
(
msg
.
stopped
)
{
// 消息被中断,比如页面直达的 push 信息
break
;
}
}
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录