Skip to content

Commit 1ad3146

Browse files
🔄 Sync from private repository - 2026-03-09 09:44:38
1 parent 18d5b5f commit 1ad3146

7 files changed

Lines changed: 352 additions & 1 deletion

File tree

API.en.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,20 @@ Open app settings page
13731373

13741374
---
13751375

1376+
### `app.restartDaemon`
1377+
1378+
![Not Supported](https://img.shields.io/badge/Trigger-None-red)
1379+
1380+
**Signature:** `restartDaemon()`
1381+
1382+
Restart the TrollScript HUD daemon process
1383+
1384+
**Returns:** `boolean`
1385+
1386+
*Whether the restart request was issued successfully*
1387+
1388+
---
1389+
13761390
### `app.list`
13771391

13781392
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)

API.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,20 @@ Ping 主机
13721372

13731373
---
13741374

1375+
### `app.restartDaemon`
1376+
1377+
![Not Supported](https://img.shields.io/badge/Trigger-None-red)
1378+
1379+
**Signature:** `restartDaemon()`
1380+
1381+
重启 TrollScript HUD Daemon 进程
1382+
1383+
**Returns:** `boolean`
1384+
1385+
*是否成功发起重启请求*
1386+
1387+
---
1388+
13751389
### `app.list`
13761390

13771391
![Full Support](https://img.shields.io/badge/Trigger-Full-brightgreen)

TrollScript-Private

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 8d62064482a141a19ebf5cdda034c2785bfaa973
1+
Subproject commit b5ff5d6fc3621149e3fc469bd29b953d96b08b34

npm/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ interface App {
584584
*/
585585
openSettings(): boolean;
586586

587+
/**
588+
* 重启 TrollScript HUD Daemon 进程
589+
* @returns 是否成功发起重启请求
590+
*/
591+
restartDaemon(): boolean;
592+
587593
/**
588594
* 获取所有已安装应用列表 (TrollStore 权限)
589595
* @returns 应用信息数组,包含 bundleIdentifier, name, version, type 等字段

templates/API/App.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ App 模块提供了应用相关的操作功能,包括获取应用信息、打
1212
- [API 参考](#api-参考)
1313
- [应用信息](#应用信息)
1414
- [URL 操作](#url-操作)
15+
- [Daemon 控制](#daemon-控制)
1516
- [日志管理](#日志管理)
1617
- [崩溃报告](#崩溃报告)
1718
- [性能监控](#性能监控)
@@ -83,6 +84,47 @@ app.open('shortcuts://run-shortcut?name=MyShortcut');
8384

8485
---
8586

87+
### Daemon 控制
88+
89+
#### `app.restartDaemon()`
90+
重启 TrollScript HUD Daemon 进程。**返回:** `boolean`
91+
92+
```javascript
93+
const ok = app.restartDaemon();
94+
console.log(`重启请求: ${ok ? '已发送' : '失败'}`);
95+
```
96+
97+
> 说明:
98+
> - 这是一个 **App 侧能力**,用于请求重启 TrollScript 的 HUD/Daemon 进程。
99+
> - 该方法会确保 `schedulerEnabled = true` 后再发起重启流程。
100+
> - 适合在脚本里做“自恢复”或更新后重启守护进程。
101+
102+
```javascript
103+
// 示例:重启 Daemon 后等待恢复
104+
function restartDaemonAndWait() {
105+
console.log('准备重启 Daemon...');
106+
107+
const requested = app.restartDaemon();
108+
if (!requested) {
109+
console.error('重启请求发送失败');
110+
return false;
111+
}
112+
113+
console.log('重启请求已发送,等待守护进程恢复...');
114+
115+
// 简单等待 watchdog / daemon 拉起
116+
setTimeout(() => {
117+
console.log('Daemon 应该已经开始恢复,可继续后续逻辑');
118+
}, 2000);
119+
120+
return true;
121+
}
122+
123+
restartDaemonAndWait();
124+
```
125+
126+
---
127+
86128
### 用户交互
87129

88130
#### `app.vibrate()`

templates/API/Location.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ console.log(results[0]);
3636
#### `location.requestAccess()`
3737
请求定位权限。**返回:** `void`
3838

39+
#### `location.requestAccessAsync()`
40+
异步请求定位权限。**返回:** `Promise<void>`
41+
3942
#### `location.getAccessStatus()`
4043
获取权限状态。**返回:** `'authorized'` | `'denied'` | `'restricted'` | `'notDetermined'` | `'unknown'`
4144

@@ -57,18 +60,27 @@ console.log(results[0]);
5760

5861
**注意:** 需要 TrollStore 权限
5962

63+
#### `location.setLocationServicesEnabledAsync(enabled)`
64+
异步开关系统定位服务。**参数:** `enabled` (boolean) **返回:** `Promise<{ success, enabled?, message? }>`
65+
6066
#### `location.toggleLocationServices()`
6167
切换定位服务状态。**返回:** `{ success, enabled?, message? }`
6268

6369
**注意:** 需要 TrollStore 权限
6470

71+
#### `location.toggleLocationServicesAsync()`
72+
异步切换定位服务状态。**返回:** `Promise<{ success, enabled?, message? }>`
73+
6574
---
6675

6776
### 位置获取
6877

6978
#### `location.getCurrent()`
7079
获取当前位置。**返回:** `{ lat, lng, alt, course, speed, accuracy, timestamp } | null`
7180

81+
#### `location.getCurrentAsync()`
82+
异步获取当前位置。**返回:** `Promise<{ lat, lng, alt, course, speed, accuracy, timestamp } | null>`
83+
7284
**返回值字段:**
7385
- `lat` - 纬度
7486
- `lng` - 经度
@@ -107,6 +119,9 @@ if (results.length > 0) {
107119
}
108120
```
109121

122+
#### `location.geocodeAsync(address)`
123+
异步地址转坐标。**参数:** `address` (string) **返回:** `Promise<[{ lat, lng, name }]>`
124+
110125
#### `location.reverseGeocode(lat, lng, locale?)`
111126
坐标转地址。**参数:** `lat` (number), `lng` (number), `locale` (string, 可选) **返回:** `[{ name, country, locality, ... }]`
112127

@@ -133,6 +148,9 @@ const enResults = location.reverseGeocode(39.9, 116.4, 'en_US');
133148
const zhResults = location.reverseGeocode(39.9, 116.4, 'zh_CN');
134149
```
135150

151+
#### `location.reverseGeocodeAsync(lat, lng, locale?)`
152+
异步坐标转地址。**参数:** `lat` (number), `lng` (number), `locale` (string, 可选) **返回:** `Promise<[{ name, country, locality, ... }]>`
153+
136154
---
137155

138156
## 完整示例

0 commit comments

Comments
 (0)