@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.
Files changed (69) hide show
  1. package/README.md +1 -32
  2. package/dist/733.js +7 -15
  3. package/dist/cli.js +1 -1
  4. package/dist/manifest.json +3 -11
  5. package/dist/skills/doubao-apps-dev/SKILL.md +103 -227
  6. package/dist/skills/doubao-apps-dev/references/examples/common-patterns.md +80 -66
  7. package/dist/skills/doubao-apps-dev/references/examples/component-basics.md +24 -3
  8. package/dist/skills/doubao-apps-dev/references/examples/component-recipes.md +71 -0
  9. package/dist/skills/doubao-apps-dev/references/examples/open-api-recipes.md +203 -0
  10. package/dist/skills/doubao-apps-dev/references/guides/component-development.md +66 -42
  11. package/dist/skills/doubao-apps-dev/references/guides/expired-widget.md +113 -0
  12. package/dist/skills/doubao-apps-dev/references/guides/mcp-ui.md +275 -0
  13. package/dist/skills/doubao-apps-dev/references/guides/performance-optimization.md +24 -7
  14. package/dist/skills/doubao-apps-dev/references/reference/components-quick-ref.md +18 -7
  15. package/dist/skills/doubao-apps-dev/references/reference/framework-api-quick-ref.md +125 -107
  16. package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +136 -0
  17. package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +257 -0
  18. package/dist/skills/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md +326 -0
  19. package/dist/skills/doubao-apps-dev/references/reference/open-api/04-/345/255/230/345/202/250.md +284 -0
  20. package/dist/skills/doubao-apps-dev/references/reference/open-api/05-/350/267/257/347/224/261.md +162 -0
  21. package/dist/skills/doubao-apps-dev/references/reference/open-api/06-/344/272/244/344/272/222.md +290 -0
  22. package/dist/skills/doubao-apps-dev/references/reference/open-api/07-/350/276/223/345/205/245.md +63 -0
  23. package/dist/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +124 -0
  24. package/dist/skills/doubao-apps-dev/references/reference/open-api/09-/345/252/222/344/275/223.md +192 -0
  25. 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
  26. package/dist/skills/doubao-apps-dev/references/reference/open-api/11-/347/231/273/345/275/225.md +110 -0
  27. package/dist/skills/doubao-apps-dev/references/reference/open-api/12-/346/224/257/344/273/230.md +224 -0
  28. 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
  29. package/dist/skills/doubao-apps-dev/references/reference/open-api/14-/350/223/235/347/211/231.md +598 -0
  30. package/dist/skills/doubao-apps-dev/references/reference/open-api/15-wi-fi.md +210 -0
  31. 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
  32. package/dist/skills/doubao-apps-dev/references/reference/open-api/17-ibeacon.md +97 -0
  33. package/dist/skills/doubao-apps-dev/references/reference/open-api/18-/347/275/227/347/233/230.md +78 -0
  34. 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
  35. package/dist/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +87 -0
  36. 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
  37. package/dist/skills/doubao-apps-dev/references/reference/open-api/22-/347/237/255/344/277/241.md +40 -0
  38. package/dist/skills/doubao-apps-dev/references/reference/open-api/23-/346/227/240/351/232/234/347/242/215.md +40 -0
  39. 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
  40. package/dist/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +63 -0
  41. package/dist/skills/doubao-apps-dev/references/reference/open-api/26-/346/227/245/345/216/206.md +95 -0
  42. package/dist/skills/doubao-apps-dev/references/reference/open-api/27-/345/211/252/350/264/264/346/235/277.md +64 -0
  43. package/dist/skills/doubao-apps-dev/references/reference/open-api/28-/350/201/224/347/263/273/344/272/272.md +101 -0
  44. package/dist/skills/doubao-apps-dev/references/reference/open-api/29-/345/212/240/345/257/206.md +43 -0
  45. package/dist/skills/doubao-apps-dev/references/reference/open-api/30-/347/224/265/350/257/235.md +36 -0
  46. package/dist/skills/doubao-apps-dev/references/reference/open-api/31-/346/211/253/347/240/201.md +58 -0
  47. package/dist/skills/doubao-apps-dev/references/reference/open-api/32-/345/261/217/345/271/225.md +136 -0
  48. package/dist/skills/doubao-apps-dev/references/reference/open-api/33-/351/234/207/345/212/250.md +62 -0
  49. 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
  50. package/dist/skills/doubao-apps-dev/references/reference/open-api/README.md +34 -0
  51. package/dist/skills/doubao-apps-dev/references/reference/open-api.md +384 -2
  52. package/dist/skills/doubao-apps-dev/references/rules/dos-and-donts.md +44 -27
  53. package/dist/skills/h5-to-doubao/SKILL.md +8 -4
  54. package/dist/skills/weixin-to-doubao/SKILL.md +8 -4
  55. package/dist/skills/weixin-to-doubao/assets/migration-checklist-template.md +1 -1
  56. package/package.json +2 -3
  57. package/dist/contexts/doubao-apps-dev/AGENTS.md +0 -300
  58. package/dist/contexts/doubao-apps-dev/CLAUDE.md +0 -31
  59. package/dist/contexts/doubao-apps-dev/references/examples/common-patterns.md +0 -589
  60. package/dist/contexts/doubao-apps-dev/references/examples/component-basics.md +0 -526
  61. package/dist/contexts/doubao-apps-dev/references/guides/best-practices.md +0 -571
  62. package/dist/contexts/doubao-apps-dev/references/guides/component-development.md +0 -891
  63. package/dist/contexts/doubao-apps-dev/references/guides/performance-optimization.md +0 -402
  64. package/dist/contexts/doubao-apps-dev/references/guides/troubleshooting.md +0 -287
  65. package/dist/contexts/doubao-apps-dev/references/reference/components-quick-ref.md +0 -103
  66. package/dist/contexts/doubao-apps-dev/references/reference/framework-api-quick-ref.md +0 -550
  67. package/dist/contexts/doubao-apps-dev/references/reference/open-api/README.md +0 -8
  68. package/dist/contexts/doubao-apps-dev/references/reference/open-api.md +0 -11
  69. package/dist/contexts/doubao-apps-dev/references/rules/dos-and-donts.md +0 -467
@@ -0,0 +1,284 @@
1
+ # Open API: 存储
2
+
3
+ 本地缓存;带 Sync 后缀的是同步 API。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [setStorage](#setstorage) | 将数据写入本地缓存。 |
12
+ | [setStorageSync](#setstoragesync) | 将数据写入本地缓存。<br><br>同步 API。 |
13
+ | [getStorage](#getstorage) | 从本地缓存读取数据。 |
14
+ | [getStorageSync](#getstoragesync) | 从本地缓存同步读取数据。<br><br>同步 API。 |
15
+ | [removeStorage](#removestorage) | 删除本地缓存中指定 key 的数据。 |
16
+ | [removeStorageSync](#removestoragesync) | 删除本地缓存中指定 key 的数据。<br><br>同步 API。 |
17
+ | [clearStorage](#clearstorage) | 清空本地缓存。 |
18
+ | [clearStorageSync](#clearstoragesync) | 清空本地缓存。<br><br>同步 API。 |
19
+ | [getStorageInfo](#getstorageinfo) | 获取本地缓存信息。 |
20
+ | [getStorageInfoSync](#getstorageinfosync) | 同步获取本地缓存信息。<br><br>同步 API。 |
21
+
22
+ ## API 详情
23
+
24
+ <a id="setstorage"></a>
25
+ ### setStorage()
26
+
27
+ 将数据写入本地缓存。
28
+
29
+ ## 代码示例
30
+
31
+ ```typescript
32
+ import { setStorage } from '@doubao-apps/framework/api';
33
+
34
+ await setStorage({
35
+ key: 'profile',
36
+ data: { name: 'Tom', age: 18 },
37
+ });
38
+ ```
39
+
40
+ ## 入参
41
+
42
+ |参数名|类型|必填|说明|
43
+ |---|---|---|---|
44
+ |data|`TData`|是|待存储的数据|
45
+ |key|`string`|是|本地缓存键名|
46
+
47
+ ## 返回值
48
+
49
+ 返回一个 Promise,写入完成后 resolve。
50
+
51
+ <a id="setstoragesync"></a>
52
+ ### setStorageSync()
53
+
54
+ 将数据写入本地缓存。
55
+
56
+ ## 代码示例
57
+
58
+ ```typescript
59
+ import { setStorageSync } from '@doubao-apps/framework/api';
60
+
61
+ setStorageSync({
62
+ key: 'profile',
63
+ data: { name: 'Tom', age: 18 },
64
+ });
65
+ ```
66
+
67
+ ## 入参
68
+
69
+ |参数名|类型|必填|说明|
70
+ |---|---|---|---|
71
+ |data|`TData`|是|待存储的数据|
72
+ |key|`string`|是|本地缓存键名|
73
+
74
+ ## 返回值
75
+
76
+ 同步写入完成后返回。
77
+
78
+ <a id="getstorage"></a>
79
+ ### getStorage()
80
+
81
+ 从本地缓存读取数据。
82
+
83
+ ## 代码示例
84
+
85
+ ```typescript
86
+ import { getStorage } from '@doubao-apps/framework/api';
87
+
88
+ const result = await getStorage<{ name: string; age: number }>({
89
+ key: 'profile',
90
+ });
91
+
92
+ console.log(result.data.name, result.data.age);
93
+ ```
94
+
95
+ ## 入参
96
+
97
+ |参数名|类型|必填|说明|
98
+ |---|---|---|---|
99
+ |key|`string`|是|本地缓存键名|
100
+
101
+ ## 返回值
102
+
103
+ 返回一个 Promise,解析为 GetStorageResult。
104
+
105
+ |字段名|类型|说明|
106
+ |---|---|---|
107
+ |data|`TData`|key 对应的数据|
108
+
109
+ <a id="getstoragesync"></a>
110
+ ### getStorageSync()
111
+
112
+ 从本地缓存同步读取数据。
113
+
114
+ ## 代码示例
115
+
116
+ ```typescript
117
+ import { getStorageSync } from '@doubao-apps/framework/api';
118
+
119
+ const result = getStorageSync<{ name: string; age: number }>({
120
+ key: 'profile',
121
+ });
122
+
123
+ console.log(result.data.name, result.data.age);
124
+ ```
125
+
126
+ ## 入参
127
+
128
+ |参数名|类型|必填|说明|
129
+ |---|---|---|---|
130
+ |key|`string`|是|本地缓存键名|
131
+
132
+ ## 返回值
133
+
134
+ 返回 GetStorageResult。
135
+
136
+ |字段名|类型|说明|
137
+ |---|---|---|
138
+ |data|`TData`|key 对应的数据|
139
+
140
+ <a id="removestorage"></a>
141
+ ### removeStorage()
142
+
143
+ 删除本地缓存中指定 key 的数据。
144
+
145
+ ## 代码示例
146
+
147
+ ```typescript
148
+ import { removeStorage } from '@doubao-apps/framework/api';
149
+
150
+ await removeStorage({ key: 'profile' });
151
+ ```
152
+
153
+ ## 入参
154
+
155
+ |参数名|类型|必填|说明|
156
+ |---|---|---|---|
157
+ |key|`string`|是|本地缓存键名|
158
+
159
+ ## 返回值
160
+
161
+ 返回一个 Promise,删除完成后 resolve。
162
+
163
+ <a id="removestoragesync"></a>
164
+ ### removeStorageSync()
165
+
166
+ 删除本地缓存中指定 key 的数据。
167
+
168
+ ## 代码示例
169
+
170
+ ```typescript
171
+ import { removeStorageSync } from '@doubao-apps/framework/api';
172
+
173
+ removeStorageSync({ key: 'profile' });
174
+ ```
175
+
176
+ ## 入参
177
+
178
+ |参数名|类型|必填|说明|
179
+ |---|---|---|---|
180
+ |key|`string`|否|本地缓存键名|
181
+
182
+ ## 返回值
183
+
184
+ 同步删除完成后返回。
185
+
186
+ <a id="clearstorage"></a>
187
+ ### clearStorage()
188
+
189
+ 清空本地缓存。
190
+
191
+ ## 代码示例
192
+
193
+ ```typescript
194
+ import { clearStorage } from '@doubao-apps/framework/api';
195
+
196
+ await clearStorage();
197
+ ```
198
+
199
+ ## 入参
200
+
201
+ 无入参。
202
+
203
+ ## 返回值
204
+
205
+ 返回一个 Promise,清空完成后 resolve。
206
+
207
+ <a id="clearstoragesync"></a>
208
+ ### clearStorageSync()
209
+
210
+ 清空本地缓存。
211
+
212
+ ## 代码示例
213
+
214
+ ```typescript
215
+ import { clearStorageSync } from '@doubao-apps/framework/api';
216
+
217
+ clearStorageSync();
218
+ ```
219
+
220
+ ## 入参
221
+
222
+ 无入参。
223
+
224
+ ## 返回值
225
+
226
+ 同步清空完成后返回。
227
+
228
+ <a id="getstorageinfo"></a>
229
+ ### getStorageInfo()
230
+
231
+ 获取本地缓存信息。
232
+
233
+ ## 代码示例
234
+
235
+ ```typescript
236
+ import { getStorageInfo } from '@doubao-apps/framework/api';
237
+
238
+ const result = await getStorageInfo();
239
+
240
+ console.log(result.keys, result.currentSize, result.limitSize);
241
+ ```
242
+
243
+ ## 入参
244
+
245
+ 无入参。
246
+
247
+ ## 返回值
248
+
249
+ 返回一个 Promise,解析为 GetStorageInfoResult。
250
+
251
+ |字段名|类型|说明|
252
+ |---|---|---|
253
+ |currentSize|`number`|当前占用的空间大小,单位 KB|
254
+ |keys|`string[]`|当前 storage 中所有的 key|
255
+ |limitSize|`number`|限制的空间大小,单位 KB|
256
+
257
+ <a id="getstorageinfosync"></a>
258
+ ### getStorageInfoSync()
259
+
260
+ 同步获取本地缓存信息。
261
+
262
+ ## 代码示例
263
+
264
+ ```typescript
265
+ import { getStorageInfoSync } from '@doubao-apps/framework/api';
266
+
267
+ const result = getStorageInfoSync();
268
+
269
+ console.log(result.keys, result.currentSize, result.limitSize);
270
+ ```
271
+
272
+ ## 入参
273
+
274
+ 无入参。
275
+
276
+ ## 返回值
277
+
278
+ 返回 GetStorageInfoResult。
279
+
280
+ |字段名|类型|说明|
281
+ |---|---|---|
282
+ |currentSize|`number`|当前占用的空间大小,单位 KB|
283
+ |keys|`string[]`|当前 storage 中所有的 key|
284
+ |limitSize|`number`|限制的空间大小,单位 KB|
@@ -0,0 +1,162 @@
1
+ # Open API: 路由
2
+
3
+ 应用内页面跳转、返回、退出和关闭。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [navigateTo](#navigateto) | 保留当前页面,跳转到应用内的某个页面。 |
12
+ | [redirectTo](#redirectto) | 关闭当前页面,跳转到应用内的某个页面。 |
13
+ | [reLaunch](#relaunch) | 关闭所有页面并跳转到应用内页面。 |
14
+ | [navigateBack](#navigateback) | 关闭当前页面,返回上一页面或多级页面。 |
15
+ | [exitApp](#exitapp) | 退出当前所有页面。 |
16
+ | [close](#close) | 关闭栈顶页面。 |
17
+
18
+ ## API 详情
19
+
20
+ <a id="navigateto"></a>
21
+ ### navigateTo()
22
+
23
+ 保留当前页面,跳转到应用内的某个页面。
24
+
25
+ ## 代码示例
26
+
27
+ ```typescript
28
+ import { navigateTo } from '@doubao-apps/framework/api';
29
+
30
+ await navigateTo({ url: '/pages/detail/index?id=1' });
31
+ ```
32
+
33
+ ## 入参
34
+
35
+ |参数名|类型|必填|说明|
36
+ |---|---|---|---|
37
+ |url|`string`|是|跳转的页面的路径,如 'path?key=value&key2=value2'|
38
+
39
+ ## 返回值
40
+
41
+ 返回 `Promise<object>`。
42
+
43
+ <a id="redirectto"></a>
44
+ ### redirectTo()
45
+
46
+ 关闭当前页面,跳转到应用内的某个页面。
47
+
48
+ ## 代码示例
49
+
50
+ ```typescript
51
+ import { redirectTo } from '@doubao-apps/framework/api';
52
+
53
+ await redirectTo({ url: '/pages/result/index' });
54
+ ```
55
+
56
+ ## 入参
57
+
58
+ |参数名|类型|必填|说明|
59
+ |---|---|---|---|
60
+ |url|`string`|是|跳转的页面的路径,如 'path?key=value&key2=value2'|
61
+
62
+ ## 返回值
63
+
64
+ 返回 `Promise<object>`。
65
+
66
+ <a id="relaunch"></a>
67
+ ### reLaunch()
68
+
69
+ 关闭所有页面并跳转到应用内页面。
70
+
71
+ ## 代码示例
72
+
73
+ ```typescript
74
+ import { reLaunch } from '@doubao-apps/framework/api';
75
+
76
+ await reLaunch({ url: '/pages/home/index' });
77
+ ```
78
+
79
+ ## 入参
80
+
81
+ |参数名|类型|必填|说明|
82
+ |---|---|---|---|
83
+ |url|`string`|是|跳转的页面的路径,如 'path?key=value&key2=value2'|
84
+
85
+ ## 返回值
86
+
87
+ 返回 `Promise<object>`。
88
+
89
+ <a id="navigateback"></a>
90
+ ### navigateBack()
91
+
92
+ 关闭当前页面,返回上一页面或多级页面。
93
+
94
+ ## 代码示例
95
+
96
+ ```typescript
97
+ import { navigateBack } from '@doubao-apps/framework/api';
98
+
99
+ await navigateBack({ delta: 1 });
100
+ ```
101
+
102
+ ## 入参
103
+
104
+ |参数名|类型|必填|说明|
105
+ |---|---|---|---|
106
+ |delta|`number`|否|返回的页面数,如果 delta 大于现有页面数,则返回到页面栈中只剩一个页面为止。|
107
+
108
+ ## 返回值
109
+
110
+ 返回 `Promise<object>`。
111
+
112
+ <a id="exitapp"></a>
113
+ ### exitApp()
114
+
115
+ 退出当前所有页面。
116
+
117
+ ## 代码示例
118
+
119
+ ```typescript
120
+ import { exitApp } from '@doubao-apps/framework/api';
121
+
122
+ await exitApp();
123
+ ```
124
+
125
+ ## 入参
126
+
127
+ 无入参。
128
+
129
+ ## 返回值
130
+
131
+ 返回 `Promise<object>`。
132
+
133
+ <a id="close"></a>
134
+ ### close()
135
+
136
+ 关闭栈顶页面。
137
+
138
+ ## 代码示例
139
+
140
+ ```typescript
141
+ import { close } from '@doubao-apps/framework/api';
142
+
143
+ async function closeTopPage() {
144
+ try {
145
+ await close();
146
+ } catch (e) {
147
+ console.error('关闭页面失败', e);
148
+ }
149
+ }
150
+
151
+ closeTopPage();
152
+ ```
153
+
154
+ ## 入参
155
+
156
+ |参数名|类型|必填|说明|
157
+ |---|---|---|---|
158
+ |containerID|`string`|否|指定一个要关闭的页面|
159
+
160
+ ## 返回值
161
+
162
+ 返回一个 Promise,在关闭操作成功发起时解析
@@ -0,0 +1,290 @@
1
+ # Open API: 交互
2
+
3
+ Toast、Loading、Modal、ActionSheet 和返回前提醒。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [showModal](#showmodal) | 显示模态对话框。 |
12
+ | [showLoading](#showloading) | 显示 loading 提示框。 |
13
+ | [hideToast](#hidetoast) | 隐藏当前 Toast。 |
14
+ | [hideLoading](#hideloading) | 隐藏当前 loading。 |
15
+ | [showActionSheet](#showactionsheet) | 显示操作菜单。 |
16
+ | [getMenuButtonBoundingClientRect](#getmenubuttonboundingclientrect) | 获取菜单按钮的布局位置信息。 |
17
+ | [enableAlertBeforeUnload](#enablealertbeforeunload) | 开启页面返回前提醒。 |
18
+ | [disableAlertBeforeUnload](#disablealertbeforeunload) | 关闭页面返回前提醒。 |
19
+ | [showToast](#showtoast) | 显示 Toast 提示。 |
20
+
21
+ ## API 详情
22
+
23
+ <a id="showmodal"></a>
24
+ ### showModal()
25
+
26
+ 显示模态对话框。
27
+
28
+ ## 代码示例
29
+
30
+ ```ts
31
+ import { showModal } from '@doubao-apps/framework/api';
32
+
33
+ const result = await showModal({
34
+ title: '提示',
35
+ content: '确认删除这条记录吗?',
36
+ confirmText: '删除',
37
+ cancelText: '取消'
38
+ });
39
+
40
+ if (result.action === 'confirm') {
41
+ console.log('用户确认删除');
42
+ }
43
+ ```
44
+
45
+ ## 入参
46
+
47
+ |参数名|类型|必填|说明|
48
+ |---|---|---|---|
49
+ |cancelText|`string`|否|取消按钮的文字。|
50
+ |confirmText|`string`|否|确认按钮的文字。|
51
+ |content|`string`|是|模态对话框的内容。|
52
+ |showCancel|`boolean`|否|是否显示取消按钮,默认 `true`。|
53
+ |tapMaskToDismiss|`boolean`|否|是否允许点击蒙层关闭对话框,默认 `false`。|
54
+ |title|`string`|否|模态对话框的标题。|
55
+
56
+ ## 返回值
57
+
58
+ 返回 `Promise<ShowModalResult>`。
59
+
60
+ |字段名|类型|说明|
61
+ |---|---|---|
62
+ |action|`"confirm" \| "cancel" \| "mask"`|用户点击的动作。|
63
+
64
+ <a id="showloading"></a>
65
+ ### showLoading()
66
+
67
+ 显示 loading 提示框。
68
+
69
+ ## 代码示例
70
+
71
+ ```typescript
72
+ import { hideLoading, showLoading } from '@doubao-apps/framework/api';
73
+
74
+ await showLoading();
75
+ await hideLoading();
76
+ ```
77
+
78
+ ## 入参
79
+
80
+ 无入参。
81
+
82
+ ## 返回值
83
+
84
+ 返回 `Promise<object>`。
85
+
86
+ <a id="hidetoast"></a>
87
+ ### hideToast()
88
+
89
+ 隐藏当前 Toast。
90
+
91
+ ## 代码示例
92
+
93
+ ```typescript
94
+ import { hideToast } from '@doubao-apps/framework/api';
95
+
96
+ await hideToast();
97
+ ```
98
+
99
+ ## 入参
100
+
101
+ 无入参。
102
+
103
+ ## 返回值
104
+
105
+ 返回 `Promise<object>`。
106
+
107
+ <a id="hideloading"></a>
108
+ ### hideLoading()
109
+
110
+ 隐藏当前 loading。
111
+
112
+ ## 代码示例
113
+
114
+ ```typescript
115
+ import { hideLoading } from '@doubao-apps/framework/api';
116
+
117
+ await hideLoading();
118
+ ```
119
+
120
+ ## 入参
121
+
122
+ 无入参。
123
+
124
+ ## 返回值
125
+
126
+ 返回 `Promise<object>`。
127
+
128
+ <a id="showactionsheet"></a>
129
+ ### showActionSheet()
130
+
131
+ 显示操作菜单。
132
+
133
+ ## 代码示例
134
+
135
+ ```ts
136
+ import { showActionSheet } from '@doubao-apps/framework/api';
137
+
138
+ const result = await showActionSheet({
139
+ itemList: ['编辑', '删除']
140
+ });
141
+
142
+ console.log(result.tapIndex);
143
+ ```
144
+
145
+ ## 入参
146
+
147
+ |参数名|类型|必填|说明|
148
+ |---|---|---|---|
149
+ |itemColor|`string`|否|按钮文字颜色。|
150
+ |itemList|`string[]`|是|按钮文字数组。|
151
+ |title|`string`|否|标题|
152
+
153
+ ## 返回值
154
+
155
+ 返回 `Promise<ShowActionSheetResult>`。
156
+
157
+ |字段名|类型|说明|
158
+ |---|---|---|
159
+ |tapIndex|`number`|用户点击的按钮序号,从 0 开始。|
160
+
161
+ <a id="getmenubuttonboundingclientrect"></a>
162
+ ### getMenuButtonBoundingClientRect()
163
+
164
+ 获取菜单按钮的布局位置信息。
165
+
166
+ ## 代码示例
167
+
168
+ ```ts
169
+ import { getMenuButtonBoundingClientRect } from '@doubao-apps/framework/api';
170
+
171
+ const rect = getMenuButtonBoundingClientRect();
172
+
173
+ console.log(rect.width, rect.height);
174
+ console.log(rect.top, rect.right, rect.bottom, rect.left);
175
+ ```
176
+
177
+ ## 入参
178
+
179
+ 无入参。
180
+
181
+ ## 返回值
182
+
183
+ 返回菜单按钮相对屏幕左上角的坐标和尺寸,字段见 MenuButtonBoundingClientRect。
184
+
185
+ |字段名|类型|说明|
186
+ |---|---|---|
187
+ |bottom|`number`|下边界坐标,单位 px。|
188
+ |height|`number`|高度,单位 px。|
189
+ |left|`number`|左边界坐标,单位 px。|
190
+ |right|`number`|右边界坐标,单位 px。|
191
+ |top|`number`|上边界坐标,单位 px。|
192
+ |width|`number`|宽度,单位 px。|
193
+
194
+ <a id="enablealertbeforeunload"></a>
195
+ ### enableAlertBeforeUnload()
196
+
197
+ 开启页面返回前提醒。
198
+ 当用户在小程序非最底层页面点击左上角返回按钮、左上角首页按钮或 Android 系统 back 键时,弹起询问弹窗
199
+
200
+ 返回询问对话框只会对调用的当前页面生效,通过手势滑动返回时不会弹起询问对话框
201
+
202
+ ## 代码示例
203
+
204
+ ```typescript
205
+ import { enableAlertBeforeUnload } from '@doubao-apps/framework/api';
206
+
207
+ await enableAlertBeforeUnload({ message: '确定离开当前页面吗?' });
208
+ ```
209
+
210
+ ## 入参
211
+
212
+ |参数名|类型|必填|说明|
213
+ |---|---|---|---|
214
+ |message|`string`|是|返回前确认弹窗的文案。|
215
+
216
+ ## 返回值
217
+
218
+ 返回 `Promise<object>`。
219
+
220
+ <a id="disablealertbeforeunload"></a>
221
+ ### disableAlertBeforeUnload()
222
+
223
+ 关闭页面返回前提醒。
224
+
225
+ ## 代码示例
226
+
227
+ ```typescript
228
+ import { disableAlertBeforeUnload } from '@doubao-apps/framework/api';
229
+
230
+ await disableAlertBeforeUnload();
231
+ ```
232
+
233
+ ## 入参
234
+
235
+ |参数名|类型|必填|说明|
236
+ |---|---|---|---|
237
+ |params|`Record<string, never>`|否|-|
238
+
239
+ ## 返回值
240
+
241
+ 返回 `Promise<object>`。
242
+
243
+ <a id="showtoast"></a>
244
+ ### showToast()
245
+
246
+ 显示 Toast 提示。
247
+
248
+ 参数 `options` 包含以下字段:
249
+ - `message`: 提示的内容。
250
+ - `type`: Toast 的类型,可选值为 'default'、'success'、'error' 或 'warning'。
251
+ - `duration`: 提示的延迟时间,单位毫秒,默认为 2000。
252
+ - `icon`: 图标,可选值为 'success', 'error', 'warn'。
253
+ - `customIcon`: 自定义图标的 URL 或 base64 字符串。
254
+
255
+ ## 代码示例
256
+
257
+ ```typescript
258
+ import { showToast } from '@doubao-apps/framework/api';
259
+
260
+ // 显示一个成功的 Toast
261
+ showToast({
262
+ message: '操作成功',
263
+ type: 'success',
264
+ icon: 'success',
265
+ duration: 1500
266
+ }).then(() => {
267
+ console.log('Toast 显示完毕');
268
+ });
269
+
270
+ // 显示一个错误的 Toast
271
+ showToast({
272
+ message: '网络错误',
273
+ type: 'error',
274
+ icon: 'error'
275
+ });
276
+ ```
277
+
278
+ ## 入参
279
+
280
+ |参数名|类型|必填|说明|
281
+ |---|---|---|---|
282
+ |customIcon|`string`|否|-|
283
+ |duration|`number`|否|-|
284
+ |icon|`"success" \| "error" \| "warn"`|否|-|
285
+ |message|`string`|是|-|
286
+ |type|`"default" \| "success" \| "error" \| "warning"`|否|-|
287
+
288
+ ## 返回值
289
+
290
+ 返回一个 Promise,在 Toast 显示结束时 resolve。