@doubao-dev/plugin-app-dev 0.0.0-stage → 0.0.40-canary-dea0ddc73-20261026073950
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 +10 -2
- package/dist/147.js +9 -0
- package/dist/assets.d.ts +5 -0
- package/dist/assets.js +4 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +1378 -0
- package/dist/plugin.d.ts +102 -0
- package/dist/plugin.js +4995 -0
- package/dist/preview.js +16 -0
- package/dist/rslib-runtime.js +33 -0
- package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
- package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/03-/350/207/252/345/256/232/344/271/211/351/200/232/344/277/241.md +127 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/12-/344/270/232/345/212/241/350/203/275/345/212/233.md +1281 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/15-/346/225/260/346/215/256/345/210/206/346/236/220.md +124 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/18-/345/212/240/351/200/237/345/272/246/350/256/241.md +354 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/21-/350/256/276/345/244/207/346/226/271/345/220/221.md +351 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/22-/351/231/200/350/236/272/344/273/252.md +354 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/23-/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md +264 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/25-/346/227/240/351/232/234/347/242/215.md +144 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/26-/345/237/272/347/241/200/344/277/241/346/201/257.md +238 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/28-/345/211/252/350/264/264/346/235/277.md +303 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/35-/346/226/207/344/273/266/347/263/273/347/273/237.md +431 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
- package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
- package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
- package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
- package/dist/templates/README.md.template +11 -0
- package/dist/templates/com.doubao/app/manifest.yaml +41 -0
- package/dist/templates/com.doubao/app/package.json.template +13 -0
- package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
- package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
- package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
- package/dist/templates/com.doubao/app/tsconfig.json +19 -0
- package/dist/templates/mcp.json +9 -0
- package/dist/templates/plugin.json.template +29 -0
- package/dist/templates/skills/example/SKILL.md.template +14 -0
- package/dist/upload.d.ts +44 -0
- package/dist/upload.js +38 -0
- package/package.json +60 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 豆包应用插件组件 API
|
|
2
|
+
|
|
3
|
+
## 核心规则
|
|
4
|
+
|
|
5
|
+
所有组件使用**小写标签**,`components-loader` 在构建时自动注入 import,业务代码不需要手动 import 运行时组件:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// ✅ 直接使用小写标签
|
|
9
|
+
<view><text>你好</text><button text="提交" /></view>
|
|
10
|
+
|
|
11
|
+
// ❌ 不要手动 import 运行时组件
|
|
12
|
+
import { View, Button } from '@doubao-dev/framework/components';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
类型标注可以 import:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import type { ButtonProps, SwiperRef, VideoRef, PopupRef } from '@doubao-dev/framework/components';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 参考文档
|
|
22
|
+
|
|
23
|
+
| 类别 | 文件 | 涵盖标签 |
|
|
24
|
+
|------|------|---------|
|
|
25
|
+
| 滚动与列表 | [scroll-list.md](scroll-list.md) | `scroll-view` `list` `list-item` `swiper` `swiper-item` |
|
|
26
|
+
| 容器与覆层 | [container-overlay.md](container-overlay.md) | `view` `popup` `movable-area` `movable-view` `theme-provider` |
|
|
27
|
+
| 文本与媒体 | [text-media.md](text-media.md) | `text` `image` `svg` `video` `long-image` `web-view` |
|
|
28
|
+
| 交互控件 | [interactive-controls.md](interactive-controls.md) | `button` `switch` `slider` `radio` `radio-group` |
|
|
29
|
+
| 表单控件 | [form-controls.md](form-controls.md) | `input` `textarea` `picker-view` `picker-column` `picker-divider` |
|
|
30
|
+
| 地图与画布 | [map-canvas.md](map-canvas.md) | `map` `map-marker` `canvas` |
|
|
31
|
+
|
|
32
|
+
## 常见错误
|
|
33
|
+
|
|
34
|
+
| 错误 | 修正 |
|
|
35
|
+
|------|------|
|
|
36
|
+
| 手动 import 运行时组件 | 直接用小写标签,loader 自动注入 |
|
|
37
|
+
| `<list>` 没设置 height | 必须 `style={{ height: '...' }}`,list 不支持自适应高度 |
|
|
38
|
+
| `list-item` 没传 `item-key` | item-key 是必填项(原生 Lynx 元素,连字符属性名) |
|
|
39
|
+
| `picker-view` 高度只写在 CSS class | 必须同时写 `style={{ height: '...' }}` |
|
|
40
|
+
| `slider` 不传 value | slider 仅支持受控用法 |
|
|
41
|
+
| `image` 没设置 width/height 也没设 autoSize | 不满足条件图片不显示 |
|
|
42
|
+
| `popup` 没传 scrollContainerId | scrollContainerId 是必填项 |
|
|
43
|
+
| `long-image` 接外部滚动容器直接传外层 scrollTop | 有 header 时需减去 header 高度 |
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# 滚动与列表组件
|
|
2
|
+
|
|
3
|
+
## `<scroll-view>`
|
|
4
|
+
|
|
5
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
6
|
+
|------|------|--------|------|
|
|
7
|
+
| scrollOrientation | `'vertical' \| 'horizontal'` | `'vertical'` | 滚动方向 |
|
|
8
|
+
| bounces | boolean | true | iOS 弹性回弹 |
|
|
9
|
+
| enableScroll | boolean | true | 是否允许滚动 |
|
|
10
|
+
| scrollBarEnable | boolean | true | 是否显示滚动条 |
|
|
11
|
+
| upperThreshold | number | 0 | 触发 onScrollToUpper 的距离阈值 (px) |
|
|
12
|
+
| lowerThreshold | number | 0 | 触发 onScrollToLower 的距离阈值 (px) |
|
|
13
|
+
| initialScrollOffset | number | 0 | 初始滚动偏移 (px),仅首屏有效 |
|
|
14
|
+
| onScrollToUpper | (e: ScrollToUpperEvent) => void | - | 滚动到顶/左 |
|
|
15
|
+
| onScrollToLower | (e: ScrollToLowerEvent) => void | - | 滚动到底/右 |
|
|
16
|
+
| onScroll | (e: ScrollEvent) => void | - | 滚动中 |
|
|
17
|
+
| onScrollEnd | (e: ScrollEndEvent) => void | - | 滚动结束 |
|
|
18
|
+
| onContentSizeChanged | (e: ContentSizeChangedEvent) => void | - | 内容尺寸变化 |
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
// 垂直滚动 + 上拉加载
|
|
22
|
+
<scroll-view
|
|
23
|
+
style={{ height: '100vh' }}
|
|
24
|
+
lowerThreshold={50}
|
|
25
|
+
onScrollToLower={() => loadMore()}
|
|
26
|
+
>
|
|
27
|
+
{items.map(item => <view key={item.id}>{/* ... */}</view>)}
|
|
28
|
+
</scroll-view>
|
|
29
|
+
|
|
30
|
+
// 水平滚动
|
|
31
|
+
<scroll-view scrollOrientation="horizontal" style={{ width: '100%' }}>
|
|
32
|
+
{images.map(img => <image key={img.id} src={img.url} style={{ width: '100px', height: '100px' }} />)}
|
|
33
|
+
</scroll-view>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## `<list>` / `list-item`
|
|
39
|
+
|
|
40
|
+
高性能列表,支持多列/瀑布流。
|
|
41
|
+
|
|
42
|
+
**`<list>` 必须显式指定 height**,不支持自适应高度。
|
|
43
|
+
|
|
44
|
+
`list-item` 是原生 Lynx 元素,属性名使用连字符(`item-key`、`sticky-top`),不是驼峰。
|
|
45
|
+
|
|
46
|
+
### list 属性
|
|
47
|
+
|
|
48
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
49
|
+
|------|------|--------|------|
|
|
50
|
+
| style | CSSProperties | - | **必须包含 height** |
|
|
51
|
+
| scrollOrientation | `'vertical' \| 'horizontal'` | `'vertical'` | 方向 |
|
|
52
|
+
| listType | `'single' \| 'flow' \| 'waterfall'` | `'single'` | 布局类型 |
|
|
53
|
+
| spanCount | number | 1 | 列数,flow/waterfall 时有效 |
|
|
54
|
+
| enableScroll | boolean | true | 是否允许滚动 |
|
|
55
|
+
| bounces | boolean | true | iOS 弹性回弹 |
|
|
56
|
+
| initialScrollIndex | number | 0 | 渲染后自动滚动到的节点位置 |
|
|
57
|
+
| lowerThresholdItemCount | number | 0 | 触发底部事件的剩余子节点数阈值 |
|
|
58
|
+
| upperThresholdItemCount | number | 0 | 触发顶部事件的剩余子节点数阈值 |
|
|
59
|
+
| scrollEventThrottle | number | 200 | 滚动事件节流间隔 (ms) |
|
|
60
|
+
| onScroll | (e: ListScrollEvent) => void | - | 滚动 |
|
|
61
|
+
| onScrollToUpper | (e: ListScrollToUpperEvent) => void | - | 滚动到顶部 |
|
|
62
|
+
| onScrollToLower | (e: ListScrollToLowerEvent) => void | - | 滚动到底部 |
|
|
63
|
+
| onLayoutComplete | (e: ListLayoutCompleteEvent) => void | - | 首屏渲染完成 |
|
|
64
|
+
|
|
65
|
+
### list-item 属性
|
|
66
|
+
|
|
67
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
68
|
+
|------|------|--------|------|
|
|
69
|
+
| item-key | string | - | **必填**,唯一标识 |
|
|
70
|
+
| sticky-top | boolean | false | 吸顶 |
|
|
71
|
+
| sticky-bottom | boolean | false | 吸底 |
|
|
72
|
+
| full-span | boolean | false | 多列时占满一行 |
|
|
73
|
+
| estimated-main-axis-size-px | number | -1 | 预估主轴尺寸 (px),瀑布流时建议填 |
|
|
74
|
+
| recyclable | boolean | true | 是否可回收 |
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
// 基础列表
|
|
78
|
+
<list style={{ height: '400px' }}>
|
|
79
|
+
{data.map(item => (
|
|
80
|
+
<list-item key={item.id} item-key={item.id}>
|
|
81
|
+
<view style={{ padding: '16px' }}><text>{item.title}</text></view>
|
|
82
|
+
</list-item>
|
|
83
|
+
))}
|
|
84
|
+
</list>
|
|
85
|
+
|
|
86
|
+
// 吸顶 header
|
|
87
|
+
<list style={{ height: '400px' }}>
|
|
88
|
+
<list-item item-key="header" sticky-top>
|
|
89
|
+
<view style={{ padding: '12px', background: '#f5f5f5' }}><text>吸顶标题</text></view>
|
|
90
|
+
</list-item>
|
|
91
|
+
{data.map(item => (
|
|
92
|
+
<list-item key={item.id} item-key={item.id}>
|
|
93
|
+
<view style={{ padding: '16px' }}><text>{item.title}</text></view>
|
|
94
|
+
</list-item>
|
|
95
|
+
))}
|
|
96
|
+
</list>
|
|
97
|
+
|
|
98
|
+
// 瀑布流
|
|
99
|
+
<list style={{ height: '100vh' }} listType="waterfall" spanCount={2}>
|
|
100
|
+
{items.map(item => (
|
|
101
|
+
<list-item key={item.id} item-key={item.id} estimated-main-axis-size-px={item.height}>
|
|
102
|
+
<view style={{ height: `${item.height}px` }}><text>{item.title}</text></view>
|
|
103
|
+
</list-item>
|
|
104
|
+
))}
|
|
105
|
+
</list>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## `<swiper>` / `<swiper-item>`
|
|
111
|
+
|
|
112
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
113
|
+
|------|------|--------|------|
|
|
114
|
+
| data | T[] | - | 轮播数据 |
|
|
115
|
+
| itemWidth | number | - | 每项宽度 |
|
|
116
|
+
| itemHeight | number \| `'auto'` | - | 每项高度 |
|
|
117
|
+
| children | (prop: RenderFunctionProps\<T\>) => ReactElement | - | 渲染函数,返回 swiper-item |
|
|
118
|
+
| containerWidth | number | screenWidth | 容器宽度 |
|
|
119
|
+
| initialIndex | number | 0 | 初始索引,仅首屏有效 |
|
|
120
|
+
| loop | boolean | false | 循环 |
|
|
121
|
+
| duration | number | 500 | 动画时长 (ms) |
|
|
122
|
+
| onChange | (current: number) => void | - | 索引变化 |
|
|
123
|
+
| onSwipeStart | (current: number) => void | - | 开始滑动 |
|
|
124
|
+
| onSwipeStop | (current: number) => void | - | 停止滑动 |
|
|
125
|
+
|
|
126
|
+
### swiper-item 属性
|
|
127
|
+
|
|
128
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
129
|
+
|------|------|--------|------|
|
|
130
|
+
| index | number | - | 当前索引 |
|
|
131
|
+
| real-index | number | index | 真实索引,循环模式下与 index 不同 |
|
|
132
|
+
| style | CSSProperties | - | 样式 |
|
|
133
|
+
| overlap | boolean | false | 透明度有问题时使用 |
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<swiper
|
|
137
|
+
data={images}
|
|
138
|
+
itemWidth={375}
|
|
139
|
+
itemHeight={200}
|
|
140
|
+
loop
|
|
141
|
+
onChange={(current) => console.log('current:', current)}
|
|
142
|
+
>
|
|
143
|
+
{({ item, index }) => (
|
|
144
|
+
<swiper-item index={index}>
|
|
145
|
+
<image src={item.url} style={{ width: '100%', height: '100%' }} mode="aspectFill" />
|
|
146
|
+
</swiper-item>
|
|
147
|
+
)}
|
|
148
|
+
</swiper>
|
|
149
|
+
```
|
|
@@ -0,0 +1,209 @@
|
|
|
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-dev/framework/components';
|
|
101
|
+
import { useRef } from '@doubao-dev/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-dev/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
|
+
Web 模拟器中的 `<web-view>` 通过本地代理承载 H5 页面,页面脚本读取到的
|
|
181
|
+
`location.origin` / `location.host` 可能是调试器本地域名,而不是真机 WebView 中的业务域名。
|
|
182
|
+
如果 H5 依赖 `location.origin` 或 `location.host` 判断测试环境、线上环境、白名单或鉴权逻辑,
|
|
183
|
+
Web 模拟器结果可能与真机不一致,请使用真机调试确认。
|
|
184
|
+
|
|
185
|
+
| 属性 | 类型 | 说明 |
|
|
186
|
+
|------|------|------|
|
|
187
|
+
| src | string | 网页地址 |
|
|
188
|
+
| onLoad | (event: { src: string }) => void | 加载成功 |
|
|
189
|
+
| onError | (event: { errorMsg: string; errorCode: number; url: string }) => void | 加载失败 |
|
|
190
|
+
| onMessage | (event: { data: unknown }) => void | 网页向应用 postMessage |
|
|
191
|
+
| ref | Ref<WebViewRef> | 获取 WebView 实例,可调用 `postMessage(data)` 向网页发送消息 |
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { useRef } from '@doubao-dev/framework';
|
|
195
|
+
import type { WebViewRef } from '@doubao-dev/framework/components';
|
|
196
|
+
|
|
197
|
+
const webViewRef = useRef<WebViewRef>(null);
|
|
198
|
+
|
|
199
|
+
<>
|
|
200
|
+
<web-view
|
|
201
|
+
ref={webViewRef}
|
|
202
|
+
src="https://example.com"
|
|
203
|
+
onLoad={(event) => console.log('网页加载成功:', event.src)}
|
|
204
|
+
onError={(event) => console.log('加载错误:', event.errorMsg, event.url)}
|
|
205
|
+
onMessage={(event) => console.log('收到消息:', event.data)}
|
|
206
|
+
/>
|
|
207
|
+
<button text="向网页发送消息" onClick={() => webViewRef.current?.postMessage({ type: 'ping' })} />
|
|
208
|
+
</>
|
|
209
|
+
```
|