@doubao-apps/create 0.0.26 → 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.
- package/dist/36.js +4 -4
- package/dist/template-empty/.ai/examples/common-patterns.md +53 -43
- package/dist/template-empty/.ai/examples/component-basics.md +0 -17
- package/dist/template-empty/.ai/guides/component-development.md +96 -214
- package/dist/template-empty/.ai/guides/system-prompt.md +14 -14
- package/dist/template-empty/.ai/reference/framework-api-quick-ref.md +46 -85
- 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 +13 -13
- package/dist/template-empty/.ai/reference/open-api/{02-storage.md → 02-/345/255/230/345/202/250.md} +13 -21
- package/dist/template-empty/.ai/reference/open-api/{03-router.md → 03-/350/267/257/347/224/261.md} +9 -9
- package/dist/{template-starter/.ai/reference/open-api/04-ui- → template-empty/.ai/reference/open-api/04-/347/225/214/351/235/242-}/344/272/244/344/272/222.md +12 -12
- package/dist/template-empty/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
- package/dist/template-empty/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
- package/dist/template-empty/.ai/reference/open-api/{07-media.md → 07-/345/252/222/344/275/223.md} +8 -8
- package/dist/template-empty/.ai/reference/open-api/{08-open- → 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 +83 -14
- package/dist/{template-starter/.ai/reference/open-api/09-device-bluetooth.md → template-empty/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md} +22 -46
- package/dist/{template-starter/.ai/reference/open-api/10-device-wi-fi.md → template-empty/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md} +9 -9
- 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
- package/dist/template-empty/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
- package/dist/template-empty/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
- 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
- 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
- package/dist/template-empty/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
- package/dist/template-empty/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
- package/dist/template-empty/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
- 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
- package/dist/template-empty/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
- package/dist/template-empty/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
- 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
- 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
- package/dist/template-empty/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
- package/dist/template-empty/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
- package/dist/template-empty/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
- package/dist/template-empty/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
- package/dist/template-empty/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
- package/dist/template-empty/.ai/reference/open-api/README.md +27 -11
- package/dist/template-empty/.ai/reference/open-api.md +275 -8
- package/dist/template-empty/.ai/rules/dos-and-donts.md +50 -37
- package/dist/template-empty/AGENTS.md +54 -31
- package/dist/template-empty/README.md +57 -10
- package/dist/template-empty/package.json +2 -2
- package/dist/template-empty/src/app.config.ts +6 -0
- package/dist/template-empty/src/app.ts +0 -6
- package/dist/template-empty/tsconfig.json +2 -0
- package/dist/template-starter/.ai/examples/common-patterns.md +53 -43
- package/dist/template-starter/.ai/examples/component-basics.md +0 -17
- package/dist/template-starter/.ai/guides/component-development.md +96 -214
- package/dist/template-starter/.ai/guides/system-prompt.md +14 -14
- package/dist/template-starter/.ai/reference/framework-api-quick-ref.md +46 -85
- 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 +13 -13
- package/dist/template-starter/.ai/reference/open-api/{02-storage.md → 02-/345/255/230/345/202/250.md} +13 -21
- package/dist/template-starter/.ai/reference/open-api/{03-router.md → 03-/350/267/257/347/224/261.md} +9 -9
- package/dist/{template-empty/.ai/reference/open-api/04-ui- → template-starter/.ai/reference/open-api/04-/347/225/214/351/235/242-}/344/272/244/344/272/222.md +12 -12
- package/dist/template-starter/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
- package/dist/template-starter/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
- package/dist/template-starter/.ai/reference/open-api/{07-media.md → 07-/345/252/222/344/275/223.md} +8 -8
- package/dist/template-starter/.ai/reference/open-api/{08-open- → 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 +83 -14
- package/dist/{template-empty/.ai/reference/open-api/09-device-bluetooth.md → template-starter/.ai/reference/open-api/09-/350/256/276/345/244/207-/350/223/235/347/211/231.md} +22 -46
- package/dist/{template-empty/.ai/reference/open-api/10-device-wi-fi.md → template-starter/.ai/reference/open-api/10-/350/256/276/345/244/207-wi-fi.md} +9 -9
- 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
- package/dist/template-starter/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
- package/dist/template-starter/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
- 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
- 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
- package/dist/template-starter/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
- package/dist/template-starter/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
- package/dist/template-starter/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
- 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
- package/dist/template-starter/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
- package/dist/template-starter/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
- 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
- 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
- package/dist/template-starter/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
- package/dist/template-starter/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
- package/dist/template-starter/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
- package/dist/template-starter/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
- package/dist/template-starter/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
- package/dist/template-starter/.ai/reference/open-api/README.md +27 -11
- package/dist/template-starter/.ai/reference/open-api.md +275 -8
- package/dist/template-starter/.ai/rules/dos-and-donts.md +50 -37
- package/dist/template-starter/AGENTS.md +54 -31
- package/dist/template-starter/README.md +6 -1
- package/dist/template-starter/package.json +2 -2
- package/dist/template-starter/src/app.config.ts +35 -0
- package/dist/template-starter/src/app.ts +0 -6
- package/dist/template-starter/src/pages/applet/index.tsx +0 -5
- package/dist/template-starter/src/pages/home/index.tsx +0 -5
- package/dist/template-starter/src/pages/lynx/index.tsx +0 -4
- package/dist/template-starter/src/pages/react-lynx/index.tsx +0 -5
- package/dist/template-starter/src/widgets/weather-card/index.tsx +0 -4
- package/dist/template-starter/tsconfig.json +2 -0
- package/package.json +1 -1
- package/dist/template-empty/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +0 -95
- package/dist/template-empty/.ai/reference/open-api/06-network.md +0 -298
- package/dist/template-empty/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +0 -372
- package/dist/template-empty/.ai/reference/open-api/12-device-/346/234/254/345/234/260/350/203/275/345/212/233.md +0 -1005
- package/dist/template-starter/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +0 -95
- package/dist/template-starter/.ai/reference/open-api/06-network.md +0 -298
- package/dist/template-starter/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +0 -372
- package/dist/template-starter/.ai/reference/open-api/12-device-/346/234/254/345/234/260/350/203/275/345/212/233.md +0 -1005
|
@@ -399,6 +399,35 @@ closePage();
|
|
|
399
399
|
|
|
400
400
|
***
|
|
401
401
|
|
|
402
|
+
### expiredWidget()
|
|
403
|
+
|
|
404
|
+
> **expiredWidget**(`__namedParameters`): `Promise`\<`object`\>
|
|
405
|
+
|
|
406
|
+
更新过期的 widget 为固定卡片
|
|
407
|
+
|
|
408
|
+
#### Parameters
|
|
409
|
+
|
|
410
|
+
• **\_\_namedParameters**: [`ExpiredWidgetParams`](doubao-apps-sdk-open-api.md#expiredwidgetparams)
|
|
411
|
+
|
|
412
|
+
#### Returns
|
|
413
|
+
|
|
414
|
+
`Promise`\<`object`\>
|
|
415
|
+
|
|
416
|
+
#### Description
|
|
417
|
+
|
|
418
|
+
用于将状态已经过期的 widget 实例转换为固定的卡片
|
|
419
|
+
|
|
420
|
+
#### Example
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
expiredWidget({
|
|
424
|
+
widgetInstanceId: 'instance_123',
|
|
425
|
+
schema: '${pageId}?key=value'
|
|
426
|
+
});
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
***
|
|
430
|
+
|
|
402
431
|
### getAccountInfo()
|
|
403
432
|
|
|
404
433
|
> **getAccountInfo**(`params`?): `Promise`\<[`GetAccountInfoResult`](doubao-apps-sdk-open-api.md#getaccountinforesult)\>
|
|
@@ -947,8 +976,6 @@ console.log(result.networkType);
|
|
|
947
976
|
|
|
948
977
|
#### Remarks
|
|
949
978
|
|
|
950
|
-
data 会 JSON 反序列化。
|
|
951
|
-
|
|
952
979
|
#### Example
|
|
953
980
|
|
|
954
981
|
```typescript
|
|
@@ -1043,8 +1070,6 @@ console.log(result.keys, result.currentSize, result.limitSize);
|
|
|
1043
1070
|
|
|
1044
1071
|
#### Remarks
|
|
1045
1072
|
|
|
1046
|
-
data 会 JSON 反序列化。
|
|
1047
|
-
|
|
1048
1073
|
#### Example
|
|
1049
1074
|
|
|
1050
1075
|
```typescript
|
|
@@ -1354,6 +1379,74 @@ Widget 登录参数。
|
|
|
1354
1379
|
|
|
1355
1380
|
***
|
|
1356
1381
|
|
|
1382
|
+
### onAccelerometerChange()
|
|
1383
|
+
|
|
1384
|
+
> **onAccelerometerChange**(`handler`): () => `void`
|
|
1385
|
+
|
|
1386
|
+
监听加速度数据变化事件。
|
|
1387
|
+
|
|
1388
|
+
#### Parameters
|
|
1389
|
+
|
|
1390
|
+
• **handler**
|
|
1391
|
+
|
|
1392
|
+
#### Returns
|
|
1393
|
+
|
|
1394
|
+
`Function`
|
|
1395
|
+
|
|
1396
|
+
返回取消当前监听函数的函数。
|
|
1397
|
+
|
|
1398
|
+
##### Returns
|
|
1399
|
+
|
|
1400
|
+
`void`
|
|
1401
|
+
|
|
1402
|
+
#### Example
|
|
1403
|
+
|
|
1404
|
+
```ts
|
|
1405
|
+
import { onAccelerometerChange } from '@doubao-apps/framework/api';
|
|
1406
|
+
|
|
1407
|
+
const off = onAccelerometerChange(({ x, y, z, timestamp }) => {
|
|
1408
|
+
console.log(x, y, z, timestamp);
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
off();
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
***
|
|
1415
|
+
|
|
1416
|
+
### onBatteryInfoChange()
|
|
1417
|
+
|
|
1418
|
+
> **onBatteryInfoChange**(`handler`): () => `void`
|
|
1419
|
+
|
|
1420
|
+
监听电池信息变化事件。
|
|
1421
|
+
|
|
1422
|
+
#### Parameters
|
|
1423
|
+
|
|
1424
|
+
• **handler**
|
|
1425
|
+
|
|
1426
|
+
#### Returns
|
|
1427
|
+
|
|
1428
|
+
`Function`
|
|
1429
|
+
|
|
1430
|
+
返回取消当前监听函数的函数。
|
|
1431
|
+
|
|
1432
|
+
##### Returns
|
|
1433
|
+
|
|
1434
|
+
`void`
|
|
1435
|
+
|
|
1436
|
+
#### Example
|
|
1437
|
+
|
|
1438
|
+
```ts
|
|
1439
|
+
import { onBatteryInfoChange } from '@doubao-apps/framework/api';
|
|
1440
|
+
|
|
1441
|
+
const off = onBatteryInfoChange(({ isLowPowerModeEnabled }) => {
|
|
1442
|
+
console.log(isLowPowerModeEnabled);
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
off();
|
|
1446
|
+
```
|
|
1447
|
+
|
|
1448
|
+
***
|
|
1449
|
+
|
|
1357
1450
|
### onCompassChange()
|
|
1358
1451
|
|
|
1359
1452
|
> **onCompassChange**(`handler`): () => `void`
|
|
@@ -1388,6 +1481,40 @@ off();
|
|
|
1388
1481
|
|
|
1389
1482
|
***
|
|
1390
1483
|
|
|
1484
|
+
### onGyroscopeChange()
|
|
1485
|
+
|
|
1486
|
+
> **onGyroscopeChange**(`handler`): () => `void`
|
|
1487
|
+
|
|
1488
|
+
监听陀螺仪数据变化事件。
|
|
1489
|
+
|
|
1490
|
+
#### Parameters
|
|
1491
|
+
|
|
1492
|
+
• **handler**
|
|
1493
|
+
|
|
1494
|
+
#### Returns
|
|
1495
|
+
|
|
1496
|
+
`Function`
|
|
1497
|
+
|
|
1498
|
+
返回取消当前监听函数的函数。
|
|
1499
|
+
|
|
1500
|
+
##### Returns
|
|
1501
|
+
|
|
1502
|
+
`void`
|
|
1503
|
+
|
|
1504
|
+
#### Example
|
|
1505
|
+
|
|
1506
|
+
```ts
|
|
1507
|
+
import { onGyroscopeChange } from '@doubao-apps/framework/api';
|
|
1508
|
+
|
|
1509
|
+
const off = onGyroscopeChange(({ x, y, z, timestamp }) => {
|
|
1510
|
+
console.log(x, y, z, timestamp);
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
off();
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
***
|
|
1517
|
+
|
|
1391
1518
|
### onKeyboardHeightChange()
|
|
1392
1519
|
|
|
1393
1520
|
> **onKeyboardHeightChange**(`handler`): () => `void`
|
|
@@ -1935,8 +2062,6 @@ await sendSms({
|
|
|
1935
2062
|
|
|
1936
2063
|
#### Remarks
|
|
1937
2064
|
|
|
1938
|
-
data 会 JSON 序列化。
|
|
1939
|
-
|
|
1940
2065
|
#### Example
|
|
1941
2066
|
|
|
1942
2067
|
```typescript
|
|
@@ -1974,8 +2099,6 @@ await setStorage({
|
|
|
1974
2099
|
|
|
1975
2100
|
#### Remarks
|
|
1976
2101
|
|
|
1977
|
-
data 会 JSON 序列化。
|
|
1978
|
-
|
|
1979
2102
|
#### Example
|
|
1980
2103
|
|
|
1981
2104
|
```typescript
|
|
@@ -2522,6 +2645,38 @@ value 需要是 ArrayBuffer。
|
|
|
2522
2645
|
|
|
2523
2646
|
## Interfaces
|
|
2524
2647
|
|
|
2648
|
+
### AccelerometerChangeEvent
|
|
2649
|
+
|
|
2650
|
+
加速度数据变化事件。
|
|
2651
|
+
|
|
2652
|
+
#### Properties
|
|
2653
|
+
|
|
2654
|
+
##### timestamp
|
|
2655
|
+
|
|
2656
|
+
> **timestamp**: `number`
|
|
2657
|
+
|
|
2658
|
+
数据采集时间戳,单位纳秒。
|
|
2659
|
+
|
|
2660
|
+
##### x
|
|
2661
|
+
|
|
2662
|
+
> **x**: `number`
|
|
2663
|
+
|
|
2664
|
+
X 轴加速度,单位 m/s²。
|
|
2665
|
+
|
|
2666
|
+
##### y
|
|
2667
|
+
|
|
2668
|
+
> **y**: `number`
|
|
2669
|
+
|
|
2670
|
+
Y 轴加速度,单位 m/s²。
|
|
2671
|
+
|
|
2672
|
+
##### z
|
|
2673
|
+
|
|
2674
|
+
> **z**: `number`
|
|
2675
|
+
|
|
2676
|
+
Z 轴加速度,单位 m/s²。
|
|
2677
|
+
|
|
2678
|
+
***
|
|
2679
|
+
|
|
2525
2680
|
### AddPhoneCalendarParams
|
|
2526
2681
|
|
|
2527
2682
|
添加系统日历事件的请求参数。
|
|
@@ -2910,6 +3065,20 @@ value 需要是 ArrayBuffer。
|
|
|
2910
3065
|
|
|
2911
3066
|
***
|
|
2912
3067
|
|
|
3068
|
+
### BatteryInfoChangeEvent
|
|
3069
|
+
|
|
3070
|
+
电池信息变化事件。
|
|
3071
|
+
|
|
3072
|
+
#### Properties
|
|
3073
|
+
|
|
3074
|
+
##### isLowPowerModeEnabled
|
|
3075
|
+
|
|
3076
|
+
> **isLowPowerModeEnabled**: `boolean`
|
|
3077
|
+
|
|
3078
|
+
是否处于省电模式。
|
|
3079
|
+
|
|
3080
|
+
***
|
|
3081
|
+
|
|
2913
3082
|
### BeaconInfo
|
|
2914
3083
|
|
|
2915
3084
|
iBeacon 设备信息。
|
|
@@ -3548,6 +3717,24 @@ Wi-Fi SSID。
|
|
|
3548
3717
|
|
|
3549
3718
|
***
|
|
3550
3719
|
|
|
3720
|
+
### ExpiredWidgetParams
|
|
3721
|
+
|
|
3722
|
+
#### Properties
|
|
3723
|
+
|
|
3724
|
+
##### schema?
|
|
3725
|
+
|
|
3726
|
+
> `optional` **schema**: `string`
|
|
3727
|
+
|
|
3728
|
+
点击失效卡要跳转的页面 schema,格式与 navigateTo 的 url 相同
|
|
3729
|
+
|
|
3730
|
+
##### widgetInstanceId
|
|
3731
|
+
|
|
3732
|
+
> **widgetInstanceId**: `string`
|
|
3733
|
+
|
|
3734
|
+
卡片实例 ID,在卡片环境通过getWidgetInstanceId来获取,其他环境(比如页面)需要通过传参或通信的方式传递过去
|
|
3735
|
+
|
|
3736
|
+
***
|
|
3737
|
+
|
|
3551
3738
|
### GetAccountInfoResult
|
|
3552
3739
|
|
|
3553
3740
|
获取当前账号信息。
|
|
@@ -4287,6 +4474,38 @@ Wi-Fi 的系统开关
|
|
|
4287
4474
|
|
|
4288
4475
|
***
|
|
4289
4476
|
|
|
4477
|
+
### GyroscopeChangeEvent
|
|
4478
|
+
|
|
4479
|
+
陀螺仪数据变化事件。
|
|
4480
|
+
|
|
4481
|
+
#### Properties
|
|
4482
|
+
|
|
4483
|
+
##### timestamp
|
|
4484
|
+
|
|
4485
|
+
> **timestamp**: `number`
|
|
4486
|
+
|
|
4487
|
+
数据采集时间戳,单位纳秒。
|
|
4488
|
+
|
|
4489
|
+
##### x
|
|
4490
|
+
|
|
4491
|
+
> **x**: `number`
|
|
4492
|
+
|
|
4493
|
+
绕 X 轴旋转的角速度,单位 rad/s。
|
|
4494
|
+
|
|
4495
|
+
##### y
|
|
4496
|
+
|
|
4497
|
+
> **y**: `number`
|
|
4498
|
+
|
|
4499
|
+
绕 Y 轴旋转的角速度,单位 rad/s。
|
|
4500
|
+
|
|
4501
|
+
##### z
|
|
4502
|
+
|
|
4503
|
+
> **z**: `number`
|
|
4504
|
+
|
|
4505
|
+
绕 Z 轴旋转的角速度,单位 rad/s。
|
|
4506
|
+
|
|
4507
|
+
***
|
|
4508
|
+
|
|
4290
4509
|
### HideInteractionParams
|
|
4291
4510
|
|
|
4292
4511
|
隐藏交互提示框的公共参数。
|
|
@@ -5566,6 +5785,38 @@ Wi-Fi SSID。
|
|
|
5566
5785
|
|
|
5567
5786
|
## Type Aliases
|
|
5568
5787
|
|
|
5788
|
+
### AccelerometerChangeListener()
|
|
5789
|
+
|
|
5790
|
+
> **AccelerometerChangeListener**: (`event`) => `void`
|
|
5791
|
+
|
|
5792
|
+
加速度数据变化事件监听函数。
|
|
5793
|
+
|
|
5794
|
+
#### Parameters
|
|
5795
|
+
|
|
5796
|
+
• **event**: [`AccelerometerChangeEvent`](doubao-apps-sdk-open-api.md#accelerometerchangeevent)
|
|
5797
|
+
|
|
5798
|
+
#### Returns
|
|
5799
|
+
|
|
5800
|
+
`void`
|
|
5801
|
+
|
|
5802
|
+
***
|
|
5803
|
+
|
|
5804
|
+
### BatteryInfoChangeListener()
|
|
5805
|
+
|
|
5806
|
+
> **BatteryInfoChangeListener**: (`event`) => `void`
|
|
5807
|
+
|
|
5808
|
+
电池信息变化事件监听函数。
|
|
5809
|
+
|
|
5810
|
+
#### Parameters
|
|
5811
|
+
|
|
5812
|
+
• **event**: [`BatteryInfoChangeEvent`](doubao-apps-sdk-open-api.md#batteryinfochangeevent)
|
|
5813
|
+
|
|
5814
|
+
#### Returns
|
|
5815
|
+
|
|
5816
|
+
`void`
|
|
5817
|
+
|
|
5818
|
+
***
|
|
5819
|
+
|
|
5569
5820
|
### BeaconProximity
|
|
5570
5821
|
|
|
5571
5822
|
> **BeaconProximity**: `0` \| `1` \| `2` \| `3`
|
|
@@ -5668,6 +5919,22 @@ iBeacon 距离等级。
|
|
|
5668
5919
|
|
|
5669
5920
|
***
|
|
5670
5921
|
|
|
5922
|
+
### GyroscopeChangeListener()
|
|
5923
|
+
|
|
5924
|
+
> **GyroscopeChangeListener**: (`event`) => `void`
|
|
5925
|
+
|
|
5926
|
+
陀螺仪数据变化事件监听函数。
|
|
5927
|
+
|
|
5928
|
+
#### Parameters
|
|
5929
|
+
|
|
5930
|
+
• **event**: [`GyroscopeChangeEvent`](doubao-apps-sdk-open-api.md#gyroscopechangeevent)
|
|
5931
|
+
|
|
5932
|
+
#### Returns
|
|
5933
|
+
|
|
5934
|
+
`void`
|
|
5935
|
+
|
|
5936
|
+
***
|
|
5937
|
+
|
|
5671
5938
|
### ImageOrientation
|
|
5672
5939
|
|
|
5673
5940
|
> **ImageOrientation**: `"up"` \| `"up-mirrored"` \| `"down"` \| `"down-mirrored"` \| `"left-mirrored"` \| `"right"` \| `"right-mirrored"` \| `"left"`
|
|
@@ -87,19 +87,6 @@ interface UserInfo {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export default defineWidget({
|
|
90
|
-
aiMeta: {
|
|
91
|
-
id: 'user-card',
|
|
92
|
-
name: '用户卡片',
|
|
93
|
-
input: {
|
|
94
|
-
type: 'object',
|
|
95
|
-
properties: {
|
|
96
|
-
name: { type: 'string', title: '姓名' },
|
|
97
|
-
age: { type: 'number', title: '年龄' },
|
|
98
|
-
avatar: { type: 'string', title: '头像' }
|
|
99
|
-
},
|
|
100
|
-
required: ['name', 'age']
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
90
|
render() {
|
|
104
91
|
const input = getViewData<UserInfo>();
|
|
105
92
|
return <view>{input.name}</view>;
|
|
@@ -107,6 +94,21 @@ export default defineWidget({
|
|
|
107
94
|
});
|
|
108
95
|
```
|
|
109
96
|
|
|
97
|
+
```ts
|
|
98
|
+
// ✅ 把 metadata 写到 src/app.config.ts
|
|
99
|
+
import { defineAppConfig } from '@doubao-apps/kit';
|
|
100
|
+
|
|
101
|
+
export default defineAppConfig({
|
|
102
|
+
widgets: {
|
|
103
|
+
'widgets/user-card': {
|
|
104
|
+
id: 'user-card',
|
|
105
|
+
name: '用户卡片',
|
|
106
|
+
description: '用户信息卡片'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
110
112
|
```tsx
|
|
111
113
|
// ❌ 不好的做法
|
|
112
114
|
export default defineWidget({
|
|
@@ -247,20 +249,26 @@ export default definePage({
|
|
|
247
249
|
```
|
|
248
250
|
|
|
249
251
|
```tsx
|
|
250
|
-
// ✅
|
|
251
|
-
|
|
252
|
-
data: {
|
|
253
|
-
userData: null
|
|
254
|
-
},
|
|
252
|
+
// ✅ 推荐 - 使用 Hook 管理请求和状态
|
|
253
|
+
import { useEffect, useState } from '@doubao-apps/framework';
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
function UserPage() {
|
|
256
|
+
const [userData, setUserData] = useState<{ name?: string } | null>(null);
|
|
257
|
+
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
fetch('/api/data')
|
|
260
|
+
.then(res => res.json())
|
|
261
|
+
.then(data => {
|
|
262
|
+
setUserData(data);
|
|
263
|
+
});
|
|
264
|
+
}, []);
|
|
261
265
|
|
|
266
|
+
return <view>{userData?.name}</view>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export default definePage({
|
|
262
270
|
render() {
|
|
263
|
-
return <
|
|
271
|
+
return <UserPage />;
|
|
264
272
|
}
|
|
265
273
|
});
|
|
266
274
|
```
|
|
@@ -351,21 +359,26 @@ export default defineWidget({
|
|
|
351
359
|
```
|
|
352
360
|
|
|
353
361
|
```tsx
|
|
354
|
-
// ✅
|
|
362
|
+
// ✅ 推荐 - 使用组件内状态,实例之间互不影响
|
|
363
|
+
import { useState } from '@doubao-apps/framework';
|
|
364
|
+
|
|
365
|
+
function CounterWidget() {
|
|
366
|
+
const [count, setCount] = useState(0);
|
|
367
|
+
|
|
368
|
+
return (
|
|
369
|
+
<view
|
|
370
|
+
onClick={() => {
|
|
371
|
+
setCount(prev => prev + 1);
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
Count: {count}
|
|
375
|
+
</view>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
355
379
|
export default defineWidget({
|
|
356
|
-
data: {
|
|
357
|
-
count: 0
|
|
358
|
-
},
|
|
359
380
|
render() {
|
|
360
|
-
return
|
|
361
|
-
<view
|
|
362
|
-
onClick={() => {
|
|
363
|
-
this.setData({ count: this.data.count + 1 });
|
|
364
|
-
}}
|
|
365
|
-
>
|
|
366
|
-
Count: {this.data.count}
|
|
367
|
-
</view>
|
|
368
|
-
);
|
|
381
|
+
return <CounterWidget />;
|
|
369
382
|
}
|
|
370
383
|
});
|
|
371
384
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Doubao Apps SDK AI 开发指南
|
|
2
2
|
|
|
3
3
|
本文件专供 AI coding agents(如 Claude、Copilot、Cursor)和开发者使用,提供 Doubao Apps SDK 框架的快速入门、开发规则和文档导航。
|
|
4
4
|
|
|
@@ -31,7 +31,6 @@ pnpm install
|
|
|
31
31
|
|
|
32
32
|
# 启动开发
|
|
33
33
|
pnpm dev
|
|
34
|
-
|
|
35
34
|
```
|
|
36
35
|
|
|
37
36
|
**开发服务器命令**:
|
|
@@ -66,9 +65,9 @@ my-doubao-app/
|
|
|
66
65
|
|
|
67
66
|
- **优先使用 pnpm** 作为包管理器
|
|
68
67
|
- **分离样式文件**:每个组件使用独立的 `.scss` 文件
|
|
69
|
-
-
|
|
68
|
+
- **在 `src/app.config.ts` 中配置 metadata**:为 App、Page 和 Widget 统一配置元数据
|
|
70
69
|
- **使用生命周期钩子**:合理使用 `onShow`、`onMounted` 等
|
|
71
|
-
- **TypeScript
|
|
70
|
+
- **TypeScript 类型**:使用 `getViewData<T>()`、为 props 和 state 提供类型定义
|
|
72
71
|
- **错误处理**:处理边界情况和错误状态
|
|
73
72
|
|
|
74
73
|
### 禁止做法
|
|
@@ -92,22 +91,37 @@ my-doubao-app/
|
|
|
92
91
|
|
|
93
92
|
Page 是全屏 UI 组件,支持九宫格、浮窗等变体。
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
**metadata 配置**:
|
|
95
|
+
```ts
|
|
96
|
+
import { defineAppConfig } from '@doubao-apps/kit';
|
|
97
|
+
|
|
98
|
+
export default defineAppConfig({
|
|
99
|
+
pages: {
|
|
100
|
+
'pages/home': {
|
|
101
|
+
id: 'my-page',
|
|
102
|
+
title: '我的页面',
|
|
103
|
+
description: '页面功能描述'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**页面实现**:
|
|
96
110
|
```tsx
|
|
97
111
|
import { definePage, getViewData } from '@doubao-apps/framework';
|
|
98
112
|
import './index.scss';
|
|
99
113
|
|
|
114
|
+
interface HomePageData {
|
|
115
|
+
title: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
export default definePage({
|
|
101
|
-
aiMeta: {
|
|
102
|
-
id: 'my-page',
|
|
103
|
-
title: '我的页面',
|
|
104
|
-
},
|
|
105
119
|
onShow() {
|
|
106
120
|
// 页面显示时触发
|
|
107
121
|
},
|
|
108
122
|
render() {
|
|
109
|
-
const input = getViewData();
|
|
110
|
-
return <view
|
|
123
|
+
const input = getViewData<HomePageData>();
|
|
124
|
+
return <view>{input.title}</view>;
|
|
111
125
|
}
|
|
112
126
|
});
|
|
113
127
|
```
|
|
@@ -118,28 +132,38 @@ export default definePage({
|
|
|
118
132
|
|
|
119
133
|
Widget 是聊天流中的卡片组件,在对话中展示。
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
**metadata 配置**:
|
|
136
|
+
```ts
|
|
137
|
+
import { defineAppConfig } from '@doubao-apps/kit';
|
|
138
|
+
|
|
139
|
+
export default defineAppConfig({
|
|
140
|
+
widgets: {
|
|
141
|
+
'widgets/my-widget': {
|
|
142
|
+
id: 'my-widget',
|
|
143
|
+
name: '我的卡片',
|
|
144
|
+
description: '卡片功能描述',
|
|
145
|
+
boxType: 'inbox',
|
|
146
|
+
border: true
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**卡片实现**:
|
|
122
153
|
```tsx
|
|
123
154
|
import { defineWidget, getViewData } from '@doubao-apps/framework';
|
|
124
155
|
import './index.scss';
|
|
125
156
|
|
|
157
|
+
interface MyWidgetData {
|
|
158
|
+
title: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
126
161
|
export default defineWidget({
|
|
127
|
-
aiMeta: {
|
|
128
|
-
id: 'my-widget',
|
|
129
|
-
name: '我的卡片',
|
|
130
|
-
boxType: 'inbox',
|
|
131
|
-
input: {
|
|
132
|
-
type: 'object',
|
|
133
|
-
properties: {
|
|
134
|
-
title: { type: 'string', title: '标题' }
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
162
|
onMounted() {
|
|
139
163
|
// 卡片挂载后触发
|
|
140
164
|
},
|
|
141
165
|
render() {
|
|
142
|
-
const input = getViewData();
|
|
166
|
+
const input = getViewData<MyWidgetData>();
|
|
143
167
|
return <view>{input.title}</view>;
|
|
144
168
|
}
|
|
145
169
|
});
|
|
@@ -208,7 +232,6 @@ API 参考文档
|
|
|
208
232
|
- **[组件库](.ai/reference/components-quick-ref.md)** - SDK 内置组件速查
|
|
209
233
|
- **[Open API](.ai/reference/open-api/README.md)** - 系统能力 API 目录与详细文档
|
|
210
234
|
|
|
211
|
-
|
|
212
235
|
### 依赖包
|
|
213
236
|
|
|
214
237
|
- **Framework**:`@doubao-apps/framework` - 核心框架
|
|
@@ -243,10 +266,10 @@ API 参考文档
|
|
|
243
266
|
|
|
244
267
|
```
|
|
245
268
|
项目根目录/
|
|
246
|
-
├── AGENTS.md
|
|
247
|
-
└── .ai/
|
|
248
|
-
├── guides/
|
|
249
|
-
├── rules/
|
|
250
|
-
├── examples/
|
|
251
|
-
└── reference/
|
|
269
|
+
├── AGENTS.md # 主入口文档(AI Agent 必读)
|
|
270
|
+
└── .ai/ # 详细文档目录
|
|
271
|
+
├── guides/ # 开发指南
|
|
272
|
+
├── rules/ # 开发规则
|
|
273
|
+
├── examples/ # 代码示例
|
|
274
|
+
└── reference/ # API 参考
|
|
252
275
|
```
|
|
@@ -45,7 +45,8 @@ pnpm run analyze
|
|
|
45
45
|
├── package.json # 依赖管理
|
|
46
46
|
├── tsconfig.json # TypeScript 配置
|
|
47
47
|
├── src/
|
|
48
|
-
│ ├── app.ts
|
|
48
|
+
│ ├── app.config.ts # App / Page / Widget metadata
|
|
49
|
+
│ ├── app.ts # 应用生命周期入口
|
|
49
50
|
│ ├── pages/ # 页面组件目录
|
|
50
51
|
│ │ └── home/
|
|
51
52
|
│ │ ├── index.tsx
|
|
@@ -57,6 +58,10 @@ pnpm run analyze
|
|
|
57
58
|
└── debug-scene/ # 调试场景配置
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
### metadata 配置
|
|
62
|
+
|
|
63
|
+
项目中的 App、Page 和 Widget metadata 统一写在 `src/app.config.ts`,`src/app.ts` 和各页面/卡片入口只负责生命周期与渲染逻辑。
|
|
64
|
+
|
|
60
65
|
---
|
|
61
66
|
|
|
62
67
|
## 🤖 AI 开发支持
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"build": "doubao build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@doubao-apps/framework": "^0.0.
|
|
9
|
+
"@doubao-apps/framework": "^0.0.27"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@doubao-apps/kit": "^0.0.
|
|
12
|
+
"@doubao-apps/kit": "^0.0.27",
|
|
13
13
|
"typescript": "5.5.3"
|
|
14
14
|
},
|
|
15
15
|
"version": "0.0.16"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineAppConfig } from '@doubao-apps/kit';
|
|
2
|
+
|
|
3
|
+
export default defineAppConfig({
|
|
4
|
+
appId: '<%= appId %>',
|
|
5
|
+
name: '<%= name %>',
|
|
6
|
+
pages: {
|
|
7
|
+
'pages/home': {
|
|
8
|
+
id: 'home',
|
|
9
|
+
title: 'Doubao Apps SDK',
|
|
10
|
+
description: 'Doubao Apps SDK 欢迎页面'
|
|
11
|
+
},
|
|
12
|
+
'pages/react-lynx': {
|
|
13
|
+
id: 'react-lynx',
|
|
14
|
+
title: 'React Lynx',
|
|
15
|
+
description: '基于 React 的 UI 开发框架介绍'
|
|
16
|
+
},
|
|
17
|
+
'pages/lynx': {
|
|
18
|
+
id: 'lynx',
|
|
19
|
+
title: 'Lynx',
|
|
20
|
+
description: '高性能跨平台 UI 引擎介绍'
|
|
21
|
+
},
|
|
22
|
+
'pages/applet': {
|
|
23
|
+
id: 'applet',
|
|
24
|
+
title: 'Applet',
|
|
25
|
+
description: '小程序开发模板介绍'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
widgets: {
|
|
29
|
+
'widgets/weather-card': {
|
|
30
|
+
id: 'weather-card',
|
|
31
|
+
name: 'Weather Card',
|
|
32
|
+
description: '显示当前天气信息的卡片组件'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|