Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
ece6800f
U
uni-app
项目概览
菜鸟程序猿_c
/
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,发现更多精彩内容 >>
提交
ece6800f
编写于
3月 24, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
chore: merge
上级
e7f68709
40c50f15
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
375 addition
and
178 deletion
+375
-178
packages/uni-api/src/service/plugin/push.ts
packages/uni-api/src/service/plugin/push.ts
+34
-11
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+23
-9
packages/uni-cli-shared/src/json/manifest.ts
packages/uni-cli-shared/src/json/manifest.ts
+9
-7
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+22
-9
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+23
-9
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+23
-9
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+23
-9
packages/uni-mp-lark/dist/uni.api.esm.js
packages/uni-mp-lark/dist/uni.api.esm.js
+23
-9
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+23
-9
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+23
-9
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+23
-9
packages/uni-push/dist/uni-push.es.js
packages/uni-push/dist/uni-push.es.js
+39
-26
packages/uni-push/dist/uni-push.plus.es.js
packages/uni-push/dist/uni-push.plus.es.js
+7
-0
packages/uni-push/lib/gtpush-min.js
packages/uni-push/lib/gtpush-min.js
+6
-6
packages/uni-push/lib/uni.plugin.js
packages/uni-push/lib/uni.plugin.js
+6
-9
packages/uni-push/src/index.ts
packages/uni-push/src/index.ts
+32
-20
packages/uni-push/src/plugin/index.ts
packages/uni-push/src/plugin/index.ts
+6
-9
packages/uni-push/src/plus.ts
packages/uni-push/src/plus.ts
+7
-0
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+23
-9
未找到文件。
packages/uni-api/src/service/plugin/push.ts
浏览文件 @
ece6800f
...
...
@@ -4,6 +4,7 @@ import { getApiCallbacks } from '../../helpers/api/callback'
interface
OnPushCidCallback
{
type
:
'
clientId
'
cid
:
string
errMsg
?:
string
}
interface
OnPushLineStateCallback
{
...
...
@@ -16,20 +17,41 @@ interface OnPushMsgCallback {
message
:
unknown
}
let
cid
:
string
=
''
interface
OnPushClickCallback
{
type
:
'
click
'
message
:
unknown
}
let
cid
:
string
|
undefined
let
cidErrMsg
:
string
|
undefined
function
normalizePushMessage
(
message
:
unknown
)
{
try
{
return
JSON
.
parse
(
message
as
string
)
}
catch
(
e
:
any
)
{}
return
message
}
/**
* @private
* @param args
*/
export
function
invokePushCallback
(
args
:
OnPushCidCallback
|
OnPushLineStateCallback
|
OnPushMsgCallback
args
:
|
OnPushCidCallback
|
OnPushLineStateCallback
|
OnPushMsgCallback
|
OnPushClickCallback
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
invokeGetPushCidCallbacks
(
cid
)
cidErrMsg
=
args
.
errMsg
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
)
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
})
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
})
})
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
})
})
}
}
...
...
@@ -38,11 +60,11 @@ interface GetPushCidOptions {
success
?:
OnPushMessageSuccess
}
const
getPushCidCallbacks
:
((
cid
?:
string
)
=>
void
)[]
=
[]
const
getPushCidCallbacks
:
((
cid
?:
string
,
errMsg
?:
string
)
=>
void
)[]
=
[]
function
invokeGetPushCidCallbacks
(
cid
?:
string
)
{
function
invokeGetPushCidCallbacks
(
cid
?:
string
,
errMsg
?:
string
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
)
callback
(
cid
,
errMsg
)
})
getPushCidCallbacks
.
length
=
0
}
...
...
@@ -55,23 +77,24 @@ export function getPushCid(args: GetPushCidOptions) {
const
hasSuccess
=
isFunction
(
success
)
const
hasFail
=
isFunction
(
fail
)
const
hasComplete
=
isFunction
(
complete
)
getPushCidCallbacks
.
push
((
cid
?:
string
)
=>
{
getPushCidCallbacks
.
push
((
cid
?:
string
,
errMsg
?:
string
)
=>
{
let
res
:
Record
<
string
,
unknown
>
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
}
hasSuccess
&&
success
(
res
)
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
}
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
}
hasFail
&&
fail
(
res
)
}
hasComplete
&&
complete
(
res
)
})
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
))
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
))
}
}
interface
OnPushMessageSuccess
{
type
:
'
click
'
|
'
receive
'
data
:
unknown
}
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
ece6800f
...
...
@@ -11057,7 +11057,15 @@ const getLaunchOptionsSync = defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
return getLaunchOptions();
});
let cid = '';
let cid;
let cidErrMsg;
function normalizePushMessage(message) {
try {
return JSON.parse(message);
}
catch (e) { }
return message;
}
/**
* @private
* @param args
...
...
@@ -11065,18 +11073,24 @@ let cid = '';
function invokePushCallback(args) {
if (args.type === 'clientId') {
cid = args.cid;
invokeGetPushCidCallbacks(cid);
cidErrMsg = args.errMsg;
invokeGetPushCidCallbacks(cid, args.errMsg);
}
else if (args.type === 'pushMsg') {
onPushMessageCallbacks.forEach((callback) => {
callback({ data: args.message });
callback({ type: 'receive', data: normalizePushMessage(args.message) });
});
}
else if (args.type === 'click') {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: 'click', data: normalizePushMessage(args.message) });
});
}
}
const getPushCidCallbacks = [];
function invokeGetPushCidCallbacks(cid) {
function invokeGetPushCidCallbacks(cid
, errMsg
) {
getPushCidCallbacks.forEach((callback) => {
callback(cid);
callback(cid
, errMsg
);
});
getPushCidCallbacks.length = 0;
}
...
...
@@ -11088,20 +11102,20 @@ function getPushCid(args) {
const hasSuccess = isFunction(success);
const hasFail = isFunction(fail);
const hasComplete = isFunction(complete);
getPushCidCallbacks.push((cid) => {
getPushCidCallbacks.push((cid
, errMsg
) => {
let res;
if (cid) {
res = { errMsg: 'getPushCid:ok', cid };
hasSuccess && success(res);
}
else {
res = { errMsg: 'getPushCid:fail' };
res = { errMsg: 'getPushCid:fail'
+ (errMsg ? ' ' + errMsg : '')
};
hasFail && fail(res);
}
hasComplete && complete(res);
});
if (
cid
) {
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid));
if (
typeof cid !== 'undefined'
) {
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid
, cidErrMsg
));
}
}
const onPushMessageCallbacks = [];
...
...
packages/uni-cli-shared/src/json/manifest.ts
浏览文件 @
ece6800f
...
...
@@ -66,19 +66,21 @@ export function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM) {
)
}
export
function
getUniPush
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
export
function
isEnableUniPushV2
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
const
manifest
=
parseManifestJsonOnce
(
inputDir
)
return
extend
(
{},
manifest
.
unipush
,
manifest
[
platform
]
&&
manifest
[
platform
].
unipush
)
if
(
platform
===
'
app
'
)
{
return
(
manifest
[
'
app-plus
'
]?.
distribute
?.
sdkConfigs
?.
push
?.
unipush
?.
version
==
'
2
'
)
}
return
manifest
[
platform
]?.
unipush
?.
enable
===
true
}
export
function
isUniPushOffline
(
inputDir
:
string
)
{
const
manifest
=
parseManifestJsonOnce
(
inputDir
)
return
(
manifest
?.[
'
app-plus
'
]?.
distribute
?.
sdkConfigs
?.
push
?.
unipush
?.
enabl
e
===
manifest
[
'
app-plus
'
]?.
distribute
?.
sdkConfigs
?.
push
?.
unipush
?.
offlin
e
===
true
)
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
ece6800f
...
...
@@ -4551,21 +4551,34 @@ const API_GET_LAUNCH_OPTIONS_SYNC = "getLaunchOptionsSync";
const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
return getLaunchOptions();
});
let cid = "";
let cid;
let cidErrMsg;
function normalizePushMessage(message) {
try {
return JSON.parse(message);
} catch (e2) {
}
return message;
}
function invokePushCallback(args) {
if (args.type === "clientId") {
cid = args.cid;
invokeGetPushCidCallbacks(cid);
cidErrMsg = args.errMsg;
invokeGetPushCidCallbacks(cid, args.errMsg);
} else if (args.type === "pushMsg") {
onPushMessageCallbacks.forEach((callback) => {
callback({ data: args.message });
callback({ type: "receive", data: normalizePushMessage(args.message) });
});
} else if (args.type === "click") {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: "click", data: normalizePushMessage(args.message) });
});
}
}
const getPushCidCallbacks = [];
function invokeGetPushCidCallbacks(cid2) {
function invokeGetPushCidCallbacks(cid2
, errMsg
) {
getPushCidCallbacks.forEach((callback) => {
callback(cid2);
callback(cid2
, errMsg
);
});
getPushCidCallbacks.length = 0;
}
...
...
@@ -4577,19 +4590,19 @@ function getPushCid(args) {
const hasSuccess = isFunction(success);
const hasFail = isFunction(fail);
const hasComplete = isFunction(complete);
getPushCidCallbacks.push((cid2) => {
getPushCidCallbacks.push((cid2
, errMsg
) => {
let res;
if (cid2) {
res = { errMsg: "getPushCid:ok", cid: cid2 };
hasSuccess && success(res);
} else {
res = { errMsg: "getPushCid:fail" };
res = { errMsg: "getPushCid:fail"
+ (errMsg ? " " + errMsg : "")
};
hasFail && fail(res);
}
hasComplete && complete(res);
});
if (
cid
) {
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid));
if (
typeof cid !== "undefined"
) {
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid
, cidErrMsg
));
}
}
const onPushMessageCallbacks = [];
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-lark/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -569,7 +569,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -577,18 +585,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -600,20 +614,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
packages/uni-push/dist/uni-push.es.js
浏览文件 @
ece6800f
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-push/dist/uni-push.plus.es.js
浏览文件 @
ece6800f
...
...
@@ -7,6 +7,13 @@ Promise.resolve().then(() => {
cid
:
info
.
clientid
,
});
}
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
});
});
plus
.
push
.
addEventListener
(
'
receive
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
...
...
packages/uni-push/lib/gtpush-min.js
浏览文件 @
ece6800f
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-push/lib/uni.plugin.js
浏览文件 @
ece6800f
...
...
@@ -23,21 +23,18 @@ var index = () => [
}
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
;
const
platform
=
process
.
env
.
UNI_PLATFORM
;
isOffline
=
platform
===
'
app
'
&&
uniCliShared
.
isUniPushOffline
(
inputDir
);
if
(
isOffline
)
{
isEnable
=
true
;
isEnable
=
uniCliShared
.
isEnableUniPushV2
(
inputDir
,
platform
);
if
(
!
isEnable
)
{
return
;
}
const
{
appid
,
enable
,
debug
}
=
uniCliShared
.
getUniPush
(
inputDir
,
platform
);
isEnable
=
appid
&&
enable
===
true
;
if
(
!
isEnable
)
{
isOffline
=
platform
===
'
app
'
&&
uniCliShared
.
isUniPushOffline
(
inputDir
);
if
(
isOffline
)
{
return
;
}
debugPush
(
'
appid
'
,
appid
,
'
deubg
'
,
debug
);
debugPush
(
'
deubg
'
,
debug__default
[
"
default
"
]
);
return
{
define
:
{
'
process.env.UNI_PUSH_APP_ID
'
:
JSON
.
stringify
(
appid
),
'
process.env.UNI_PUSH_DEBUG
'
:
!!
debug
,
'
process.env.UNI_PUSH_DEBUG
'
:
!!
debug__default
[
"
default
"
],
},
};
},
...
...
packages/uni-push/src/index.ts
浏览文件 @
ece6800f
...
...
@@ -4,27 +4,39 @@ if (process.env.UNI_PUSH_DEBUG) {
GtPush
.
setDebugMode
(
true
)
}
GtPush
.
init
({
appid
:
process
.
env
.
UNI_PUSH_APP_ID
!
,
onClientId
:
(
res
)
=>
{
const
appid
=
process
.
env
.
UNI_APP_ID
!
if
(
!
appid
)
{
Promise
.
resolve
().
then
((
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
clientId
'
,
cid
:
res
.
cid
,
cid
:
''
,
errMsg
:
'
manifest.json->appid is required
'
,
})
},
onlineState
:
(
res
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
lineState
'
,
online
:
res
.
online
,
})
},
onPushMsg
:
(
res
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
pushMsg
'
,
message
:
res
.
message
,
})
},
})
})
}
else
{
GtPush
.
init
({
appid
,
onClientId
:
(
res
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
clientId
'
,
cid
:
res
.
cid
,
})
},
onlineState
:
(
res
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
lineState
'
,
online
:
res
.
online
,
})
},
onPushMsg
:
(
res
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
pushMsg
'
,
message
:
res
.
message
,
})
},
})
}
packages/uni-push/src/plugin/index.ts
浏览文件 @
ece6800f
...
...
@@ -3,7 +3,7 @@ import debug from 'debug'
import
{
defineUniMainJsPlugin
,
isSsr
,
getUniPush
,
isEnableUniPushV2
,
isUniPushOffline
,
resolveBuiltIn
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -22,20 +22,17 @@ export default () => [
}
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
!
const
platform
=
process
.
env
.
UNI_PLATFORM
!
isOffline
=
platform
===
'
app
'
&&
isUniPushOffline
(
inputDir
)
if
(
isOffline
)
{
isEnable
=
true
isEnable
=
isEnableUniPushV2
(
inputDir
,
platform
)
if
(
!
isEnable
)
{
return
}
const
{
appid
,
enable
,
debug
}
=
getUniPush
(
inputDir
,
platform
)
isEnable
=
appid
&&
enable
===
true
if
(
!
isEnable
)
{
isOffline
=
platform
===
'
app
'
&&
isUniPushOffline
(
inputDir
)
if
(
isOffline
)
{
return
}
debugPush
(
'
appid
'
,
appid
,
'
deubg
'
,
debug
)
debugPush
(
'
deubg
'
,
debug
)
return
{
define
:
{
'
process.env.UNI_PUSH_APP_ID
'
:
JSON
.
stringify
(
appid
),
'
process.env.UNI_PUSH_DEBUG
'
:
!!
debug
,
},
}
...
...
packages/uni-push/src/plus.ts
浏览文件 @
ece6800f
...
...
@@ -7,6 +7,13 @@ Promise.resolve().then(() => {
cid
:
info
.
clientid
,
})
}
plus
.
push
.
addEventListener
(
'
click
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
type
:
'
click
'
,
message
:
result
,
})
})
plus
.
push
.
addEventListener
(
'
receive
'
,
(
result
)
=>
{
// @ts-expect-error
uni
.
invokePushCallback
({
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
ece6800f
...
...
@@ -605,7 +605,15 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
emitter
.
emit
(
name
,
...
args
);
},
EmitProtocol
);
let
cid
=
''
;
let
cid
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
try
{
return
JSON
.
parse
(
message
);
}
catch
(
e
)
{
}
return
message
;
}
/**
* @private
* @param args
...
...
@@ -613,18 +621,24 @@ let cid = '';
function
invokePushCallback
(
args
)
{
if
(
args
.
type
===
'
clientId
'
)
{
cid
=
args
.
cid
;
invokeGetPushCidCallbacks
(
cid
);
cidErrMsg
=
args
.
errMsg
;
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
);
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
data
:
args
.
message
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
});
}
}
const
getPushCidCallbacks
=
[];
function
invokeGetPushCidCallbacks
(
cid
)
{
function
invokeGetPushCidCallbacks
(
cid
,
errMsg
)
{
getPushCidCallbacks
.
forEach
((
callback
)
=>
{
callback
(
cid
);
callback
(
cid
,
errMsg
);
});
getPushCidCallbacks
.
length
=
0
;
}
...
...
@@ -636,20 +650,20 @@ function getPushCid(args) {
const
hasSuccess
=
isFunction
(
success
);
const
hasFail
=
isFunction
(
fail
);
const
hasComplete
=
isFunction
(
complete
);
getPushCidCallbacks
.
push
((
cid
)
=>
{
getPushCidCallbacks
.
push
((
cid
,
errMsg
)
=>
{
let
res
;
if
(
cid
)
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
cid
};
hasSuccess
&&
success
(
res
);
}
else
{
res
=
{
errMsg
:
'
getPushCid:fail
'
};
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
hasFail
&&
fail
(
res
);
}
hasComplete
&&
complete
(
res
);
});
if
(
cid
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
));
if
(
typeof
cid
!==
'
undefined
'
)
{
Promise
.
resolve
().
then
(()
=>
invokeGetPushCidCallbacks
(
cid
,
cidErrMsg
));
}
}
const
onPushMessageCallbacks
=
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录