@doubao-apps/create 0.0.25 → 0.0.26

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 (33) hide show
  1. 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
  2. package/dist/template-empty/.ai/reference/open-api/02-storage.md +417 -0
  3. package/dist/template-empty/.ai/reference/open-api/03-router.md +165 -0
  4. package/dist/template-empty/.ai/reference/open-api/04-ui-/344/272/244/344/272/222.md +432 -0
  5. package/dist/template-empty/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +95 -0
  6. package/dist/template-empty/.ai/reference/open-api/06-network.md +298 -0
  7. package/dist/template-empty/.ai/reference/open-api/07-media.md +346 -0
  8. package/dist/template-empty/.ai/reference/open-api/08-open-/344/270/232/345/212/241/350/203/275/345/212/233.md +477 -0
  9. package/dist/template-empty/.ai/reference/open-api/09-device-bluetooth.md +985 -0
  10. package/dist/template-empty/.ai/reference/open-api/10-device-wi-fi.md +277 -0
  11. package/dist/template-empty/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +372 -0
  12. package/dist/template-empty/.ai/reference/open-api/12-device-/346/234/254/345/234/260/350/203/275/345/212/233.md +1005 -0
  13. package/dist/template-empty/.ai/reference/open-api/README.md +20 -0
  14. package/dist/template-empty/.ai/reference/open-api.md +1532 -307
  15. package/dist/template-empty/AGENTS.md +2 -2
  16. package/dist/template-empty/package.json +2 -2
  17. 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
  18. package/dist/template-starter/.ai/reference/open-api/02-storage.md +417 -0
  19. package/dist/template-starter/.ai/reference/open-api/03-router.md +165 -0
  20. package/dist/template-starter/.ai/reference/open-api/04-ui-/344/272/244/344/272/222.md +432 -0
  21. package/dist/template-starter/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +95 -0
  22. package/dist/template-starter/.ai/reference/open-api/06-network.md +298 -0
  23. package/dist/template-starter/.ai/reference/open-api/07-media.md +346 -0
  24. package/dist/template-starter/.ai/reference/open-api/08-open-/344/270/232/345/212/241/350/203/275/345/212/233.md +477 -0
  25. package/dist/template-starter/.ai/reference/open-api/09-device-bluetooth.md +985 -0
  26. package/dist/template-starter/.ai/reference/open-api/10-device-wi-fi.md +277 -0
  27. package/dist/template-starter/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +372 -0
  28. package/dist/template-starter/.ai/reference/open-api/12-device-/346/234/254/345/234/260/350/203/275/345/212/233.md +1005 -0
  29. package/dist/template-starter/.ai/reference/open-api/README.md +20 -0
  30. package/dist/template-starter/.ai/reference/open-api.md +1532 -307
  31. package/dist/template-starter/AGENTS.md +2 -2
  32. package/dist/template-starter/package.json +2 -2
  33. package/package.json +1 -1
@@ -0,0 +1,298 @@
1
+ # Open API: Network
2
+
3
+ 网络请求、网络类型和本机局域网 IP。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
+ | --- | --- | --- | --- | --- | --- |
11
+ | [`request`](#request) | `request(params): Promise<RequestResponse>` | 发起网络请求 | `params: RequestParams` | `Promise<RequestResponse>` | 返回 statusCode、header 和 data |
12
+ | [`getNetworkType`](#getnetworktype) | `getNetworkType(params?): Promise<GetNetworkTypeResult>` | 获取当前网络类型 | `params?: GetNetworkTypeParams` | `Promise<GetNetworkTypeResult>` | - |
13
+ | [`onNetworkStatusChange`](#onnetworkstatuschange) | `onNetworkStatusChange(handler): () => void` | 监听网络状态变化事件 | `handler` | `() => void` | 返回取消监听函数 |
14
+ | [`getLocalIPAddress`](#getlocalipaddress) | `getLocalIPAddress(params?): Promise<GetLocalIPAddressResult>` | 获取局域网 IP 地址 | `params?` | `Promise<GetLocalIPAddressResult>` | - |
15
+
16
+ ## API 详情
17
+
18
+ <a id="request"></a>
19
+ ### request()
20
+
21
+ > **request**(`params`): `Promise`\<[`RequestResponse`](#requestresponse)\>
22
+
23
+ 发起网络请求。
24
+
25
+ #### Parameters
26
+
27
+ • **params**: [`RequestParams`](#requestparams)
28
+
29
+ 请求参数,字段见 [RequestParams](#requestparams)。
30
+
31
+ #### Returns
32
+
33
+ `Promise`\<[`RequestResponse`](#requestresponse)\>
34
+
35
+ 返回一个 Promise,解析为 [RequestResponse](#requestresponse)。
36
+
37
+ #### Remarks
38
+
39
+ 返回 statusCode、header 和 data。
40
+
41
+ #### Example
42
+
43
+ ```typescript
44
+ import { request } from '@doubao-apps/framework/api';
45
+
46
+ const result = await request({
47
+ url: 'https://postman-echo.com/post',
48
+ method: 'POST',
49
+ dataType: 'json',
50
+ header: { 'content-type': 'application/json' },
51
+ data: { hello: 'world' }
52
+ });
53
+
54
+ console.log(result.statusCode, result.data);
55
+ ```
56
+
57
+ <a id="getnetworktype"></a>
58
+ ### getNetworkType()
59
+
60
+ > **getNetworkType**(`params`?): `Promise`\<[`GetNetworkTypeResult`](#getnetworktyperesult)\>
61
+
62
+ 获取当前网络类型。
63
+
64
+ #### Parameters
65
+
66
+ • **params?**: [`GetNetworkTypeParams`](#getnetworktypeparams)
67
+
68
+ #### Returns
69
+
70
+ `Promise`\<[`GetNetworkTypeResult`](#getnetworktyperesult)\>
71
+
72
+ 返回一个 Promise,解析为 [GetNetworkTypeResult](#getnetworktyperesult)。
73
+
74
+ #### Example
75
+
76
+ ```ts
77
+ import { getNetworkType } from '@doubao-apps/framework/api';
78
+
79
+ const result = await getNetworkType();
80
+ console.log(result.networkType);
81
+ ```
82
+
83
+ <a id="onnetworkstatuschange"></a>
84
+ ### onNetworkStatusChange()
85
+
86
+ > **onNetworkStatusChange**(`handler`): () => `void`
87
+
88
+ 监听网络状态变化事件。
89
+
90
+ #### Parameters
91
+
92
+ • **handler**
93
+
94
+ #### Returns
95
+
96
+ `Function`
97
+
98
+ 返回取消当前监听函数的函数。
99
+
100
+ ##### Returns
101
+
102
+ `void`
103
+
104
+ #### Example
105
+
106
+ ```ts
107
+ import { onNetworkStatusChange } from '@doubao-apps/framework/api';
108
+
109
+ const off = onNetworkStatusChange(({ isConnected, networkType }) => {
110
+ console.log(isConnected, networkType);
111
+ });
112
+
113
+ off();
114
+ ```
115
+
116
+ <a id="getlocalipaddress"></a>
117
+ ### getLocalIPAddress()
118
+
119
+ > **getLocalIPAddress**(`params`?): `Promise`\<[`GetLocalIPAddressResult`](#getlocalipaddressresult)\>
120
+
121
+ 获取局域网 IP 地址。
122
+
123
+ #### Parameters
124
+
125
+ • **params?**
126
+
127
+ #### Returns
128
+
129
+ `Promise`\<[`GetLocalIPAddressResult`](#getlocalipaddressresult)\>
130
+
131
+ ## 相关类型
132
+
133
+ <a id="requestparams"></a>
134
+ ### RequestParams
135
+
136
+ 网络请求参数。
137
+
138
+ #### Properties
139
+
140
+ ##### data?
141
+
142
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
143
+
144
+ 请求体数据。
145
+
146
+ 传给服务器的数据最终会是 `String` 或 `ArrayBuffer`:
147
+ - 若 `data` 是 `string` 或 `ArrayBuffer`,直接使用;
148
+ - 若 `header['content-type']` 是 `application/x-www-form-urlencoded`,会被编码为 query string,例如:`encodeURIComponent(k)=encodeURIComponent(v)`;
149
+ - 若 `header['content-type']` 是 `application/json`,会执行 JSON 序列化;
150
+ - 若 `data` 是普通对象且未命中上述类型,也会执行 JSON 序列化;
151
+ - 其他类型会调用 `toString()`
152
+
153
+ ##### dataType?
154
+
155
+ > `optional` **dataType**: `"string"` \| `"json"`
156
+
157
+ 期望返回的数据格式。
158
+ - `json`: 尝试按 JSON 解析;
159
+ - `string`: 按字符串返回。
160
+
161
+ ###### Default
162
+
163
+ ```ts
164
+ "json"
165
+ ```
166
+
167
+ ##### header?
168
+
169
+ > `optional` **header**: `Record`\<`string`, `string`\>
170
+
171
+ 请求 Header。
172
+
173
+ ###### Default
174
+
175
+ ```ts
176
+ {"content-type": "application/json"}
177
+ ```
178
+
179
+ ##### method?
180
+
181
+ > `optional` **method**: [`RequestMethod`](#requestmethod)
182
+
183
+ 请求方法。
184
+
185
+ ###### Default
186
+
187
+ ```ts
188
+ "GET"
189
+ ```
190
+
191
+ ##### url
192
+
193
+ > **url**: `string`
194
+
195
+ 请求地址,需为完整的 **HTTPS** URL。
196
+
197
+ <a id="requestresponse"></a>
198
+ ### RequestResponse
199
+
200
+ 网络请求返回结果。
201
+
202
+ #### Properties
203
+
204
+ ##### data?
205
+
206
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
207
+
208
+ 响应数据,类型由 `dataType` 决定。
209
+
210
+ ##### header
211
+
212
+ > **header**: `Record`\<`string`, `string`\>
213
+
214
+ HTTP 响应头。
215
+
216
+ ##### statusCode
217
+
218
+ > **statusCode**: `number`
219
+
220
+ HTTP 状态码。
221
+
222
+ <a id="requestmethod"></a>
223
+ ### RequestMethod
224
+
225
+ > **RequestMethod**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"HEAD"` \| `"OPTIONS"` \| `"TRACE"` \| `"CONNECT"`
226
+
227
+ <a id="getnetworktypeparams"></a>
228
+ ### GetNetworkTypeParams
229
+
230
+ 获取网络类型的请求参数。
231
+
232
+ 当前无需传入任何字段,预留扩展位。
233
+
234
+ <a id="getnetworktyperesult"></a>
235
+ ### GetNetworkTypeResult
236
+
237
+ 获取网络类型的返回结果。
238
+
239
+ #### Properties
240
+
241
+ ##### hasSystemProxy?
242
+
243
+ > `optional` **hasSystemProxy**: `boolean`
244
+
245
+ 设备是否使用了系统代理。
246
+
247
+ ##### networkType
248
+
249
+ > **networkType**: [`NetworkType`](#networktype-2)
250
+
251
+ 当前网络类型。
252
+
253
+ ##### signalStrength?
254
+
255
+ > `optional` **signalStrength**: `number`
256
+
257
+ 信号强弱,单位 dBm。
258
+
259
+ ##### weakNet?
260
+
261
+ > `optional` **weakNet**: `boolean`
262
+
263
+ 是否处于弱网环境。
264
+
265
+ <a id="networktype-2"></a>
266
+ <a id="networktype"></a>
267
+ ### NetworkType
268
+
269
+ > **NetworkType**: `"wifi"` \| `"2g"` \| `"3g"` \| `"4g"` \| `"5g"` \| `"unknown"` \| `"none"`
270
+
271
+ 网络类型。
272
+
273
+ - `wifi` - Wi-Fi 网络
274
+ - `2g` - 2G 网络
275
+ - `3g` - 3G 网络
276
+ - `4g` - 4G 网络
277
+ - `5g` - 5G 网络
278
+ - `unknown` - Android 下不常见的网络类型
279
+ - `none` - 无网络
280
+
281
+ <a id="getlocalipaddressresult"></a>
282
+ ### GetLocalIPAddressResult
283
+
284
+ 获取局域网 IP 的返回结果。
285
+
286
+ #### Properties
287
+
288
+ ##### localIp
289
+
290
+ > **localIp**: `string`
291
+
292
+ 本机局域网 IP 地址。
293
+
294
+ ##### netmask?
295
+
296
+ > `optional` **netmask**: `string`
297
+
298
+ 子网掩码。
@@ -0,0 +1,346 @@
1
+ # Open API: Media
2
+
3
+ 图片选择、预览、保存、压缩和信息读取。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
+ | --- | --- | --- | --- | --- | --- |
11
+ | [`saveImageToPhotosAlbum`](#saveimagetophotosalbum) | `saveImageToPhotosAlbum(params): Promise<object>` | 保存图片到系统相册 | `params: SaveImageToPhotosAlbumParams` | `Promise<object>` | - |
12
+ | [`previewImage`](#previewimage) | `previewImage(params): Promise<object>` | 预览图片 | `params: PreviewImageParams` | `Promise<object>` | - |
13
+ | [`getImageInfo`](#getimageinfo) | `getImageInfo(params): Promise<GetImageInfoResult>` | 获取图片信息 | `params: GetImageInfoParams` | `Promise<GetImageInfoResult>` | - |
14
+ | [`chooseImage`](#chooseimage) | `chooseImage(params?): Promise<ChooseImageResult>` | 选择图片 | `params?: ChooseImageParams` | `Promise<ChooseImageResult>` | - |
15
+ | [`compressImage`](#compressimage) | `compressImage(params): Promise<CompressImageResult>` | 压缩图片 | `params: CompressImageParams` | `Promise<CompressImageResult>` | - |
16
+
17
+ ## API 详情
18
+
19
+ <a id="saveimagetophotosalbum"></a>
20
+ ### saveImageToPhotosAlbum()
21
+
22
+ > **saveImageToPhotosAlbum**(`params`): `Promise`\<`object`\>
23
+
24
+ 保存图片到系统相册。
25
+
26
+ 需要先确保应用已具备写入系统相册的权限。
27
+
28
+ #### Parameters
29
+
30
+ • **params**: [`SaveImageToPhotosAlbumParams`](#saveimagetophotosalbumparams)
31
+
32
+ #### Returns
33
+
34
+ `Promise`\<`object`\>
35
+
36
+ #### Example
37
+
38
+ ```typescript
39
+ import { saveImageToPhotosAlbum } from '@doubao-apps/framework/api';
40
+
41
+ await saveImageToPhotosAlbum({
42
+ filePath: '/path/to/image.png'
43
+ });
44
+ ```
45
+
46
+ <a id="previewimage"></a>
47
+ ### previewImage()
48
+
49
+ > **previewImage**(`params`): `Promise`\<`object`\>
50
+
51
+ 预览图片。
52
+
53
+ #### Parameters
54
+
55
+ • **params**: [`PreviewImageParams`](#previewimageparams)
56
+
57
+ #### Returns
58
+
59
+ `Promise`\<`object`\>
60
+
61
+ <a id="getimageinfo"></a>
62
+ ### getImageInfo()
63
+
64
+ > **getImageInfo**(`params`): `Promise`\<[`GetImageInfoResult`](#getimageinforesult)\>
65
+
66
+ 获取图片信息。
67
+
68
+ #### Parameters
69
+
70
+ • **params**: [`GetImageInfoParams`](#getimageinfoparams)
71
+
72
+ #### Returns
73
+
74
+ `Promise`\<[`GetImageInfoResult`](#getimageinforesult)\>
75
+
76
+ <a id="chooseimage"></a>
77
+ ### chooseImage()
78
+
79
+ > **chooseImage**(`params`?): `Promise`\<[`ChooseImageResult`](#chooseimageresult)\>
80
+
81
+ 选择图片。
82
+
83
+ #### Parameters
84
+
85
+ • **params?**: [`ChooseImageParams`](#chooseimageparams)
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<[`ChooseImageResult`](#chooseimageresult)\>
90
+
91
+ <a id="compressimage"></a>
92
+ ### compressImage()
93
+
94
+ > **compressImage**(`params`): `Promise`\<[`CompressImageResult`](#compressimageresult)\>
95
+
96
+ 压缩图片。
97
+
98
+ #### Parameters
99
+
100
+ • **params**: [`CompressImageParams`](#compressimageparams)
101
+
102
+ #### Returns
103
+
104
+ `Promise`\<[`CompressImageResult`](#compressimageresult)\>
105
+
106
+ ## 相关类型
107
+
108
+ <a id="saveimagetophotosalbumparams"></a>
109
+ ### SaveImageToPhotosAlbumParams
110
+
111
+ 保存图片到系统相册的请求参数。
112
+
113
+ #### Properties
114
+
115
+ ##### filePath
116
+
117
+ > **filePath**: `string`
118
+
119
+ 需要保存的图片文件路径。支持临时文件路径或持久文件路径,不支持网络图片路径。
120
+
121
+ <a id="previewimageparams"></a>
122
+ ### PreviewImageParams
123
+
124
+ 预览图片的请求参数。
125
+
126
+ #### Properties
127
+
128
+ ##### current?
129
+
130
+ > `optional` **current**: `string` \| `number`
131
+
132
+ 当前显示图片的链接,或当前显示图片的下标,不填则默认为 urls 中的第一张
133
+
134
+ ##### referrerPolicy?
135
+
136
+ > `optional` **referrerPolicy**: `string`
137
+
138
+ 预览页使用的 Referrer 策略。
139
+
140
+ ##### showmenu?
141
+
142
+ > `optional` **showmenu**: `boolean`
143
+
144
+ 是否显示长按菜单,菜单支持保存图片至本地相册
145
+
146
+ ##### urls
147
+
148
+ > **urls**: `string`[]
149
+
150
+ 需要预览的图片链接列表。
151
+
152
+ <a id="getimageinfoparams"></a>
153
+ ### GetImageInfoParams
154
+
155
+ 获取图片信息的请求参数。
156
+
157
+ #### Properties
158
+
159
+ ##### src
160
+
161
+ > **src**: `string`
162
+
163
+ 图片路径,可以是相对路径、临时文件路径、存储文件路径或网络图片路径。
164
+
165
+ <a id="getimageinforesult"></a>
166
+ ### GetImageInfoResult
167
+
168
+ 图片信息结果。
169
+
170
+ #### Properties
171
+
172
+ ##### height
173
+
174
+ > **height**: `number`
175
+
176
+ 图片原始高度,单位 px,不考虑旋转。
177
+
178
+ ##### orientation
179
+
180
+ > **orientation**: [`ImageOrientation`](#imageorientation)
181
+
182
+ 图片方向。
183
+
184
+ ##### path
185
+
186
+ > **path**: `string`
187
+
188
+ 图片的本地路径。
189
+
190
+ ##### type
191
+
192
+ > **type**: `string`
193
+
194
+ 图片格式。
195
+
196
+ ##### width
197
+
198
+ > **width**: `number`
199
+
200
+ 图片原始宽度,单位 px,不考虑旋转。
201
+
202
+ <a id="imageorientation"></a>
203
+ ### ImageOrientation
204
+
205
+ > **ImageOrientation**: `"up"` \| `"up-mirrored"` \| `"down"` \| `"down-mirrored"` \| `"left-mirrored"` \| `"right"` \| `"right-mirrored"` \| `"left"`
206
+
207
+ 图片方向枚举。
208
+
209
+ <a id="chooseimageparams"></a>
210
+ ### ChooseImageParams
211
+
212
+ 选择图片的请求参数。
213
+
214
+ #### Properties
215
+
216
+ ##### count?
217
+
218
+ > `optional` **count**: `number`
219
+
220
+ 最多可选图片张数。
221
+
222
+ ##### imageId?
223
+
224
+ > `optional` **imageId**: `string`
225
+
226
+ H5 场景下可复用的 input 元素 ID。
227
+
228
+ ##### sizeType?
229
+
230
+ > `optional` **sizeType**: [`ChooseImageSizeType`](#chooseimagesizetype)[]
231
+
232
+ 允许返回的图片尺寸类型。
233
+
234
+ ##### sourceType?
235
+
236
+ > `optional` **sourceType**: [`ChooseImageSourceType`](#chooseimagesourcetype)[]
237
+
238
+ 允许选择的图片来源。
239
+
240
+ <a id="chooseimageresult"></a>
241
+ ### ChooseImageResult
242
+
243
+ 选择图片结果。
244
+
245
+ #### Properties
246
+
247
+ ##### tempFilePaths
248
+
249
+ > **tempFilePaths**: `string`[]
250
+
251
+ 图片临时文件路径列表。
252
+
253
+ ##### tempFiles
254
+
255
+ > **tempFiles**: [`ChooseImageFile`](#chooseimagefile)[]
256
+
257
+ 图片临时文件信息列表。
258
+
259
+ <a id="chooseimagesizetype"></a>
260
+ ### ChooseImageSizeType
261
+
262
+ > **ChooseImageSizeType**: `"original"` \| `"compressed"`
263
+
264
+ 可选的图片尺寸类型。
265
+
266
+ <a id="chooseimagesourcetype"></a>
267
+ ### ChooseImageSourceType
268
+
269
+ > **ChooseImageSourceType**: `"album"` \| `"camera"` \| `"user"` \| `"environment"`
270
+
271
+ 可选的图片来源类型。
272
+
273
+ <a id="chooseimagefile"></a>
274
+ ### ChooseImageFile
275
+
276
+ 选择图片返回的单个文件信息。
277
+
278
+ #### Properties
279
+
280
+ ##### originalFileObj?
281
+
282
+ > `optional` **originalFileObj**: `File`
283
+
284
+ 原始浏览器 File 对象。
285
+
286
+ ##### path
287
+
288
+ > **path**: `string`
289
+
290
+ 本地临时文件路径。
291
+
292
+ ##### size
293
+
294
+ > **size**: `number`
295
+
296
+ 文件大小,单位 B。
297
+
298
+ ##### type?
299
+
300
+ > `optional` **type**: `string`
301
+
302
+ 文件 MIME 类型。
303
+
304
+ <a id="compressimageparams"></a>
305
+ ### CompressImageParams
306
+
307
+ 压缩图片的请求参数。
308
+
309
+ #### Properties
310
+
311
+ ##### compressedHeight?
312
+
313
+ > `optional` **compressedHeight**: `number`
314
+
315
+ 压缩后图片高度,单位 px。
316
+
317
+ ##### compressedWidth?
318
+
319
+ > `optional` **compressedWidth**: `number`
320
+
321
+ 压缩后图片宽度,单位 px。
322
+
323
+ ##### quality?
324
+
325
+ > `optional` **quality**: `number`
326
+
327
+ 压缩质量,范围 0 - 100,仅对 jpg 生效。
328
+
329
+ ##### src
330
+
331
+ > **src**: `string`
332
+
333
+ 图片路径。
334
+
335
+ <a id="compressimageresult"></a>
336
+ ### CompressImageResult
337
+
338
+ 压缩图片结果。
339
+
340
+ #### Properties
341
+
342
+ ##### tempFilePath
343
+
344
+ > **tempFilePath**: `string`
345
+
346
+ 压缩后图片的临时文件路径。