deeke-script-app 1.5.0 → 1.5.2
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/@deekeScript/@type/Class/Rect.d.ts +2 -0
- package/@deekeScript/@type/interface/ForegroundServiceBridge.d.ts +31 -0
- package/@deekeScript/@type/interface/NotificationBridge.d.ts +5 -0
- package/deekeScript.json +3 -3
- package/package.json +1 -1
- package/test/2.js +6 -0
- package/test/foreground.js +23 -0
- package/test/notification.js +4 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
declare global {
|
|
3
|
+
var ForegroundServiceBridge: foregroundServiceBridge;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface foregroundServiceBridge {
|
|
7
|
+
/**
|
|
8
|
+
* 开启前台服务
|
|
9
|
+
*/
|
|
10
|
+
public startService(): void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 注册执行的方法(启动服务前设置)
|
|
14
|
+
* @param register 注册监听
|
|
15
|
+
*/
|
|
16
|
+
public register(func: Function): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 前台服务标题和内容设置(启动服务前设置)
|
|
20
|
+
* @param title 前台服务标题
|
|
21
|
+
* @param content 前台服务内容
|
|
22
|
+
*/
|
|
23
|
+
public setContent(title: string, content: string):void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 关闭服务
|
|
27
|
+
*/
|
|
28
|
+
public stopService(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { };
|
|
@@ -18,6 +18,11 @@ interface notificationBridge {
|
|
|
18
18
|
onNotification: (packageName: string, title: string, text: string) => void,
|
|
19
19
|
onNotificationRemoved: (packageName: string, title: string, text: string) => void
|
|
20
20
|
): void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 关闭服务
|
|
24
|
+
*/
|
|
25
|
+
public stopService(): void;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export { };
|
package/deekeScript.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "测试测试",
|
|
3
3
|
"icon": "images/test/app.png",
|
|
4
4
|
"head": "images/test/app.png",
|
|
5
5
|
"settingTopBg": "images/test/setting-top.png",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
},
|
|
12
12
|
"groups": [
|
|
13
13
|
{
|
|
14
|
-
"title": "DY
|
|
14
|
+
"title": "DY·万能引流测试",
|
|
15
15
|
"titleHidden": false,
|
|
16
16
|
"hidden": false,
|
|
17
17
|
"methods": [
|
|
18
18
|
{
|
|
19
|
-
"title": "推荐营销",
|
|
19
|
+
"title": "推荐营销2",
|
|
20
20
|
"icon": "images/test/finger.png",
|
|
21
21
|
"jsFile": "script/task/dy.js",
|
|
22
22
|
"settingPage": {
|
package/package.json
CHANGED
package/test/2.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
let close = false;
|
|
3
|
+
ForegroundServiceBridge.setContent('测试', '前台服务');
|
|
4
|
+
ForegroundServiceBridge.register(()=>{
|
|
5
|
+
console.log('前台服务启动成功');
|
|
6
|
+
let m = setInterval(() => {
|
|
7
|
+
console.log('正在执行任务...');
|
|
8
|
+
if(close){
|
|
9
|
+
clearInterval(m);
|
|
10
|
+
}
|
|
11
|
+
}, 3000);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
ForegroundServiceBridge.startService();
|
|
15
|
+
|
|
16
|
+
let i = 0;
|
|
17
|
+
setInterval(() => {
|
|
18
|
+
console.log('正在监听中...');
|
|
19
|
+
if(i++ >= 1){
|
|
20
|
+
ForegroundServiceBridge.stopService();
|
|
21
|
+
close = true;
|
|
22
|
+
}
|
|
23
|
+
}, 10000);
|
package/test/notification.js
CHANGED
|
@@ -11,8 +11,12 @@ if (!root) {
|
|
|
11
11
|
NotificationBridge.startService();
|
|
12
12
|
NotificationBridge.startListening((packageName, title, text) => {
|
|
13
13
|
console.log('收到通知', packageName, title, text);
|
|
14
|
+
if(text == '关闭'){
|
|
15
|
+
NotificationBridge.stopService();
|
|
16
|
+
}
|
|
14
17
|
}, (packageName, title, text) => {
|
|
15
18
|
console.log('通知监听已关闭', packageName, title, text);
|
|
19
|
+
|
|
16
20
|
});
|
|
17
21
|
|
|
18
22
|
NotificationBridge.startService();
|