@doubao-apps/ai 0.0.35-rc.0 → 0.0.35
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 +2 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +33 -1
- package/dist/{manifest.json → public/manifest.json} +7 -2
- package/dist/{skills → public/skills}/doubao-apps-dev/SKILL.md +11 -10
- package/dist/{skills → public/skills}/doubao-apps-dev/references/examples/common-patterns.md +2 -2
- package/dist/{skills/doubao-apps-dev/references/examples/component-basics.md → public/skills/doubao-apps-dev/references/examples/page-widget-basics.md} +1 -1
- package/dist/{skills/doubao-apps-dev/references/examples/component-recipes.md → public/skills/doubao-apps-dev/references/examples/page-widget-recipes.md} +2 -3
- package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/component-development.md +2 -2
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +270 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +438 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md +32 -55
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/04-/345/255/230/345/202/250.md +18 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/05-/350/267/257/347/224/261.md +8 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/06-/344/272/244/344/272/222.md +49 -3
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/07-/350/276/223/345/205/245.md +47 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +238 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/09-/345/252/222/344/275/223.md +81 -1
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/10-/344/270/232/345/212/241/350/203/275/345/212/233.md +143 -13
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/11-/347/231/273/345/275/225.md +11 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/14-/350/223/235/347/211/231.md +212 -1
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/15-wi-fi.md +104 -27
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +122 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/17-ibeacon.md +38 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/18-/347/275/227/347/233/230.md +45 -22
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +120 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +122 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +153 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/23-/346/227/240/351/232/234/347/242/215.md +11 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/24-/345/237/272/347/241/200/344/277/241/346/201/257.md +19 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +92 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/26-/346/227/245/345/216/206.md +11 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/27-/345/211/252/350/264/264/346/235/277.md +11 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/28-/350/201/224/347/263/273/344/272/272.md +13 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/29-/345/212/240/345/257/206.md +11 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/31-/346/211/253/347/240/201.md +51 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/32-/345/261/217/345/271/225.md +60 -20
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/33-/351/234/207/345/212/250.md +11 -0
- package/dist/public/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +334 -0
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/README.md +4 -4
- package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api.md +14 -12
- package/dist/public/skills/doubao-components-api/SKILL.md +50 -0
- package/dist/public/skills/doubao-components-api/references/reference/form.md +146 -0
- package/dist/public/skills/doubao-components-api/references/reference/interactive.md +120 -0
- package/dist/public/skills/doubao-components-api/references/reference/layout-overlay.md +131 -0
- package/dist/public/skills/doubao-components-api/references/reference/layout-scroll.md +149 -0
- package/dist/public/skills/doubao-components-api/references/reference/map-canvas.md +107 -0
- package/dist/public/skills/doubao-components-api/references/reference/media.md +195 -0
- package/dist/{skills → public/skills}/douyin-to-doubao/SKILL.md +1 -1
- package/dist/{skills → public/skills}/h5-to-doubao/SKILL.md +2 -2
- package/dist/{skills → public/skills}/quality-gate/scripts/collect-doubao-page-data.js +3 -3
- package/dist/{skills → public/skills}/uniapp-to-doubao/SKILL.md +1 -1
- package/dist/{skills → public/skills}/weixin-to-doubao/SKILL.md +1 -1
- package/package.json +5 -5
- package/dist/733.js +0 -33
- package/dist/skills/doubao-apps-dev/references/reference/components-quick-ref.md +0 -114
- package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +0 -136
- package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +0 -257
- package/dist/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +0 -124
- package/dist/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +0 -87
- package/dist/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +0 -86
- package/dist/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +0 -87
- package/dist/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +0 -102
- package/dist/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +0 -63
- package/dist/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +0 -73
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/examples/open-api-recipes.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/best-practices.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/expired-widget.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/mcp-ui.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/performance-optimization.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/troubleshooting.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/framework-api-quick-ref.md +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/12-/346/224/257/344/273/230.md" +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/13-/346/225/260/346/215/256/345/210/206/346/236/220.md" +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/22-/347/237/255/344/277/241.md" +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/30-/347/224/265/350/257/235.md" +0 -0
- /package/dist/{skills → public/skills}/doubao-apps-dev/references/rules/dos-and-donts.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/assets/migration-checklist-template.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/component-mapping.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/core-api-mapping.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/event-mapping.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/style-mapping.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/source-framework/api-reference.md +0 -0
- /package/dist/{skills → public/skills}/douyin-to-doubao/references/source-framework/components.md +0 -0
- /package/dist/{skills → public/skills}/h5-to-doubao/references/common/troubleshooting.md +0 -0
- /package/dist/{skills → public/skills}/h5-to-doubao/references/source-framework/react-to-doubao.md +0 -0
- /package/dist/{skills → public/skills}/h5-to-doubao/references/source-framework/vue-to-doubao.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/SKILL.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/gates/bronze.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase1.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase2.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase3.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/gates/silver.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/runtime-fix.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/screenshots/doubao-faq.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/screenshots/doubao.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/screenshots/h5-react.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/screenshots/weixin.md +0 -0
- /package/dist/{skills → public/skills}/quality-gate/scripts/phase2-normalized-compare.py +0 -0
- /package/dist/{skills → public/skills}/quality-gate/scripts/run-doubao-screenshots.sh +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/assets/migration-checklist-template.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/component-mapping.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/core-api-mapping.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/event-mapping.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/style-mapping.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/source-framework/api-reference.md +0 -0
- /package/dist/{skills → public/skills}/uniapp-to-doubao/references/source-framework/components.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/assets/migration-checklist-template.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/component-mapping.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/core-api-mapping.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/event-mapping.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/style-mapping.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/source-framework/api-reference.md +0 -0
- /package/dist/{skills → public/skills}/weixin-to-doubao/references/source-framework/components.md +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# 文本与媒体组件
|
|
2
|
+
|
|
3
|
+
## `<text>`
|
|
4
|
+
|
|
5
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
6
|
+
|------|------|--------|------|
|
|
7
|
+
| className | string | - | 样式类名 |
|
|
8
|
+
| style | CSSProperties | - | 内联样式 |
|
|
9
|
+
| textMaxline | string | - | 最大行数,超出省略号 |
|
|
10
|
+
| tailColorConvert | boolean | false | 省略号颜色跟随外层 text 样式 |
|
|
11
|
+
| textSingleLineVerticalAlign | `'normal' \| 'bottom' \| 'center' \| 'top'` | `'normal'` | 单行垂直对齐,inline 文本不支持 |
|
|
12
|
+
| textSelection | boolean | false | 是否可选择文本 |
|
|
13
|
+
| customContextMenu | boolean | false | 开启文本选择后使用自定义菜单 |
|
|
14
|
+
| onClick | (e: TouchEvent) => void | - | 点击 |
|
|
15
|
+
| onLayout | (e: LayoutEvent) => void | - | 布局完成 |
|
|
16
|
+
| onSelectionChange | (e: SelectionChangeEvent) => void | - | 文本选区变化(需开启 textSelection) |
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<text textMaxline="2">超出两行显示省略号的长文本...</text>
|
|
20
|
+
<text textSelection>可以被用户选择复制的文本</text>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## `<image>`
|
|
26
|
+
|
|
27
|
+
**必须设置非空 src,且满足以下任意一条,否则图片不显示:**
|
|
28
|
+
- 设置 width + height > 0
|
|
29
|
+
- 设置 `autoSize`
|
|
30
|
+
|
|
31
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
32
|
+
|------|------|--------|------|
|
|
33
|
+
| src | string | - | **必填**,图片地址(http/https/base64) |
|
|
34
|
+
| mode | `'scaleToFill' \| 'aspectFit' \| 'aspectFill' \| 'center'` | `'scaleToFill'` | 缩放模式 |
|
|
35
|
+
| placeholder | string | - | 占位图,用法同 src |
|
|
36
|
+
| autoSize | boolean | false | 加载成功后自动调整为原图尺寸 |
|
|
37
|
+
| flatten | boolean | true | false 时走 Lynx 自定义解码链路,可缓解 Android 大图降采样 |
|
|
38
|
+
| subsample | boolean | true | 是否启用降采样,仅在 `flatten=false` 时可设为 false |
|
|
39
|
+
| onLoad | (e: LoadEvent) => void | - | 加载成功,事件包含宽高 |
|
|
40
|
+
| onError | (e: ErrorEvent) => void | - | 加载失败 |
|
|
41
|
+
| onClick | (e: TouchEvent) => void | - | 点击 |
|
|
42
|
+
|
|
43
|
+
**mode 说明:**
|
|
44
|
+
|
|
45
|
+
| 值 | 说明 |
|
|
46
|
+
|----|------|
|
|
47
|
+
| scaleToFill | 拉伸填满,不保持比例 |
|
|
48
|
+
| aspectFit | 保持比例,长边完全显示 |
|
|
49
|
+
| aspectFill | 保持比例,短边完全显示(常用于头像/封面) |
|
|
50
|
+
| center | 不缩放,只显示中间区域 |
|
|
51
|
+
|
|
52
|
+
**Android 大图说明:** `flatten={false}` 走 Lynx 解码链路,可缓解 Fresco 默认纹理限制导致的超大图片降采样。`subsample={false}` 关闭降采样,超大图存在 OOM 风险,谨慎使用。
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<image
|
|
56
|
+
src="https://example.com/photo.jpg"
|
|
57
|
+
mode="aspectFill"
|
|
58
|
+
style={{ width: '200px', height: '200px', borderRadius: '50%' }}
|
|
59
|
+
onLoad={(e) => console.log('尺寸:', e.detail.width, e.detail.height)}
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## `<svg>`
|
|
66
|
+
|
|
67
|
+
| 属性 | 类型 | 说明 |
|
|
68
|
+
|------|------|------|
|
|
69
|
+
| className | string | 样式类名 |
|
|
70
|
+
| style | CSSProperties | 内联样式 |
|
|
71
|
+
|
|
72
|
+
SVG 内容作为子节点传入,使用标准 SVG 元素。
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## `<video>`
|
|
77
|
+
|
|
78
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
79
|
+
|------|------|--------|------|
|
|
80
|
+
| ref | ForwardedRef\<VideoRef\> | - | 实例 ref,可调用播放控制方法 |
|
|
81
|
+
| playUrl | string | - | 播放地址 |
|
|
82
|
+
| poster | string | - | 海报图 |
|
|
83
|
+
| autoPlay | boolean | false | 资源就绪后自动播放 |
|
|
84
|
+
| mute | boolean | true | 静音 |
|
|
85
|
+
| loop | boolean | false | 循环 |
|
|
86
|
+
| objectfit | `'aspectFit' \| 'aspectFill' \| 'scaleToFill'` | `'aspectFit'` | 缩放模式 |
|
|
87
|
+
| style | CSSProperties | - | 设置宽高和圆角 |
|
|
88
|
+
|
|
89
|
+
### VideoRef 方法
|
|
90
|
+
|
|
91
|
+
| 方法 | 说明 |
|
|
92
|
+
|------|------|
|
|
93
|
+
| play(callback?) | 播放 |
|
|
94
|
+
| pause(callback?) | 暂停 |
|
|
95
|
+
| stop(callback?) | 停止 |
|
|
96
|
+
| seek(position, play, callback?) | 跳转到指定时间 |
|
|
97
|
+
| replay(play, callback?) | 重新播放 |
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import type { VideoRef } from '@doubao-apps/framework/components';
|
|
101
|
+
import { useRef } from '@doubao-apps/framework';
|
|
102
|
+
|
|
103
|
+
const videoRef = useRef<VideoRef>(null);
|
|
104
|
+
|
|
105
|
+
<video
|
|
106
|
+
ref={videoRef}
|
|
107
|
+
playUrl="https://example.com/video.mp4"
|
|
108
|
+
poster="https://example.com/poster.jpg"
|
|
109
|
+
objectfit="aspectFill"
|
|
110
|
+
style={{ width: '100%', height: '220px', borderRadius: '12px' }}
|
|
111
|
+
/>
|
|
112
|
+
<button onClick={() => videoRef.current?.play()}>播放</button>
|
|
113
|
+
<button onClick={() => videoRef.current?.pause()}>暂停</button>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## `<long-image>`
|
|
119
|
+
|
|
120
|
+
长图分段解码,提供两种用法。
|
|
121
|
+
|
|
122
|
+
### 简单用法(内置滚动容器)
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<long-image
|
|
126
|
+
src="https://example.com/long.jpg"
|
|
127
|
+
style={{ height: '70vh' }}
|
|
128
|
+
onStateChange={(state) => {
|
|
129
|
+
// state: 'measuring' | 'loading-meta' | 'ready' | 'error'
|
|
130
|
+
console.log(state);
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
136
|
+
|------|------|--------|------|
|
|
137
|
+
| src | string | - | **必填** |
|
|
138
|
+
| id | string | 自动生成 | 根节点 id |
|
|
139
|
+
| reloadToken | number | 0 | 变化时重新初始化 |
|
|
140
|
+
| segmentDisplayHeight | number | 600 | 单段目标高度 (px) |
|
|
141
|
+
| decodeOverscanScreens | number | 1 | 预加载屏数 |
|
|
142
|
+
| maxActiveSegments | number | 8 | 同时激活解码上限 |
|
|
143
|
+
| placeholderColor | string | 'transparent' | 非激活段占位背景色 |
|
|
144
|
+
| style | CSSProperties | - | 未设 height 时默认 100vh |
|
|
145
|
+
| onStateChange | (state: LongImageState) => void | - | 状态回调 |
|
|
146
|
+
| onMetricsChange | (metrics: LongImageMetrics) => void | - | 指标回调 |
|
|
147
|
+
|
|
148
|
+
### Hook 用法(接入外部滚动容器)
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useLongImage, renderLongImageSegments } from '@doubao-apps/framework/components';
|
|
152
|
+
|
|
153
|
+
const longImageResult = useLongImage({ src });
|
|
154
|
+
|
|
155
|
+
<view id={longImageResult.containerId} style={{ height: '70vh' }} onLayoutChange={longImageResult.handleContainerLayoutChange}>
|
|
156
|
+
<list style={{ width: '100%', height: '100%' }} onScroll={longImageResult.handleScroll}>
|
|
157
|
+
{renderLongImageSegments(longImageResult, { mode: 'list' })}
|
|
158
|
+
</list>
|
|
159
|
+
</view>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**⚠️ 长图前有 header 时必须修正 scrollTop:**
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
const HEADER_HEIGHT = 120;
|
|
166
|
+
const handlePageScroll = (event) => {
|
|
167
|
+
longImageResult.handleScroll({
|
|
168
|
+
...event,
|
|
169
|
+
detail: { ...event.detail, scrollTop: Math.max(0, event.detail.scrollTop - HEADER_HEIGHT) }
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`handleScroll` 期望接收的 scrollTop 语义是"可视区域顶部相对于长图内容顶部的偏移",如果长图前有其他内容,外层 scrollTop 需减去该内容高度。
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## `<web-view>`
|
|
179
|
+
|
|
180
|
+
| 属性 | 类型 | 说明 |
|
|
181
|
+
|------|------|------|
|
|
182
|
+
| src | string | 网页地址 |
|
|
183
|
+
| onLoad | () => void | 加载成功 |
|
|
184
|
+
| onError | (e: { errorMsg: string; errorCode: number }) => void | 加载失败 |
|
|
185
|
+
| onMessage | (e: { msg: string }) => void | 网页 postMessage |
|
|
186
|
+
| className | string | 样式类名 |
|
|
187
|
+
| style | CSSProperties | 内联样式 |
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<web-view
|
|
191
|
+
src="https://example.com"
|
|
192
|
+
style={{ width: '100%', height: '100vh' }}
|
|
193
|
+
onMessage={(e) => console.log('收到消息:', e.msg)}
|
|
194
|
+
/>
|
|
195
|
+
```
|
|
@@ -68,7 +68,7 @@ npx @doubao-apps/ai skills add doubao-apps-dev --agent codex
|
|
|
68
68
|
| 框架 API 速查 | `$SKILLS_BASE/references/reference/framework-api-quick-ref.md` | definePage/defineWidget 等核心 API |
|
|
69
69
|
| 开发规则 | `$SKILLS_BASE/references/rules/dos-and-donts.md` | 必须遵守的开发规范 |
|
|
70
70
|
| 组件开发指南 | `$SKILLS_BASE/references/guides/component-development.md` | 页面/组件组织方式 |
|
|
71
|
-
| 组件库参考 |
|
|
71
|
+
| 组件库参考 | `doubao-components-api` skill | UI 组件完整 props 和事件 API |
|
|
72
72
|
|
|
73
73
|
### 映射文档(迁移核心依据)
|
|
74
74
|
|
|
@@ -47,7 +47,7 @@ description: Migrate H5 projects to Doubao Apps SDK (React Lynx). Supports stand
|
|
|
47
47
|
| 框架 API 速查 | `$SKILLS_BASE/references/reference/framework-api-quick-ref.md` | definePage/defineWidget 等核心 API |
|
|
48
48
|
| 开发规则 | `$SKILLS_BASE/references/rules/dos-and-donts.md` | 必须遵守的开发规范 |
|
|
49
49
|
| 组件开发指南 | `$SKILLS_BASE/references/guides/component-development.md` | 完整的组件开发模式 |
|
|
50
|
-
| 组件库参考 |
|
|
50
|
+
| 组件库参考 | `doubao-components-api` skill | UI 组件完整 props 和事件 API |
|
|
51
51
|
|
|
52
52
|
### 源框架子文档(按源框架读取)
|
|
53
53
|
|
|
@@ -246,7 +246,7 @@ HTML 元素:
|
|
|
246
246
|
**按需读取**:
|
|
247
247
|
|
|
248
248
|
- `$SKILLS_BASE/references/guides/component-development.md` - 遇到复杂组件时
|
|
249
|
-
-
|
|
249
|
+
- `doubao-components-api` skill - 需要使用 UI 组件时
|
|
250
250
|
- `./references/source-framework/react-to-doubao.md` - 当 `source_framework=react`
|
|
251
251
|
- `./references/source-framework/vue-to-doubao.md` - 当 `source_framework=vue`
|
|
252
252
|
- `./references/common/troubleshooting.md` - 当迁移或验证阶段出现公共问题
|
|
@@ -180,10 +180,10 @@ function sampleFromType(ts, checker, type, fieldPath, state, depth = 0) {
|
|
|
180
180
|
return chooseStringSample(fieldName);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
if (normalized.isStringLiteral
|
|
183
|
+
if (normalized.isStringLiteral?.()) {
|
|
184
184
|
return normalized.value;
|
|
185
185
|
}
|
|
186
|
-
if (normalized.isNumberLiteral
|
|
186
|
+
if (normalized.isNumberLiteral?.()) {
|
|
187
187
|
return normalized.value;
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -197,7 +197,7 @@ function sampleFromType(ts, checker, type, fieldPath, state, depth = 0) {
|
|
|
197
197
|
return false;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
if (normalized.isUnion
|
|
200
|
+
if (normalized.isUnion?.()) {
|
|
201
201
|
const literal = normalized.types.find(
|
|
202
202
|
(item) =>
|
|
203
203
|
(item.flags & ts.TypeFlags.StringLiteral) ||
|
|
@@ -69,7 +69,7 @@ npx @doubao-apps/ai skills add doubao-apps-dev --agent codex
|
|
|
69
69
|
| 框架 API 速查 | `$SKILLS_BASE/references/reference/framework-api-quick-ref.md` | `definePage` / `defineApp` / `getViewData` 等 |
|
|
70
70
|
| 开发规则 | `$SKILLS_BASE/references/rules/dos-and-donts.md` | 必须遵守的目标框架规范 |
|
|
71
71
|
| 组件开发指南 | `$SKILLS_BASE/references/guides/component-development.md` | 页面/组件组织方式 |
|
|
72
|
-
| 组件库参考 |
|
|
72
|
+
| 组件库参考 | `doubao-components-api` skill | UI 组件完整 props 和事件 API |
|
|
73
73
|
|
|
74
74
|
### 映射文档(迁移核心依据)
|
|
75
75
|
|
|
@@ -45,7 +45,7 @@ description: Migrate WeChat Mini Program (微信小程序) projects to Doubao Ap
|
|
|
45
45
|
| 框架 API 速查 | `$SKILLS_BASE/references/reference/framework-api-quick-ref.md` | definePage/defineWidget 等核心 API |
|
|
46
46
|
| 开发规则 | `$SKILLS_BASE/references/rules/dos-and-donts.md` | 必须遵守的开发规范 |
|
|
47
47
|
| 组件开发指南 | `$SKILLS_BASE/references/guides/component-development.md` | 完整的组件开发模式 |
|
|
48
|
-
| 组件库参考 |
|
|
48
|
+
| 组件库参考 | `doubao-components-api` skill | UI 组件完整 props 和事件 API |
|
|
49
49
|
|
|
50
50
|
### 映射文档(迁移核心依据)
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doubao-apps/ai",
|
|
3
|
-
"version": "0.0.35
|
|
4
|
-
"description": "Doubao Apps SDK AI tools
|
|
3
|
+
"version": "0.0.35",
|
|
4
|
+
"description": "Doubao Apps SDK AI tools for skills management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"doubao-cli": "./bin.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"import": "./dist/cli.js",
|
|
17
17
|
"types": "./dist/cli.d.ts"
|
|
18
18
|
},
|
|
19
|
-
"./manifest": "./dist/manifest.json",
|
|
20
|
-
"./skills/*": "./dist/skills/*"
|
|
19
|
+
"./manifest/public": "./dist/public/manifest.json",
|
|
20
|
+
"./skills/public/*": "./dist/public/skills/*"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"bin.js",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"registry": "https://registry.npmjs.org/"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "rslib build && node scripts/copy-assets.cjs"
|
|
36
|
+
"build": "rimraf dist && rslib build && node scripts/copy-assets.cjs"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/dist/733.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import l,{createRequire as e}from"node:module";let o=l.createRequire(import.meta.url);import{__webpack_require__ as s}from"./rslib-runtime.js";import{fileURLToPath as t}from"node:url";import{dirname as a}from"node:path";let i=e(import.meta.url);s.add({"node:fs"(l){l.exports=i("node:fs")},"node:path"(l){l.exports=i("node:path")},"../../ai/dist/cli.js"(l,e,s){var i=a(t(import.meta.url));let n=s("node:fs"),r=s("node:path"),c={amp:{projectPath:".agents/skills/",globalPath:"~/.config/agents/skills/"},"kimi-cli":{projectPath:".agents/skills/",globalPath:"~/.config/agents/skills/"},replit:{projectPath:".agents/skills/",globalPath:"~/.config/agents/skills/"},universal:{projectPath:".agents/skills/",globalPath:"~/.config/agents/skills/"},antigravity:{projectPath:".agent/skills/",globalPath:"~/.gemini/antigravity/skills/"},augment:{projectPath:".augment/skills/",globalPath:"~/.augment/skills/"},claude:{projectPath:".claude/skills/",globalPath:"~/.claude/skills/"},"claude-code":{projectPath:".claude/skills/",globalPath:"~/.claude/skills/"},openclaw:{projectPath:"skills/",globalPath:"~/.openclaw/skills/"},cline:{projectPath:".agents/skills/",globalPath:"~/.agents/skills/"},codebuddy:{projectPath:".codebuddy/skills/",globalPath:"~/.codebuddy/skills/"},codex:{projectPath:".agents/skills/",globalPath:"~/.codex/skills/"},"command-code":{projectPath:".commandcode/skills/",globalPath:"~/.commandcode/skills/"},continue:{projectPath:".continue/skills/",globalPath:"~/.continue/skills/"},cortex:{projectPath:".cortex/skills/",globalPath:"~/.snowflake/cortex/skills/"},crush:{projectPath:".crush/skills/",globalPath:"~/.config/crush/skills/"},cursor:{projectPath:".agents/skills/",globalPath:"~/.cursor/skills/"},droid:{projectPath:".factory/skills/",globalPath:"~/.factory/skills/"},"gemini-cli":{projectPath:".agents/skills/",globalPath:"~/.gemini/skills/"},"github-copilot":{projectPath:".agents/skills/",globalPath:"~/.copilot/skills/"},goose:{projectPath:".goose/skills/",globalPath:"~/.config/goose/skills/"},junie:{projectPath:".junie/skills/",globalPath:"~/.junie/skills/"},"iflow-cli":{projectPath:".iflow/skills/",globalPath:"~/.iflow/skills/"},kilo:{projectPath:".kilocode/skills/",globalPath:"~/.kilocode/skills/"},"kiro-cli":{projectPath:".kiro/skills/",globalPath:"~/.kiro/skills/"},kode:{projectPath:".kode/skills/",globalPath:"~/.kode/skills/"},mcpjam:{projectPath:".mcpjam/skills/",globalPath:"~/.mcpjam/skills/"},"mistral-vibe":{projectPath:".vibe/skills/",globalPath:"~/.vibe/skills/"},mux:{projectPath:".mux/skills/",globalPath:"~/.mux/skills/"},opencode:{projectPath:".agents/skills/",globalPath:"~/.config/opencode/skills/"},openhands:{projectPath:".openhands/skills/",globalPath:"~/.openhands/skills/"},pi:{projectPath:".pi/skills/",globalPath:"~/.pi/agent/skills/"},qoder:{projectPath:".qoder/skills/",globalPath:"~/.qoder/skills/"},"qwen-code":{projectPath:".qwen/skills/",globalPath:"~/.qwen/skills/"},roo:{projectPath:".roo/skills/",globalPath:"~/.roo/skills/"},trae:{projectPath:".trae/skills/",globalPath:"~/.trae/skills/"},"trae-cn":{projectPath:".trae/skills/",globalPath:"~/.trae-cn/skills/"},windsurf:{projectPath:".windsurf/skills/",globalPath:"~/.codeium/windsurf/skills/"},zencoder:{projectPath:".zencoder/skills/",globalPath:"~/.zencoder/skills/"},neovate:{projectPath:".neovate/skills/",globalPath:"~/.neovate/skills/"},pochi:{projectPath:".pochi/skills/",globalPath:"~/.pochi/skills/"},adal:{projectPath:".adal/skills/",globalPath:"~/.adal/skills/"}};function d(){return r.join(i,"..","dist")}function g(l={}){return r.join(function(l={}){if(l.preferBundledAssets)return d();try{let l=o.resolve("@byted-doubao-apps/ai-assets/manifest");return r.dirname(l)}catch{return d()}}(l),"skills")}function k(l){return l.startsWith("~/")?r.join(process.env.HOME||process.env.USERPROFILE||"",l.slice(2)):l}function p(l){let e={agent:null,global:!1};for(let o=0;o<l.length;o++)("--agent"===l[o]||"-a"===l[o])&&l[o+1]?e.agent=l[++o]:("--global"===l[o]||"-g"===l[o])&&(e.global=!0);return e}function h(l,e,o,s={}){if(!c[e])throw Error(`Unknown agent: "${e}". Supported agents: ${Object.keys(c).join(", ")}`);let t=function(l,e={}){return r.join(g(e),l)}(l,s);if(!n.existsSync(t)){let e=g(s),o=n.existsSync(e)?n.readdirSync(e).join(", "):"(none)";throw Error(`Skill "${l}" not found. Available skills: ${o}`)}let a=c[e],i=o?a.globalPath:a.projectPath,d=o?r.join(k(i),l):r.join(process.cwd(),i,l);for(let o of(console.log(`Installing skill "${l}" for ${e}...`),console.log(` Target: ${d}`),n.existsSync(d)&&n.rmSync(d,{recursive:!0,force:!0}),n.mkdirSync(d,{recursive:!0}),n.readdirSync(t,{withFileTypes:!0}))){let l=r.join(t,o.name),e=r.join(d,o.name);o.isDirectory()?(!function l(e,o){if(!n.existsSync(e))throw Error(`Source directory not found: ${e}`);for(let s of(n.mkdirSync(o,{recursive:!0}),n.readdirSync(e,{withFileTypes:!0}))){let t=r.join(e,s.name),a=r.join(o,s.name);s.isDirectory()?l(t,a):n.copyFileSync(t,a)}}(l,e),console.log(` ✓ ${o.name}/`)):(n.copyFileSync(l,e),console.log(` ✓ ${o.name}`))}console.log(" ✓ Done")}l.exports={runCli:function(l={}){let e=l.commandName||"doubao-ai",o={preferBundledAssets:!0===l.preferBundledAssets},[s,...t]=process.argv.slice(2);if(!s||"--help"===s||"-h"===s)return void console.log(`
|
|
2
|
-
${e} - Doubao Apps SDK AI 工具
|
|
3
|
-
|
|
4
|
-
用法:
|
|
5
|
-
${e} skills add <skill1> [skill2...] --agent <agent> 安装一个或多个 skill 到指定 Agent
|
|
6
|
-
${e} skills list 查看可用 skills
|
|
7
|
-
${e} skills update [--global] 更新所有已安装的 skills
|
|
8
|
-
|
|
9
|
-
选项:
|
|
10
|
-
--agent <agent> 指定 AI Agent(如 claude-code、opencode、cursor)
|
|
11
|
-
--global, -g 全局安装(用户目录而非项目目录)
|
|
12
|
-
|
|
13
|
-
示例:
|
|
14
|
-
# 安装一个或多个 skill 到 Claude Code
|
|
15
|
-
${e} skills add doubao-apps-dev quality-gate --agent claude-code
|
|
16
|
-
|
|
17
|
-
# 安装 skill 到 opencode
|
|
18
|
-
${e} skills add doubao-apps-dev --agent opencode
|
|
19
|
-
|
|
20
|
-
# 全局安装 skill
|
|
21
|
-
${e} skills add doubao-apps-dev --agent claude-code --global
|
|
22
|
-
|
|
23
|
-
# 查看可用 skills
|
|
24
|
-
${e} skills list
|
|
25
|
-
|
|
26
|
-
# 更新所有已安装的 skills
|
|
27
|
-
${e} skills update
|
|
28
|
-
|
|
29
|
-
支持的 Agents:
|
|
30
|
-
${Object.keys(c).join(", ")}
|
|
31
|
-
`);if("skills"===s){let[l,...s]=t;if("list"===l)return void function(l={}){let e=g(l);if(!n.existsSync(e))return console.log("No skills available. Run build first.");let o=n.readdirSync(e,{withFileTypes:!0}).filter(l=>l.isDirectory()).map(l=>l.name);if(0===o.length)return console.log("No skills available.");for(let l of(console.log("Available skills:"),o)){let o=r.join(e,l,"SKILL.md");console.log(` - ${l}${n.existsSync(o)?"":" (not built)"}`)}}(o);if("add"===l){let{agent:l,global:t}=p(s),a=[];for(let l=0;l<s.length;l++){let e=s[l];"--agent"===e||"-a"===e?l++:"--global"!==e&&"-g"!==e&&a.push(e)}for(let s of(0===a.length&&(console.error(`Usage: ${e} skills add <skill-name>... --agent <agent>`),process.exit(1)),l||(console.error(`--agent is required. Example: ${e} skills add doubao-apps-dev --agent claude-code`),process.exit(1)),a))h(s,l,t,o);return}if("update"===l){let{global:l}=p(s);!function(l,e={}){let o=g(e);if(!n.existsSync(o))return console.log("No skills to update. Run build first.");let s=n.readdirSync(o,{withFileTypes:!0}).filter(l=>l.isDirectory()).map(l=>l.name),t=0;for(let[o,a]of Object.entries(c)){let i=l?a.globalPath:a.projectPath,c=l?k(i):r.join(process.cwd(),i);for(let a of s)n.existsSync(r.join(c,a))&&(h(a,o,l,e),t++)}0===t?console.log("No installed skills found to update."):console.log(`
|
|
32
|
-
Updated ${t} skill installation(s).`)}(l,o);return}console.error(`Unknown skills subcommand: "${l}". Use: add, list, update`),process.exit(1)}console.error(`Unknown command: "${s}". Run \`${e} --help\` for usage.`),process.exit(1)}}}});
|
|
33
|
-
//# sourceMappingURL=733.js.map
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# 组件库快速参考
|
|
2
|
-
|
|
3
|
-
所有组件均已编译为全局变量,**无需任何 import**,直接像 `<view>`、`<text>` 一样使用小写标签即可。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 组件列表
|
|
8
|
-
|
|
9
|
-
| 组件标签 | 用途 | 关键属性 |
|
|
10
|
-
|---------|------|----------|
|
|
11
|
-
| `<button>` | 按钮交互 | `text`, `type`, `size`, `loading`, `disabled`, `openType`, `onClick` |
|
|
12
|
-
| `<switch>` | 开关切换 | `checked`, `defaultChecked`, `disabled`, `onChange` |
|
|
13
|
-
| `<slider>` | 滑块选择 | `value`(必填), `min`, `max`, `showValue`, `disabled`, `onChange` |
|
|
14
|
-
| `<swiper>` | 轮播容器 | `data`, `itemWidth`, `itemHeight`, `loop`, `duration`, `onChange` |
|
|
15
|
-
| `<swiper-item>` | 轮播项 | `index`, `realIndex` |
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 事件命名
|
|
20
|
-
|
|
21
|
-
应用 TSX 中使用 React 风格事件名。`button` 点击使用 `onClick`;不要在业务代码里写 `onTap`、`bindtap` 或 `catchtap`。
|
|
22
|
-
`switch` / `slider` / `swiper` 使用 `onChange`,回调直接接收当前值。
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## button 按钮
|
|
27
|
-
|
|
28
|
-
```tsx
|
|
29
|
-
<button
|
|
30
|
-
text="提交"
|
|
31
|
-
type="primary" // primary | default | plain
|
|
32
|
-
size="default" // default | mini | large
|
|
33
|
-
loading={false}
|
|
34
|
-
disabled={false}
|
|
35
|
-
throttle={500} // 节流时间(ms)
|
|
36
|
-
onClick={() => {}}
|
|
37
|
-
/>
|
|
38
|
-
|
|
39
|
-
{/* 开放能力 */}
|
|
40
|
-
<button
|
|
41
|
-
openType="getPhoneNumber"
|
|
42
|
-
onGetPhoneNumber={(e) => console.log(e)}
|
|
43
|
-
/>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## switch 开关
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
{/* 非受控 */}
|
|
52
|
-
<switch defaultChecked onChange={(checked) => {}} />
|
|
53
|
-
|
|
54
|
-
{/* 受控 */}
|
|
55
|
-
<switch checked={value} onChange={(checked) => setChecked(checked)} />
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
> `onChange` 回调直接接收 `boolean` 值,而非事件对象。
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## slider 滑块
|
|
63
|
-
|
|
64
|
-
```tsx
|
|
65
|
-
const [value, setValue] = useState(50);
|
|
66
|
-
|
|
67
|
-
<slider
|
|
68
|
-
value={value} // 必填,只支持受控
|
|
69
|
-
min={0}
|
|
70
|
-
max={100}
|
|
71
|
-
showValue={true}
|
|
72
|
-
onChange={(value) => setValue(value)}
|
|
73
|
-
/>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
> `onChange` 回调直接接收 `number` 值,而非事件对象。
|
|
77
|
-
> `slider` 不支持 `step`、`defaultValue` 或事件对象参数;不要传这些 props。
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## swiper 轮播
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
<swiper
|
|
85
|
-
data={[{ img: 'url1' }, { img: 'url2' }]}
|
|
86
|
-
itemWidth={300}
|
|
87
|
-
itemHeight={200}
|
|
88
|
-
loop={true}
|
|
89
|
-
duration={500}
|
|
90
|
-
onChange={(index) => console.log(index)}
|
|
91
|
-
>
|
|
92
|
-
{({ item, index }) => (
|
|
93
|
-
<swiper-item index={index} key={index}>
|
|
94
|
-
<image src={item.img} />
|
|
95
|
-
</swiper-item>
|
|
96
|
-
)}
|
|
97
|
-
</swiper>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
> `onChange` 回调直接接收当前 `index: number`,而非事件对象。
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## 注意事项
|
|
105
|
-
|
|
106
|
-
1. **无需 import**:所有组件直接使用小写标签,不需要从任何包导入
|
|
107
|
-
2. **事件命名**:button 使用 `onClick`,不要写 `onTap`、`bindtap` 或 `catchtap`
|
|
108
|
-
3. **onChange 回调签名**:switch/slider/swiper 的 `onChange` 直接接收值(boolean/number/number),不是事件对象
|
|
109
|
-
4. **Lynx 不支持 CSS 继承**:组件样式自包含,不依赖父元素样式
|
|
110
|
-
5. **受控/非受控**:switch 支持两种模式,slider 只支持受控模式
|
|
111
|
-
6. **节流处理**:button 内置 500ms 节流,可通过 `throttle` 自定义
|
|
112
|
-
7. **Slider props**:slider 只使用 `value`、`min`、`max`、`showValue`、`disabled`、`onChange`,不要写 `step`
|
|
113
|
-
|
|
114
|
-
完整 Page 组合示例见 [内置组件使用配方](../examples/component-recipes.md)。
|
package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# Open API: 基础
|
|
2
|
-
|
|
3
|
-
账号、授权、宿主基础信息、窗口信息和能力可用性。
|
|
4
|
-
|
|
5
|
-
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
-
|
|
7
|
-
## 速查
|
|
8
|
-
|
|
9
|
-
| API | 说明 |
|
|
10
|
-
| --- | --- |
|
|
11
|
-
| [getAccountInfo](#getaccountinfo) | 异步获取账号信息。 |
|
|
12
|
-
| [getAccountInfoSync](#getaccountinfosync) | 同步获取账号信息。<br><br>同步 API。 |
|
|
13
|
-
| [authorize](#authorize) | 初始化授权。 |
|
|
14
|
-
| [canIUse](#caniuse) | 检测当前宿主是否支持指定 API 或能力。 |
|
|
15
|
-
|
|
16
|
-
## API 详情
|
|
17
|
-
|
|
18
|
-
<a id="getaccountinfo"></a>
|
|
19
|
-
### getAccountInfo()
|
|
20
|
-
|
|
21
|
-
异步获取账号信息。
|
|
22
|
-
|
|
23
|
-
## 代码示例
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { getAccountInfo } from '@doubao-apps/framework/api';
|
|
27
|
-
|
|
28
|
-
const result = await getAccountInfo();
|
|
29
|
-
console.log(result.miniProgram.appId);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 入参
|
|
33
|
-
|
|
34
|
-
无入参。
|
|
35
|
-
|
|
36
|
-
## 返回值
|
|
37
|
-
|
|
38
|
-
返回 `Promise<GetAccountInfoResult>`。
|
|
39
|
-
|
|
40
|
-
|字段名|类型|说明|
|
|
41
|
-
|---|---|---|
|
|
42
|
-
|miniProgram|`DoubaoAppAccountInfo`|豆包 App账号信息|
|
|
43
|
-
|miniProgram.appId|`string`|豆包 App appId|
|
|
44
|
-
|miniProgram.envVersion|`"develop" \| "trial" \| "release"`|豆包 App 运行环境。<br><br>- develop: 开发版<br>- trial: 体验版<br>- release: 正式版|
|
|
45
|
-
|miniProgram.version|`string`|线上豆包 App 版本号。|
|
|
46
|
-
|plugin|`PluginAccountInfo`|插件账号信息(仅在插件中调用时包含)|
|
|
47
|
-
|plugin.appId|`string`|插件 appId|
|
|
48
|
-
|plugin.version|`string`|插件版本号,'a.b.c' 形式|
|
|
49
|
-
|
|
50
|
-
<a id="getaccountinfosync"></a>
|
|
51
|
-
### getAccountInfoSync()
|
|
52
|
-
|
|
53
|
-
同步获取账号信息。
|
|
54
|
-
|
|
55
|
-
## 代码示例
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { getAccountInfoSync } from '@doubao-apps/framework/api';
|
|
59
|
-
|
|
60
|
-
const result = getAccountInfoSync();
|
|
61
|
-
console.log(result.miniProgram.appId, result.miniProgram.envVersion, result.miniProgram.version);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## 入参
|
|
65
|
-
|
|
66
|
-
无入参。
|
|
67
|
-
|
|
68
|
-
## 返回值
|
|
69
|
-
|
|
70
|
-
返回 `GetAccountInfoResult`。
|
|
71
|
-
|
|
72
|
-
|字段名|类型|说明|
|
|
73
|
-
|---|---|---|
|
|
74
|
-
|miniProgram|`DoubaoAppAccountInfo`|豆包 App账号信息|
|
|
75
|
-
|miniProgram.appId|`string`|豆包 App appId|
|
|
76
|
-
|miniProgram.envVersion|`"develop" \| "trial" \| "release"`|豆包 App 运行环境。<br><br>- develop: 开发版<br>- trial: 体验版<br>- release: 正式版|
|
|
77
|
-
|miniProgram.version|`string`|线上豆包 App 版本号。|
|
|
78
|
-
|plugin|`PluginAccountInfo`|插件账号信息(仅在插件中调用时包含)|
|
|
79
|
-
|plugin.appId|`string`|插件 appId|
|
|
80
|
-
|plugin.version|`string`|插件版本号,'a.b.c' 形式|
|
|
81
|
-
|
|
82
|
-
<a id="authorize"></a>
|
|
83
|
-
### authorize()
|
|
84
|
-
|
|
85
|
-
初始化授权
|
|
86
|
-
|
|
87
|
-
## 代码示例
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import { authorize } from '@doubao-apps/framework/api';
|
|
91
|
-
|
|
92
|
-
await authorize({ scope: 'scope.userLocation' });
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 入参
|
|
96
|
-
|
|
97
|
-
|参数名|类型|必填|说明|
|
|
98
|
-
|---|---|---|---|
|
|
99
|
-
|scope|`Scope`|是|授权范围|
|
|
100
|
-
|
|
101
|
-
**类型说明**
|
|
102
|
-
|
|
103
|
-
- `Scope`: `"scope.userLocation" | "scope.userFuzzyLocation" | "scope.userLocationBackground" | "scope.payment" | "scope.record" | "scope.bluetooth" | "scope.camera" | "scope.addPhoneContact" | "scope.addPhoneCalendar"`
|
|
104
|
-
|
|
105
|
-
## 返回值
|
|
106
|
-
|
|
107
|
-
Promise 对象,授权成功时会返回授权结果
|
|
108
|
-
|
|
109
|
-
<a id="caniuse"></a>
|
|
110
|
-
### canIUse()
|
|
111
|
-
|
|
112
|
-
检测当前宿主是否支持指定 API 或能力。
|
|
113
|
-
|
|
114
|
-
## 代码示例
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { canIUse } from '@doubao-apps/framework/api';
|
|
118
|
-
|
|
119
|
-
const { result } = await canIUse({ schema: 'doubao.getLocation' });
|
|
120
|
-
|
|
121
|
-
console.log(result);
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## 入参
|
|
125
|
-
|
|
126
|
-
|参数名|类型|必填|说明|
|
|
127
|
-
|---|---|---|---|
|
|
128
|
-
|schema|`string`|是|-|
|
|
129
|
-
|
|
130
|
-
## 返回值
|
|
131
|
-
|
|
132
|
-
返回 `Promise<CanIUseResult>`。
|
|
133
|
-
|
|
134
|
-
|字段名|类型|说明|
|
|
135
|
-
|---|---|---|
|
|
136
|
-
|result|`boolean`|-|
|