@doubao-apps/ai 0.0.33 → 0.0.34
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/README.md +1 -32
- package/dist/733.js +7 -15
- package/dist/cli.js +1 -1
- package/dist/manifest.json +3 -11
- package/dist/skills/doubao-apps-dev/SKILL.md +103 -227
- package/dist/skills/doubao-apps-dev/references/examples/common-patterns.md +80 -66
- package/dist/skills/doubao-apps-dev/references/examples/component-basics.md +24 -3
- package/dist/skills/doubao-apps-dev/references/examples/component-recipes.md +71 -0
- package/dist/skills/doubao-apps-dev/references/examples/open-api-recipes.md +203 -0
- package/dist/skills/doubao-apps-dev/references/guides/component-development.md +66 -42
- package/dist/skills/doubao-apps-dev/references/guides/expired-widget.md +113 -0
- package/dist/skills/doubao-apps-dev/references/guides/mcp-ui.md +275 -0
- package/dist/skills/doubao-apps-dev/references/guides/performance-optimization.md +24 -7
- package/dist/skills/doubao-apps-dev/references/reference/components-quick-ref.md +18 -7
- package/dist/skills/doubao-apps-dev/references/reference/framework-api-quick-ref.md +125 -107
- package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +136 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +257 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md +326 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/04-/345/255/230/345/202/250.md +284 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/05-/350/267/257/347/224/261.md +162 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/06-/344/272/244/344/272/222.md +290 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/07-/350/276/223/345/205/245.md +63 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +124 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/09-/345/252/222/344/275/223.md +192 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/10-/344/270/232/345/212/241/350/203/275/345/212/233.md +431 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/11-/347/231/273/345/275/225.md +110 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/12-/346/224/257/344/273/230.md +224 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/13-/346/225/260/346/215/256/345/210/206/346/236/220.md +43 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/14-/350/223/235/347/211/231.md +598 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/15-wi-fi.md +210 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +87 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/17-ibeacon.md +97 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/18-/347/275/227/347/233/230.md +78 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +86 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +87 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +102 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/22-/347/237/255/344/277/241.md +40 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/23-/346/227/240/351/232/234/347/242/215.md +40 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/24-/345/237/272/347/241/200/344/277/241/346/201/257.md +86 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +63 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/26-/346/227/245/345/216/206.md +95 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/27-/345/211/252/350/264/264/346/235/277.md +64 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/28-/350/201/224/347/263/273/344/272/272.md +101 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/29-/345/212/240/345/257/206.md +43 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/30-/347/224/265/350/257/235.md +36 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/31-/346/211/253/347/240/201.md +58 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/32-/345/261/217/345/271/225.md +136 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/33-/351/234/207/345/212/250.md +62 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +73 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api/README.md +34 -0
- package/dist/skills/doubao-apps-dev/references/reference/open-api.md +384 -2
- package/dist/skills/doubao-apps-dev/references/rules/dos-and-donts.md +44 -27
- package/dist/skills/h5-to-doubao/SKILL.md +8 -4
- package/dist/skills/weixin-to-doubao/SKILL.md +8 -4
- package/dist/skills/weixin-to-doubao/assets/migration-checklist-template.md +1 -1
- package/package.json +2 -3
- package/dist/contexts/doubao-apps-dev/AGENTS.md +0 -300
- package/dist/contexts/doubao-apps-dev/CLAUDE.md +0 -31
- package/dist/contexts/doubao-apps-dev/references/examples/common-patterns.md +0 -589
- package/dist/contexts/doubao-apps-dev/references/examples/component-basics.md +0 -526
- package/dist/contexts/doubao-apps-dev/references/guides/best-practices.md +0 -571
- package/dist/contexts/doubao-apps-dev/references/guides/component-development.md +0 -891
- package/dist/contexts/doubao-apps-dev/references/guides/performance-optimization.md +0 -402
- package/dist/contexts/doubao-apps-dev/references/guides/troubleshooting.md +0 -287
- package/dist/contexts/doubao-apps-dev/references/reference/components-quick-ref.md +0 -103
- package/dist/contexts/doubao-apps-dev/references/reference/framework-api-quick-ref.md +0 -550
- package/dist/contexts/doubao-apps-dev/references/reference/open-api/README.md +0 -8
- package/dist/contexts/doubao-apps-dev/references/reference/open-api.md +0 -11
- package/dist/contexts/doubao-apps-dev/references/rules/dos-and-donts.md +0 -467
package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# Open API: 系统
|
|
2
|
+
|
|
3
|
+
宿主基础信息、窗口信息和系统设置。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [getWindowInfoSync](#getwindowinfosync) | 获取窗口信息。<br><br>同步 API。 |
|
|
12
|
+
| [getSystemSetting](#getsystemsetting) | 获取设备设置。 |
|
|
13
|
+
| [getAppBaseInfoSync](#getappbaseinfosync) | 获取应用基础信息。<br><br>同步 API。 |
|
|
14
|
+
| [getWindowInfo](#getwindowinfo) | 获取窗口信息。 |
|
|
15
|
+
| [getAppBaseInfo](#getappbaseinfo) | 获取应用基础信息。 |
|
|
16
|
+
| [ThemeChangeListener](#themechangelistener) | 应用主题变化事件监听函数。<br><br>返回 void,不是 Promise。 |
|
|
17
|
+
| [onThemeChange](#onthemechange) | 监听应用主题变化。 |
|
|
18
|
+
|
|
19
|
+
## API 详情
|
|
20
|
+
|
|
21
|
+
<a id="getwindowinfosync"></a>
|
|
22
|
+
### getWindowInfoSync()
|
|
23
|
+
|
|
24
|
+
获取窗口信息。
|
|
25
|
+
|
|
26
|
+
## 代码示例
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { getWindowInfoSync } from '@doubao-apps/framework/api';
|
|
30
|
+
|
|
31
|
+
const result = getWindowInfoSync();
|
|
32
|
+
|
|
33
|
+
console.log(result.windowWidth, result.windowHeight);
|
|
34
|
+
console.log(result.safeArea?.top, result.screenTop);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 入参
|
|
38
|
+
|
|
39
|
+
无入参。
|
|
40
|
+
|
|
41
|
+
## 返回值
|
|
42
|
+
|
|
43
|
+
返回窗口尺寸、状态栏高度和安全区域等信息,字段见 GetWindowInfoResult。
|
|
44
|
+
|
|
45
|
+
|字段名|类型|说明|
|
|
46
|
+
|---|---|---|
|
|
47
|
+
|pixelRatio|`number`|设备像素比|
|
|
48
|
+
|safeArea|`WindowSafeArea`|安全区域|
|
|
49
|
+
|safeArea.bottom|`number`|安全区域右下角纵坐标|
|
|
50
|
+
|safeArea.height|`number`|安全区域高度|
|
|
51
|
+
|safeArea.left|`number`|安全区域左上角横坐标|
|
|
52
|
+
|safeArea.right|`number`|安全区域右下角横坐标|
|
|
53
|
+
|safeArea.top|`number`|安全区域左上角纵坐标|
|
|
54
|
+
|safeArea.width|`number`|安全区域宽度|
|
|
55
|
+
|screenHeight|`number`|屏幕高度|
|
|
56
|
+
|screenTop|`number`|窗口上边缘的 y 值|
|
|
57
|
+
|screenWidth|`number`|屏幕宽度|
|
|
58
|
+
|statusBarHeight|`number`|状态栏高度|
|
|
59
|
+
|windowHeight|`number`|可使用窗口高度|
|
|
60
|
+
|windowWidth|`number`|可使用窗口宽度|
|
|
61
|
+
|
|
62
|
+
<a id="getsystemsetting"></a>
|
|
63
|
+
### getSystemSetting()
|
|
64
|
+
|
|
65
|
+
获取设备设置。
|
|
66
|
+
|
|
67
|
+
## 代码示例
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { getSystemSetting } from '@doubao-apps/framework/api';
|
|
71
|
+
|
|
72
|
+
const result = getSystemSetting();
|
|
73
|
+
|
|
74
|
+
console.log(result.bluetoothEnabled, result.locationEnabled);
|
|
75
|
+
console.log(result.wifiEnabled, result.deviceOrientation);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 入参
|
|
79
|
+
|
|
80
|
+
无入参。
|
|
81
|
+
|
|
82
|
+
## 返回值
|
|
83
|
+
|
|
84
|
+
返回蓝牙、定位、Wi-Fi 系统开关和设备方向等字段,见 GetSystemSettingResult。
|
|
85
|
+
|
|
86
|
+
|字段名|类型|说明|
|
|
87
|
+
|---|---|---|
|
|
88
|
+
|bluetoothEnabled|`boolean`|蓝牙的系统开关|
|
|
89
|
+
|deviceOrientation|`DeviceOrientation`|设备方向|
|
|
90
|
+
|locationEnabled|`boolean`|地理位置的系统开关|
|
|
91
|
+
|wifiEnabled|`boolean`|Wi-Fi 的系统开关|
|
|
92
|
+
|
|
93
|
+
**类型说明**
|
|
94
|
+
|
|
95
|
+
- `DeviceOrientation`: `"portrait" | "landscape"`
|
|
96
|
+
|
|
97
|
+
<a id="getappbaseinfosync"></a>
|
|
98
|
+
### getAppBaseInfoSync()
|
|
99
|
+
|
|
100
|
+
获取应用基础信息。
|
|
101
|
+
|
|
102
|
+
## 代码示例
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { getAppBaseInfoSync } from '@doubao-apps/framework/api';
|
|
106
|
+
|
|
107
|
+
const result = getAppBaseInfoSync();
|
|
108
|
+
|
|
109
|
+
console.log(result.language, result.SDKVersion, result.theme);
|
|
110
|
+
console.log(result.host?.appId, result.enableDebug);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 入参
|
|
114
|
+
|
|
115
|
+
无入参。
|
|
116
|
+
|
|
117
|
+
## 返回值
|
|
118
|
+
|
|
119
|
+
返回 SDK 版本、调试开关、宿主信息、语言和主题等字段,见 GetAppBaseInfoResult。
|
|
120
|
+
|
|
121
|
+
|字段名|类型|说明|
|
|
122
|
+
|---|---|---|
|
|
123
|
+
|enableDebug|`boolean`|是否已打开调试|
|
|
124
|
+
|host|`AppBaseInfoHost`|当前豆包 App运行的宿主环境|
|
|
125
|
+
|host.appId|`string`|宿主 app 对应的 appId|
|
|
126
|
+
|language|`string`|当前语言|
|
|
127
|
+
|SDKVersion|`string`|客户端基础库版本|
|
|
128
|
+
|theme|`"light" \| "dark"`|当前主题|
|
|
129
|
+
|version|`string`|宿主版本号|
|
|
130
|
+
|
|
131
|
+
<a id="getwindowinfo"></a>
|
|
132
|
+
### getWindowInfo()
|
|
133
|
+
|
|
134
|
+
获取窗口信息。
|
|
135
|
+
|
|
136
|
+
## 代码示例
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { getWindowInfo } from '@doubao-apps/framework/api';
|
|
140
|
+
|
|
141
|
+
const result = await getWindowInfo();
|
|
142
|
+
|
|
143
|
+
console.log(result.windowWidth, result.windowHeight);
|
|
144
|
+
console.log(result.safeArea?.top, result.screenTop);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 入参
|
|
148
|
+
|
|
149
|
+
无入参。
|
|
150
|
+
|
|
151
|
+
## 返回值
|
|
152
|
+
|
|
153
|
+
返回窗口尺寸、状态栏高度和安全区域等信息,字段见 GetWindowInfoResult。
|
|
154
|
+
|
|
155
|
+
|字段名|类型|说明|
|
|
156
|
+
|---|---|---|
|
|
157
|
+
|pixelRatio|`number`|设备像素比|
|
|
158
|
+
|safeArea|`WindowSafeArea`|安全区域|
|
|
159
|
+
|safeArea.bottom|`number`|安全区域右下角纵坐标|
|
|
160
|
+
|safeArea.height|`number`|安全区域高度|
|
|
161
|
+
|safeArea.left|`number`|安全区域左上角横坐标|
|
|
162
|
+
|safeArea.right|`number`|安全区域右下角横坐标|
|
|
163
|
+
|safeArea.top|`number`|安全区域左上角纵坐标|
|
|
164
|
+
|safeArea.width|`number`|安全区域宽度|
|
|
165
|
+
|screenHeight|`number`|屏幕高度|
|
|
166
|
+
|screenTop|`number`|窗口上边缘的 y 值|
|
|
167
|
+
|screenWidth|`number`|屏幕宽度|
|
|
168
|
+
|statusBarHeight|`number`|状态栏高度|
|
|
169
|
+
|windowHeight|`number`|可使用窗口高度|
|
|
170
|
+
|windowWidth|`number`|可使用窗口宽度|
|
|
171
|
+
|
|
172
|
+
<a id="getappbaseinfo"></a>
|
|
173
|
+
### getAppBaseInfo()
|
|
174
|
+
|
|
175
|
+
获取应用基础信息。
|
|
176
|
+
|
|
177
|
+
## 代码示例
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { getAppBaseInfo } from '@doubao-apps/framework/api';
|
|
181
|
+
|
|
182
|
+
const result = await getAppBaseInfo();
|
|
183
|
+
|
|
184
|
+
console.log(result.language, result.SDKVersion, result.theme);
|
|
185
|
+
console.log(result.host?.appId, result.enableDebug);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 入参
|
|
189
|
+
|
|
190
|
+
无入参。
|
|
191
|
+
|
|
192
|
+
## 返回值
|
|
193
|
+
|
|
194
|
+
返回 SDK 版本、调试开关、宿主信息、语言和主题等字段,见 GetAppBaseInfoResult。
|
|
195
|
+
|
|
196
|
+
|字段名|类型|说明|
|
|
197
|
+
|---|---|---|
|
|
198
|
+
|enableDebug|`boolean`|是否已打开调试|
|
|
199
|
+
|host|`AppBaseInfoHost`|当前豆包 App运行的宿主环境|
|
|
200
|
+
|host.appId|`string`|宿主 app 对应的 appId|
|
|
201
|
+
|language|`string`|当前语言|
|
|
202
|
+
|SDKVersion|`string`|客户端基础库版本|
|
|
203
|
+
|theme|`"light" \| "dark"`|当前主题|
|
|
204
|
+
|version|`string`|宿主版本号|
|
|
205
|
+
|
|
206
|
+
<a id="themechangelistener"></a>
|
|
207
|
+
### ThemeChangeListener()
|
|
208
|
+
|
|
209
|
+
应用主题变化事件监听函数。
|
|
210
|
+
|
|
211
|
+
## 代码示例
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// 暂无代码示例
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 入参
|
|
218
|
+
|
|
219
|
+
|参数名|类型|必填|说明|
|
|
220
|
+
|---|---|---|---|
|
|
221
|
+
|theme|`AppTheme`|是|切换后的应用主题|
|
|
222
|
+
|
|
223
|
+
**类型说明**
|
|
224
|
+
|
|
225
|
+
- `AppTheme`: `"light" | "dark"`
|
|
226
|
+
|
|
227
|
+
## 返回值
|
|
228
|
+
|
|
229
|
+
返回 `void`。
|
|
230
|
+
|
|
231
|
+
<a id="onthemechange"></a>
|
|
232
|
+
### onThemeChange()
|
|
233
|
+
|
|
234
|
+
监听应用主题变化。
|
|
235
|
+
|
|
236
|
+
当用户在系统设置或宿主内切换浅色、深色主题时触发。回调参数中的 `theme` 表示切换后的主题,可与
|
|
237
|
+
getAppBaseInfo 返回的 `theme` 字段配合使用。
|
|
238
|
+
|
|
239
|
+
## 代码示例
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { onThemeChange } from '@doubao-apps/framework/api';
|
|
243
|
+
|
|
244
|
+
const offThemeChange = onThemeChange(({ theme }) => {
|
|
245
|
+
console.log('当前主题:', theme);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
offThemeChange();
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## 入参
|
|
252
|
+
|
|
253
|
+
无入参。
|
|
254
|
+
|
|
255
|
+
## 返回值
|
|
256
|
+
|
|
257
|
+
返回取消当前监听函数的函数。
|
package/dist/skills/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Open API: 定位
|
|
2
|
+
|
|
3
|
+
获取设备当前的地理位置信息。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [LocationChangeListener](#locationchangelistener) | LocationChangeListener API。<br><br>返回 void,不是 Promise。 |
|
|
12
|
+
| [LocationChangeErrorListener](#locationchangeerrorlistener) | LocationChangeErrorListener API。<br><br>返回 void,不是 Promise。 |
|
|
13
|
+
| [getLocation](#getlocation) | 获取设备当前的地理位置信息。 |
|
|
14
|
+
| [chooseLocation](#chooselocation) | 打开地图选择位置。 |
|
|
15
|
+
| [openLocation](#openlocation) | 使用地图查看位置。 |
|
|
16
|
+
| [startLocationUpdate](#startlocationupdate) | 开始接收位置更新。 |
|
|
17
|
+
| [stopLocationUpdate](#stoplocationupdate) | 停止接收位置更新。 |
|
|
18
|
+
| [onLocationChange](#onlocationchange) | 注册地理位置变化回调。<br><br>返回 void,不是 Promise。 |
|
|
19
|
+
| [offLocationChange](#offlocationchange) | 取消注册地理位置变化回调。<br><br>返回 void,不是 Promise。 |
|
|
20
|
+
| [onLocationChangeError](#onlocationchangeerror) | 注册位置更新异常回调。<br><br>返回 void,不是 Promise。 |
|
|
21
|
+
| [offLocationChangeError](#offlocationchangeerror) | 取消注册位置更新异常回调。<br><br>返回 void,不是 Promise。 |
|
|
22
|
+
|
|
23
|
+
## API 详情
|
|
24
|
+
|
|
25
|
+
<a id="locationchangelistener"></a>
|
|
26
|
+
### LocationChangeListener()
|
|
27
|
+
|
|
28
|
+
LocationChangeListener API。
|
|
29
|
+
|
|
30
|
+
## 代码示例
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// 暂无代码示例
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 入参
|
|
37
|
+
|
|
38
|
+
|参数名|类型|必填|说明|
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
|accuracy|`number`|否|位置精确度,单位 m|
|
|
41
|
+
|altitude|`number`|否|高度,单位 m|
|
|
42
|
+
|city|`string`|否|城市信息|
|
|
43
|
+
|district|`string`|否|区县信息|
|
|
44
|
+
|horizontalAccuracy|`number`|否|水平精度,单位 m|
|
|
45
|
+
|latitude|`number`|是|纬度|
|
|
46
|
+
|longitude|`number`|是|经度|
|
|
47
|
+
|province|`string`|否|省份信息|
|
|
48
|
+
|speed|`number`|否|速度,单位 m/s|
|
|
49
|
+
|verticalAccuracy|`number`|否|垂直精度,单位 m|
|
|
50
|
+
|
|
51
|
+
## 返回值
|
|
52
|
+
|
|
53
|
+
返回 `void`。
|
|
54
|
+
|
|
55
|
+
<a id="locationchangeerrorlistener"></a>
|
|
56
|
+
### LocationChangeErrorListener()
|
|
57
|
+
|
|
58
|
+
LocationChangeErrorListener API。
|
|
59
|
+
|
|
60
|
+
## 代码示例
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// 暂无代码示例
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 入参
|
|
67
|
+
|
|
68
|
+
|参数名|类型|必填|说明|
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
|errCode|`number`|否|错误码|
|
|
71
|
+
|errMsg|`string`|是|错误信息|
|
|
72
|
+
|
|
73
|
+
## 返回值
|
|
74
|
+
|
|
75
|
+
返回 `void`。
|
|
76
|
+
|
|
77
|
+
<a id="getlocation"></a>
|
|
78
|
+
### getLocation()
|
|
79
|
+
|
|
80
|
+
获取设备当前的地理位置信息。
|
|
81
|
+
|
|
82
|
+
## 代码示例
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { getLocation } from '@doubao-apps/framework/api';
|
|
86
|
+
|
|
87
|
+
async function fetchLocation() {
|
|
88
|
+
try {
|
|
89
|
+
const locationData = await getLocation();
|
|
90
|
+
console.log('纬度:', locationData.latitude);
|
|
91
|
+
console.log('经度:', locationData.longitude);
|
|
92
|
+
console.log('时间戳:', locationData.timestamp);
|
|
93
|
+
console.log('行进速度:', locationData.speed);
|
|
94
|
+
console.log('定位精度:', locationData.accuracy);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('获取位置失败:', error);
|
|
97
|
+
// 处理错误,例如提示用户开启定位权限
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fetchLocation();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 入参
|
|
105
|
+
|
|
106
|
+
|参数名|类型|必填|说明|
|
|
107
|
+
|---|---|---|---|
|
|
108
|
+
|maxCacheMs|`number`|否|缓存时间,单位毫秒,默认为0|
|
|
109
|
+
|mode|`number`|否|定位模式<br>0:低功耗<br>1:仅设备<br>2:高精度(默认)|
|
|
110
|
+
|source|`string`|否|调用业务方|
|
|
111
|
+
|timeoutMs|`number`|否|超时时间,单位毫秒,默认 30000|
|
|
112
|
+
|
|
113
|
+
## 返回值
|
|
114
|
+
|
|
115
|
+
返回一个 Promise,成功时解析为包含地理位置信息的对象,包含:
|
|
116
|
+
- `latitude`: number - 纬度。
|
|
117
|
+
- `longitude`: number - 经度。
|
|
118
|
+
- `timestamp`: string - 时间戳。
|
|
119
|
+
- `speed`: number - 行进速度,单位:米/秒。
|
|
120
|
+
- `accuracy`: number - 定位精度,单位:米。
|
|
121
|
+
参考 GetLocationResponse。
|
|
122
|
+
|
|
123
|
+
|字段名|类型|说明|
|
|
124
|
+
|---|---|---|
|
|
125
|
+
|accuracy|`number`|定位精度,单位:米|
|
|
126
|
+
|latitude|`number`|纬度|
|
|
127
|
+
|longitude|`number`|经度|
|
|
128
|
+
|speed|`number`|行进速度,单位:米/秒|
|
|
129
|
+
|timestamp|`string`|时间戳|
|
|
130
|
+
|
|
131
|
+
<a id="chooselocation"></a>
|
|
132
|
+
### chooseLocation()
|
|
133
|
+
|
|
134
|
+
打开地图选择位置。
|
|
135
|
+
|
|
136
|
+
## 代码示例
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { chooseLocation } from '@doubao-apps/framework/api';
|
|
140
|
+
|
|
141
|
+
const { name, latitude, longitude } = await chooseLocation();
|
|
142
|
+
|
|
143
|
+
console.log(name, latitude, longitude);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 入参
|
|
147
|
+
|
|
148
|
+
|参数名|类型|必填|说明|
|
|
149
|
+
|---|---|---|---|
|
|
150
|
+
|latitude|`number`|否|目标地纬度|
|
|
151
|
+
|longitude|`number`|否|目标地经度|
|
|
152
|
+
|
|
153
|
+
## 返回值
|
|
154
|
+
|
|
155
|
+
返回 `Promise<ChooseLocationResponse>`。
|
|
156
|
+
|
|
157
|
+
|字段名|类型|说明|
|
|
158
|
+
|---|---|---|
|
|
159
|
+
|address|`string`|地址详情|
|
|
160
|
+
|latitude|`number`|纬度,GCJ-02 坐标系|
|
|
161
|
+
|longitude|`number`|经度,GCJ-02 坐标系|
|
|
162
|
+
|name|`string`|位置名称|
|
|
163
|
+
|
|
164
|
+
<a id="openlocation"></a>
|
|
165
|
+
### openLocation()
|
|
166
|
+
|
|
167
|
+
使用地图查看位置。
|
|
168
|
+
|
|
169
|
+
## 代码示例
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { openLocation } from '@doubao-apps/framework/api';
|
|
173
|
+
|
|
174
|
+
await openLocation({
|
|
175
|
+
latitude: 39.908823,
|
|
176
|
+
longitude: 116.39747,
|
|
177
|
+
name: '目的地',
|
|
178
|
+
scale: 15
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 入参
|
|
183
|
+
|
|
184
|
+
|参数名|类型|必填|说明|
|
|
185
|
+
|---|---|---|---|
|
|
186
|
+
|address|`string`|否|地址详情|
|
|
187
|
+
|latitude|`number`|是|纬度|
|
|
188
|
+
|longitude|`number`|是|经度|
|
|
189
|
+
|name|`string`|否|位置名称|
|
|
190
|
+
|scale|`number`|否|缩放比例,范围 5 ~ 18|
|
|
191
|
+
|
|
192
|
+
## 返回值
|
|
193
|
+
|
|
194
|
+
返回 `Promise<object>`。
|
|
195
|
+
|
|
196
|
+
<a id="startlocationupdate"></a>
|
|
197
|
+
### startLocationUpdate()
|
|
198
|
+
|
|
199
|
+
开始接收位置更新。
|
|
200
|
+
|
|
201
|
+
## 代码示例
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { startLocationUpdate } from '@doubao-apps/framework/api';
|
|
205
|
+
|
|
206
|
+
await startLocationUpdate({ type: 'gcj02' });
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 入参
|
|
210
|
+
|
|
211
|
+
|参数名|类型|必填|说明|
|
|
212
|
+
|---|---|---|---|
|
|
213
|
+
|type|`"wgs84" \| "gcj02"`|否|坐标系类型,支持 wgs84 或 gcj02|
|
|
214
|
+
|
|
215
|
+
## 返回值
|
|
216
|
+
|
|
217
|
+
返回 `Promise<object>`。
|
|
218
|
+
|
|
219
|
+
<a id="stoplocationupdate"></a>
|
|
220
|
+
### stopLocationUpdate()
|
|
221
|
+
|
|
222
|
+
停止接收位置更新。
|
|
223
|
+
|
|
224
|
+
## 代码示例
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import { stopLocationUpdate } from '@doubao-apps/framework/api';
|
|
228
|
+
|
|
229
|
+
await stopLocationUpdate();
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## 入参
|
|
233
|
+
|
|
234
|
+
无入参。
|
|
235
|
+
|
|
236
|
+
## 返回值
|
|
237
|
+
|
|
238
|
+
返回 `Promise<object>`。
|
|
239
|
+
|
|
240
|
+
<a id="onlocationchange"></a>
|
|
241
|
+
### onLocationChange()
|
|
242
|
+
|
|
243
|
+
注册地理位置变化回调。
|
|
244
|
+
|
|
245
|
+
## 代码示例
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { onLocationChange } from '@doubao-apps/framework/api';
|
|
249
|
+
|
|
250
|
+
onLocationChange(({ latitude, longitude }) => {
|
|
251
|
+
console.log(latitude, longitude);
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## 入参
|
|
256
|
+
|
|
257
|
+
无入参。
|
|
258
|
+
|
|
259
|
+
## 返回值
|
|
260
|
+
|
|
261
|
+
返回 `void`。
|
|
262
|
+
|
|
263
|
+
<a id="offlocationchange"></a>
|
|
264
|
+
### offLocationChange()
|
|
265
|
+
|
|
266
|
+
取消注册地理位置变化回调。
|
|
267
|
+
|
|
268
|
+
## 代码示例
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { offLocationChange } from '@doubao-apps/framework/api';
|
|
272
|
+
|
|
273
|
+
offLocationChange();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## 入参
|
|
277
|
+
|
|
278
|
+
无入参。
|
|
279
|
+
|
|
280
|
+
## 返回值
|
|
281
|
+
|
|
282
|
+
返回 `void`。
|
|
283
|
+
|
|
284
|
+
<a id="onlocationchangeerror"></a>
|
|
285
|
+
### onLocationChangeError()
|
|
286
|
+
|
|
287
|
+
注册位置更新异常回调。
|
|
288
|
+
|
|
289
|
+
## 代码示例
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
import { onLocationChangeError } from '@doubao-apps/framework/api';
|
|
293
|
+
|
|
294
|
+
onLocationChangeError(({ errMsg, errCode }) => {
|
|
295
|
+
console.log(errMsg, errCode);
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## 入参
|
|
300
|
+
|
|
301
|
+
无入参。
|
|
302
|
+
|
|
303
|
+
## 返回值
|
|
304
|
+
|
|
305
|
+
返回 `void`。
|
|
306
|
+
|
|
307
|
+
<a id="offlocationchangeerror"></a>
|
|
308
|
+
### offLocationChangeError()
|
|
309
|
+
|
|
310
|
+
取消注册位置更新异常回调。
|
|
311
|
+
|
|
312
|
+
## 代码示例
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
import { offLocationChangeError } from '@doubao-apps/framework/api';
|
|
316
|
+
|
|
317
|
+
offLocationChangeError();
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## 入参
|
|
321
|
+
|
|
322
|
+
无入参。
|
|
323
|
+
|
|
324
|
+
## 返回值
|
|
325
|
+
|
|
326
|
+
返回 `void`。
|