@dcloudio/uni-push 3.0.0-alpha-3080720230627002 → 3.0.0-alpha-3081120230719001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/uni-push-v1.plus.es.js +44 -0
- package/lib/uni.plugin.js +18 -3
- package/package.json +2 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
function initPushNotification() {
|
2
|
+
// 仅 App 端
|
3
|
+
if (typeof plus !== 'undefined' && plus.push) {
|
4
|
+
plus.globalEvent.addEventListener('newPath', ({ path }) => {
|
5
|
+
if (!path) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
// 指定的页面为当前页面
|
9
|
+
const pages = getCurrentPages();
|
10
|
+
const currentPage = pages[pages.length - 1];
|
11
|
+
if (currentPage &&
|
12
|
+
currentPage.$page &&
|
13
|
+
currentPage.$page.fullPath === path) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
|
17
|
+
uni.navigateTo({
|
18
|
+
url: path,
|
19
|
+
fail(res) {
|
20
|
+
if (res.errMsg.indexOf('tabbar') > -1) {
|
21
|
+
uni.switchTab({
|
22
|
+
url: path,
|
23
|
+
fail(res) {
|
24
|
+
console.error(res.errMsg);
|
25
|
+
},
|
26
|
+
});
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
console.error(res.errMsg);
|
30
|
+
}
|
31
|
+
},
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
// @ts-expect-error
|
38
|
+
uni.invokePushCallback({
|
39
|
+
type: 'enabled',
|
40
|
+
offline: true,
|
41
|
+
});
|
42
|
+
Promise.resolve().then(() => {
|
43
|
+
initPushNotification();
|
44
|
+
});
|
package/lib/uni.plugin.js
CHANGED
@@ -12,6 +12,7 @@ var index = () => [
|
|
12
12
|
let isEnableV1 = false;
|
13
13
|
let isEnableV2 = false;
|
14
14
|
let isOffline = false;
|
15
|
+
let configModulePush = false;
|
15
16
|
return {
|
16
17
|
name: 'uni:push',
|
17
18
|
enforce: 'pre',
|
@@ -23,6 +24,7 @@ var index = () => [
|
|
23
24
|
const platform = process.env.UNI_PLATFORM;
|
24
25
|
isEnableV1 = uniCliShared.isEnableUniPushV1(inputDir, platform);
|
25
26
|
isEnableV2 = uniCliShared.isEnableUniPushV2(inputDir, platform);
|
27
|
+
configModulePush = uniCliShared.hasPushModule(inputDir);
|
26
28
|
// v1
|
27
29
|
if (isEnableV1) {
|
28
30
|
return;
|
@@ -43,15 +45,28 @@ var index = () => [
|
|
43
45
|
},
|
44
46
|
resolveId(id) {
|
45
47
|
if (id === '@dcloudio/uni-push') {
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
let file = 'dist/uni-push.es.js';
|
49
|
+
if (isEnableV1) {
|
50
|
+
file = 'dist/uni-push-v1.plus.es.js';
|
51
|
+
}
|
52
|
+
else if (isOffline) {
|
53
|
+
file = 'dist/uni-push.plus.es.js';
|
54
|
+
}
|
55
|
+
return uniCliShared.resolveBuiltIn(path__default.default.join('@dcloudio/uni-push', file));
|
49
56
|
}
|
50
57
|
},
|
51
58
|
transform(code, id) {
|
52
59
|
if (!opts.filter(id)) {
|
53
60
|
return;
|
54
61
|
}
|
62
|
+
// 如果启用了v1,但是没有配置module.push,不需要注入
|
63
|
+
if (isEnableV1 && !configModulePush) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
// 如果启用了v2+offline,但是没有配置module.push,不需要注入
|
67
|
+
if (isEnableV2 && isOffline && !configModulePush) {
|
68
|
+
return;
|
69
|
+
}
|
55
70
|
if (isEnableV1 || isEnableV2) {
|
56
71
|
return {
|
57
72
|
code: `import '@dcloudio/uni-push';` + code,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dcloudio/uni-push",
|
3
|
-
"version": "3.0.0-alpha-
|
3
|
+
"version": "3.0.0-alpha-3081120230719001",
|
4
4
|
"description": "@dcloudio/uni-push",
|
5
5
|
"main": "lib/uni-push.js",
|
6
6
|
"module": "lib/uni-push.js",
|
@@ -20,6 +20,6 @@
|
|
20
20
|
},
|
21
21
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
22
22
|
"dependencies": {
|
23
|
-
"@dcloudio/uni-cli-shared": "3.0.0-alpha-
|
23
|
+
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3081120230719001"
|
24
24
|
}
|
25
25
|
}
|