@doubao-apps/create 0.0.25 → 0.0.27

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 (91) hide show
  1. package/dist/36.js +4 -4
  2. package/dist/template-empty/.ai/examples/common-patterns.md +53 -43
  3. package/dist/template-empty/.ai/examples/component-basics.md +0 -17
  4. package/dist/template-empty/.ai/guides/component-development.md +96 -214
  5. package/dist/template-empty/.ai/guides/system-prompt.md +14 -14
  6. package/dist/template-empty/.ai/reference/framework-api-quick-ref.md +46 -85
  7. package/dist/template-empty/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +699 -0
  8. package/dist/template-empty/.ai/reference/open-api/02-/345/255/230/345/202/250.md +409 -0
  9. package/dist/template-empty/.ai/reference/open-api/03-/350/267/257/347/224/261.md +165 -0
  10. package/dist/template-empty/.ai/reference/open-api/04-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
  11. package/dist/template-empty/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
  12. package/dist/template-empty/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
  13. package/dist/template-empty/.ai/reference/open-api/07-/345/252/222/344/275/223.md +346 -0
  14. package/dist/template-empty/.ai/reference/open-api/08-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +546 -0
  15. package/dist/template-empty/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md +961 -0
  16. package/dist/template-empty/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md +277 -0
  17. package/dist/template-empty/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
  18. package/dist/template-empty/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
  19. package/dist/template-empty/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
  20. package/dist/template-empty/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
  21. package/dist/template-empty/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
  22. package/dist/template-empty/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
  23. package/dist/template-empty/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
  24. package/dist/template-empty/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
  25. package/dist/template-empty/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
  26. package/dist/template-empty/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
  27. package/dist/template-empty/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
  28. package/dist/template-empty/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
  29. package/dist/template-empty/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
  30. package/dist/template-empty/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
  31. package/dist/template-empty/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
  32. package/dist/template-empty/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
  33. package/dist/template-empty/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
  34. package/dist/template-empty/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
  35. package/dist/template-empty/.ai/reference/open-api/README.md +36 -0
  36. package/dist/template-empty/.ai/reference/open-api.md +1758 -266
  37. package/dist/template-empty/.ai/rules/dos-and-donts.md +50 -37
  38. package/dist/template-empty/AGENTS.md +56 -33
  39. package/dist/template-empty/README.md +57 -10
  40. package/dist/template-empty/package.json +2 -2
  41. package/dist/template-empty/src/app.config.ts +6 -0
  42. package/dist/template-empty/src/app.ts +0 -6
  43. package/dist/template-empty/tsconfig.json +2 -0
  44. package/dist/template-starter/.ai/examples/common-patterns.md +53 -43
  45. package/dist/template-starter/.ai/examples/component-basics.md +0 -17
  46. package/dist/template-starter/.ai/guides/component-development.md +96 -214
  47. package/dist/template-starter/.ai/guides/system-prompt.md +14 -14
  48. package/dist/template-starter/.ai/reference/framework-api-quick-ref.md +46 -85
  49. package/dist/template-starter/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +699 -0
  50. package/dist/template-starter/.ai/reference/open-api/02-/345/255/230/345/202/250.md +409 -0
  51. package/dist/template-starter/.ai/reference/open-api/03-/350/267/257/347/224/261.md +165 -0
  52. package/dist/template-starter/.ai/reference/open-api/04-/347/225/214/351/235/242-/344/272/244/344/272/222.md +432 -0
  53. package/dist/template-starter/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
  54. package/dist/template-starter/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
  55. package/dist/template-starter/.ai/reference/open-api/07-/345/252/222/344/275/223.md +346 -0
  56. package/dist/template-starter/.ai/reference/open-api/08-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +546 -0
  57. package/dist/template-starter/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md +961 -0
  58. package/dist/template-starter/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md +277 -0
  59. package/dist/template-starter/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
  60. package/dist/template-starter/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
  61. package/dist/template-starter/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
  62. package/dist/template-starter/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
  63. package/dist/template-starter/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
  64. package/dist/template-starter/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
  65. package/dist/template-starter/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
  66. package/dist/template-starter/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
  67. package/dist/template-starter/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
  68. package/dist/template-starter/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
  69. package/dist/template-starter/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
  70. package/dist/template-starter/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
  71. package/dist/template-starter/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
  72. package/dist/template-starter/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
  73. package/dist/template-starter/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
  74. package/dist/template-starter/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
  75. package/dist/template-starter/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
  76. package/dist/template-starter/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
  77. package/dist/template-starter/.ai/reference/open-api/README.md +36 -0
  78. package/dist/template-starter/.ai/reference/open-api.md +1758 -266
  79. package/dist/template-starter/.ai/rules/dos-and-donts.md +50 -37
  80. package/dist/template-starter/AGENTS.md +56 -33
  81. package/dist/template-starter/README.md +6 -1
  82. package/dist/template-starter/package.json +2 -2
  83. package/dist/template-starter/src/app.config.ts +35 -0
  84. package/dist/template-starter/src/app.ts +0 -6
  85. package/dist/template-starter/src/pages/applet/index.tsx +0 -5
  86. package/dist/template-starter/src/pages/home/index.tsx +0 -5
  87. package/dist/template-starter/src/pages/lynx/index.tsx +0 -4
  88. package/dist/template-starter/src/pages/react-lynx/index.tsx +0 -5
  89. package/dist/template-starter/src/widgets/weather-card/index.tsx +0 -4
  90. package/dist/template-starter/tsconfig.json +2 -0
  91. package/package.json +1 -1
@@ -0,0 +1,432 @@
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 提示框。<br><br>需调用 hideLoading 关闭。 |
13
+ | [hideToast](#hidetoast) | 隐藏当前 Toast。 |
14
+ | [hideLoading](#hideloading) | 隐藏当前 loading。 |
15
+ | [showActionSheet](#showactionsheet) | 显示操作菜单。 |
16
+ | [getMenuButtonBoundingClientRect](#getmenubuttonboundingclientrect) | 获取菜单按钮的布局位置信息。 |
17
+ | [enableAlertBeforeUnload](#enablealertbeforeunload) | 开启页面返回前提醒。<br><br>配合 disableAlertBeforeUnload 使用。 |
18
+ | [disableAlertBeforeUnload](#disablealertbeforeunload) | 关闭页面返回前提醒。 |
19
+ | [showToast](#showtoast) | 显示 Toast 提示。<br><br>duration 和 icon 可控制提示表现。 |
20
+
21
+ ## API 详情
22
+
23
+ <a id="showmodal"></a>
24
+ ### showModal()
25
+
26
+ > **showModal**(`params`): `Promise`\<[`ShowModalResult`](#showmodalresult)\>
27
+
28
+ 显示模态对话框。
29
+
30
+ #### Parameters
31
+
32
+ • **params**: [`ShowModalParams`](#showmodalparams)
33
+
34
+ #### Returns
35
+
36
+ `Promise`\<[`ShowModalResult`](#showmodalresult)\>
37
+
38
+ #### Example
39
+
40
+ ```ts
41
+ import { showModal } from '@doubao-apps/framework/api';
42
+
43
+ const result = await showModal({
44
+ title: '提示',
45
+ content: '确认删除这条记录吗?',
46
+ confirmText: '删除',
47
+ cancelText: '取消'
48
+ });
49
+
50
+ if (result.action === 'confirm') {
51
+ console.log('用户确认删除');
52
+ }
53
+ ```
54
+
55
+ <a id="showloading"></a>
56
+ ### showLoading()
57
+
58
+ > **showLoading**(`params`?): `Promise`\<`object`\>
59
+
60
+ 显示 loading 提示框。
61
+
62
+ #### Parameters
63
+
64
+ • **params?**: [`ShowLoadingParams`](#showloadingparams)
65
+
66
+ #### Returns
67
+
68
+ `Promise`\<`object`\>
69
+
70
+ #### Remarks
71
+
72
+ 需调用 hideLoading 关闭。
73
+
74
+ <a id="hidetoast"></a>
75
+ ### hideToast()
76
+
77
+ > **hideToast**(`params`?): `Promise`\<`object`\>
78
+
79
+ 隐藏当前 Toast。
80
+
81
+ #### Parameters
82
+
83
+ • **params?**: [`HideInteractionParams`](#hideinteractionparams)
84
+
85
+ #### Returns
86
+
87
+ `Promise`\<`object`\>
88
+
89
+ <a id="hideloading"></a>
90
+ ### hideLoading()
91
+
92
+ > **hideLoading**(`params`?): `Promise`\<`object`\>
93
+
94
+ 隐藏当前 loading。
95
+
96
+ #### Parameters
97
+
98
+ • **params?**: [`HideInteractionParams`](#hideinteractionparams)
99
+
100
+ #### Returns
101
+
102
+ `Promise`\<`object`\>
103
+
104
+ <a id="showactionsheet"></a>
105
+ ### showActionSheet()
106
+
107
+ > **showActionSheet**(`params`): `Promise`\<[`ShowActionSheetResult`](#showactionsheetresult)\>
108
+
109
+ 显示操作菜单。
110
+
111
+ #### Parameters
112
+
113
+ • **params**: [`ShowActionSheetParams`](#showactionsheetparams)
114
+
115
+ #### Returns
116
+
117
+ `Promise`\<[`ShowActionSheetResult`](#showactionsheetresult)\>
118
+
119
+ #### Example
120
+
121
+ ```ts
122
+ import { showActionSheet } from '@doubao-apps/framework/api';
123
+
124
+ const result = await showActionSheet({
125
+ itemList: ['编辑', '删除']
126
+ });
127
+
128
+ console.log(result.tapIndex);
129
+ ```
130
+
131
+ <a id="getmenubuttonboundingclientrect"></a>
132
+ ### getMenuButtonBoundingClientRect()
133
+
134
+ > **getMenuButtonBoundingClientRect**(`params`?): [`MenuButtonBoundingClientRect`](#menubuttonboundingclientrect)
135
+
136
+ 获取菜单按钮的布局位置信息。
137
+
138
+ #### Parameters
139
+
140
+ • **params?**
141
+
142
+ #### Returns
143
+
144
+ [`MenuButtonBoundingClientRect`](#menubuttonboundingclientrect)
145
+
146
+ 返回菜单按钮相对屏幕左上角的坐标和尺寸,字段见 [MenuButtonBoundingClientRect](#menubuttonboundingclientrect)。
147
+
148
+ #### Example
149
+
150
+ ```ts
151
+ import { getMenuButtonBoundingClientRect } from '@doubao-apps/framework/api';
152
+
153
+ const rect = getMenuButtonBoundingClientRect();
154
+
155
+ console.log(rect.width, rect.height);
156
+ console.log(rect.top, rect.right, rect.bottom, rect.left);
157
+ ```
158
+
159
+ <a id="enablealertbeforeunload"></a>
160
+ ### enableAlertBeforeUnload()
161
+
162
+ > **enableAlertBeforeUnload**(`params`): `Promise`\<`object`\>
163
+
164
+ 开启页面返回前提醒。
165
+ 当用户在小程序非最底层页面点击左上角返回按钮、左上角首页按钮或 Android 系统 back 键时,弹起询问弹窗
166
+
167
+ 返回询问对话框只会对调用的当前页面生效,通过手势滑动返回时不会弹起询问对话框
168
+
169
+ #### Parameters
170
+
171
+ • **params**: [`EnableAlertBeforeUnloadParams`](#enablealertbeforeunloadparams)
172
+
173
+ #### Returns
174
+
175
+ `Promise`\<`object`\>
176
+
177
+ #### Remarks
178
+
179
+ 配合 disableAlertBeforeUnload 使用。
180
+
181
+ <a id="disablealertbeforeunload"></a>
182
+ ### disableAlertBeforeUnload()
183
+
184
+ > **disableAlertBeforeUnload**(`params`?): `Promise`\<`object`\>
185
+
186
+ 关闭页面返回前提醒。
187
+
188
+ #### Parameters
189
+
190
+ • **params?**: `Record`\<`string`, `never`\>
191
+
192
+ #### Returns
193
+
194
+ `Promise`\<`object`\>
195
+
196
+ <a id="showtoast"></a>
197
+ ### showToast()
198
+
199
+ > **showToast**(`params`): `Promise`\<`object`\>
200
+
201
+ 显示 Toast 提示。
202
+
203
+ 参数 `options` 包含以下字段:
204
+ - `message`: 提示的内容。
205
+ - `type`: Toast 的类型,可选值为 'success' 或 'error'。
206
+ - `duration`: 提示的延迟时间,单位毫秒,默认为 2000。
207
+ - `icon`: 图标,可选值为 'success', 'error', 'warn'。
208
+ - `customIcon`: 自定义图标的 URL 或 base64 字符串。
209
+
210
+ #### Parameters
211
+
212
+ • **params**: [`ShowToastParams`](#showtoastparams)
213
+
214
+ #### Returns
215
+
216
+ `Promise`\<`object`\>
217
+
218
+ 返回一个 Promise,在 Toast 显示结束时 resolve。
219
+
220
+ #### Remarks
221
+
222
+ duration 和 icon 可控制提示表现。
223
+
224
+ #### Example
225
+
226
+ ```typescript
227
+ import { showToast } from '@doubao-apps/framework';
228
+
229
+ // 显示一个成功的 Toast
230
+ showToast({
231
+ message: '操作成功',
232
+ type: 'success',
233
+ icon: 'success',
234
+ duration: 1500
235
+ }).then(() => {
236
+ console.log('Toast 显示完毕');
237
+ });
238
+
239
+ // 显示一个错误的 Toast
240
+ showToast({
241
+ message: '网络错误',
242
+ type: 'error',
243
+ icon: 'error'
244
+ });
245
+ ```
246
+
247
+ ## 相关类型
248
+
249
+ <a id="showmodalparams"></a>
250
+ ### ShowModalParams
251
+
252
+ 显示模态对话框的参数。
253
+
254
+ #### Properties
255
+
256
+ ##### cancelText?
257
+
258
+ > `optional` **cancelText**: `string`
259
+
260
+ 取消按钮的文字。
261
+
262
+ ##### confirmText?
263
+
264
+ > `optional` **confirmText**: `string`
265
+
266
+ 确认按钮的文字。
267
+
268
+ ##### content
269
+
270
+ > **content**: `string`
271
+
272
+ 模态对话框的内容。
273
+
274
+ ##### showCancel?
275
+
276
+ > `optional` **showCancel**: `boolean`
277
+
278
+ 是否显示取消按钮,默认 `true`。
279
+
280
+ ##### tapMaskToDismiss?
281
+
282
+ > `optional` **tapMaskToDismiss**: `boolean`
283
+
284
+ 是否允许点击蒙层关闭对话框,默认 `false`。
285
+
286
+ ##### title?
287
+
288
+ > `optional` **title**: `string`
289
+
290
+ 模态对话框的标题。
291
+
292
+ <a id="showmodalresult"></a>
293
+ ### ShowModalResult
294
+
295
+ 显示模态对话框的返回结果。
296
+
297
+ #### Properties
298
+
299
+ ##### action
300
+
301
+ > **action**: `"confirm"` \| `"cancel"` \| `"mask"`
302
+
303
+ 用户点击的动作。
304
+
305
+ <a id="showloadingparams"></a>
306
+ ### ShowLoadingParams
307
+
308
+ 显示 loading 提示框的参数。
309
+
310
+ <a id="hideinteractionparams"></a>
311
+ ### HideInteractionParams
312
+
313
+ 隐藏交互提示框的公共参数。
314
+
315
+ <a id="showactionsheetparams"></a>
316
+ ### ShowActionSheetParams
317
+
318
+ 显示操作菜单的参数。
319
+
320
+ #### Properties
321
+
322
+ ##### itemColor?
323
+
324
+ > `optional` **itemColor**: `string`
325
+
326
+ 按钮文字颜色。
327
+
328
+ ##### itemList
329
+
330
+ > **itemList**: `string`[]
331
+
332
+ 按钮文字数组。
333
+
334
+ ##### title?
335
+
336
+ > `optional` **title**: `string`
337
+
338
+ 标题
339
+
340
+ <a id="showactionsheetresult"></a>
341
+ ### ShowActionSheetResult
342
+
343
+ 显示操作菜单的返回结果。
344
+
345
+ #### Properties
346
+
347
+ ##### tapIndex
348
+
349
+ > **tapIndex**: `number`
350
+
351
+ 用户点击的按钮序号,从 0 开始。
352
+
353
+ <a id="menubuttonboundingclientrect"></a>
354
+ ### MenuButtonBoundingClientRect
355
+
356
+ 菜单按钮的布局位置信息。
357
+
358
+ #### Properties
359
+
360
+ ##### bottom
361
+
362
+ > **bottom**: `number`
363
+
364
+ 下边界坐标,单位 px。
365
+
366
+ ##### height
367
+
368
+ > **height**: `number`
369
+
370
+ 高度,单位 px。
371
+
372
+ ##### left
373
+
374
+ > **left**: `number`
375
+
376
+ 左边界坐标,单位 px。
377
+
378
+ ##### right
379
+
380
+ > **right**: `number`
381
+
382
+ 右边界坐标,单位 px。
383
+
384
+ ##### top
385
+
386
+ > **top**: `number`
387
+
388
+ 上边界坐标,单位 px。
389
+
390
+ ##### width
391
+
392
+ > **width**: `number`
393
+
394
+ 宽度,单位 px。
395
+
396
+ <a id="enablealertbeforeunloadparams"></a>
397
+ ### EnableAlertBeforeUnloadParams
398
+
399
+ 开启返回前提醒的参数。
400
+
401
+ #### Properties
402
+
403
+ ##### message
404
+
405
+ > **message**: `string`
406
+
407
+ 返回前确认弹窗的文案。
408
+
409
+ <a id="showtoastparams"></a>
410
+ ### ShowToastParams
411
+
412
+ #### Properties
413
+
414
+ ##### customIcon?
415
+
416
+ > `optional` **customIcon**: `string`
417
+
418
+ ##### duration?
419
+
420
+ > `optional` **duration**: `number`
421
+
422
+ ##### icon?
423
+
424
+ > `optional` **icon**: `"success"` \| `"error"` \| `"warn"`
425
+
426
+ ##### message
427
+
428
+ > **message**: `string`
429
+
430
+ ##### type?
431
+
432
+ > `optional` **type**: `"default"` \| `"success"` \| `"error"` \| `"warning"`
@@ -0,0 +1,42 @@
1
+ # Open API: 界面 / 输入
2
+
3
+ 键盘和输入框选区能力。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [onKeyboardHeightChange](#onkeyboardheightchange) | 监听键盘高度变化事件。<br><br>返回取消监听函数。 |
12
+
13
+ ## API 详情
14
+
15
+ <a id="onkeyboardheightchange"></a>
16
+ ### onKeyboardHeightChange()
17
+
18
+ > **onKeyboardHeightChange**(`handler`): () => `void`
19
+
20
+ 监听键盘高度变化事件。
21
+
22
+ #### Parameters
23
+
24
+ • **handler**
25
+
26
+ #### Returns
27
+
28
+ `Function`
29
+
30
+ ##### Returns
31
+
32
+ `void`
33
+
34
+ #### Example
35
+
36
+ ```typescript
37
+ import { onKeyboardHeightChange } from '@doubao-apps/framework/api';
38
+
39
+ const unsubscribe = onKeyboardHeightChange(({ height }) => {
40
+ console.log('Keyboard height change event:', { height });
41
+ });
42
+ ```
@@ -0,0 +1,148 @@
1
+ # Open API: 网络
2
+
3
+ 网络请求
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [request](#request) | 发起网络请求。<br><br>返回 statusCode、header 和 data。 |
12
+
13
+ ## API 详情
14
+
15
+ <a id="request"></a>
16
+ ### request()
17
+
18
+ > **request**(`params`): `Promise`\<[`RequestResponse`](#requestresponse)\>
19
+
20
+ 发起网络请求。
21
+
22
+ #### Parameters
23
+
24
+ • **params**: [`RequestParams`](#requestparams)
25
+
26
+ 请求参数,字段见 [RequestParams](#requestparams)。
27
+
28
+ #### Returns
29
+
30
+ `Promise`\<[`RequestResponse`](#requestresponse)\>
31
+
32
+ 返回一个 Promise,解析为 [RequestResponse](#requestresponse)。
33
+
34
+ #### Remarks
35
+
36
+ 返回 statusCode、header 和 data。
37
+
38
+ #### Example
39
+
40
+ ```typescript
41
+ import { request } from '@doubao-apps/framework/api';
42
+
43
+ const result = await request({
44
+ url: 'https://postman-echo.com/post',
45
+ method: 'POST',
46
+ dataType: 'json',
47
+ header: { 'content-type': 'application/json' },
48
+ data: { hello: 'world' }
49
+ });
50
+
51
+ console.log(result.statusCode, result.data);
52
+ ```
53
+
54
+ ## 相关类型
55
+
56
+ <a id="requestparams"></a>
57
+ ### RequestParams
58
+
59
+ 网络请求参数。
60
+
61
+ #### Properties
62
+
63
+ ##### data?
64
+
65
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
66
+
67
+ 请求体数据。
68
+
69
+ 传给服务器的数据最终会是 `String` 或 `ArrayBuffer`:
70
+ - 若 `data` 是 `string` 或 `ArrayBuffer`,直接使用;
71
+ - 若 `header['content-type']` 是 `application/x-www-form-urlencoded`,会被编码为 query string,例如:`encodeURIComponent(k)=encodeURIComponent(v)`;
72
+ - 若 `header['content-type']` 是 `application/json`,会执行 JSON 序列化;
73
+ - 若 `data` 是普通对象且未命中上述类型,也会执行 JSON 序列化;
74
+ - 其他类型会调用 `toString()`
75
+
76
+ ##### dataType?
77
+
78
+ > `optional` **dataType**: `"string"` \| `"json"`
79
+
80
+ 期望返回的数据格式。
81
+ - `json`: 尝试按 JSON 解析;
82
+ - `string`: 按字符串返回。
83
+
84
+ ###### Default
85
+
86
+ ```ts
87
+ "json"
88
+ ```
89
+
90
+ ##### header?
91
+
92
+ > `optional` **header**: `Record`\<`string`, `string`\>
93
+
94
+ 请求 Header。
95
+
96
+ ###### Default
97
+
98
+ ```ts
99
+ {"content-type": "application/json"}
100
+ ```
101
+
102
+ ##### method?
103
+
104
+ > `optional` **method**: [`RequestMethod`](#requestmethod)
105
+
106
+ 请求方法。
107
+
108
+ ###### Default
109
+
110
+ ```ts
111
+ "GET"
112
+ ```
113
+
114
+ ##### url
115
+
116
+ > **url**: `string`
117
+
118
+ 请求地址,需为完整的 **HTTPS** URL。
119
+
120
+ <a id="requestresponse"></a>
121
+ ### RequestResponse
122
+
123
+ 网络请求返回结果。
124
+
125
+ #### Properties
126
+
127
+ ##### data?
128
+
129
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
130
+
131
+ 响应数据,类型由 `dataType` 决定。
132
+
133
+ ##### header
134
+
135
+ > **header**: `Record`\<`string`, `string`\>
136
+
137
+ HTTP 响应头。
138
+
139
+ ##### statusCode
140
+
141
+ > **statusCode**: `number`
142
+
143
+ HTTP 状态码。
144
+
145
+ <a id="requestmethod"></a>
146
+ ### RequestMethod
147
+
148
+ > **RequestMethod**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"HEAD"` \| `"OPTIONS"` \| `"TRACE"` \| `"CONNECT"`