@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.
Files changed (99) hide show
  1. package/dist/36.js +4 -4
  2. package/dist/template-empty/.ai/examples/common-patterns.md +53 -43
  3. package/dist/template-empty/.ai/examples/component-basics.md +0 -17
  4. package/dist/template-empty/.ai/guides/component-development.md +96 -214
  5. package/dist/template-empty/.ai/guides/system-prompt.md +14 -14
  6. package/dist/template-empty/.ai/reference/framework-api-quick-ref.md +46 -85
  7. package/dist/template-empty/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +13 -13
  8. package/dist/template-empty/.ai/reference/open-api/{02-storage.md → 02-/345/255/230/345/202/250.md} +13 -21
  9. package/dist/template-empty/.ai/reference/open-api/{03-router.md → 03-/350/267/257/347/224/261.md} +9 -9
  10. 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
  11. package/dist/template-empty/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
  12. package/dist/template-empty/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
  13. package/dist/template-empty/.ai/reference/open-api/{07-media.md → 07-/345/252/222/344/275/223.md} +8 -8
  14. 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
  15. 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
  16. 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
  17. package/dist/template-empty/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
  18. package/dist/template-empty/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
  19. package/dist/template-empty/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
  20. package/dist/template-empty/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
  21. package/dist/template-empty/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
  22. package/dist/template-empty/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
  23. package/dist/template-empty/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
  24. package/dist/template-empty/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
  25. package/dist/template-empty/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
  26. package/dist/template-empty/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
  27. package/dist/template-empty/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
  28. package/dist/template-empty/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
  29. package/dist/template-empty/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
  30. package/dist/template-empty/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
  31. package/dist/template-empty/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
  32. package/dist/template-empty/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
  33. package/dist/template-empty/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
  34. package/dist/template-empty/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
  35. package/dist/template-empty/.ai/reference/open-api/README.md +27 -11
  36. package/dist/template-empty/.ai/reference/open-api.md +275 -8
  37. package/dist/template-empty/.ai/rules/dos-and-donts.md +50 -37
  38. package/dist/template-empty/AGENTS.md +54 -31
  39. package/dist/template-empty/README.md +57 -10
  40. package/dist/template-empty/package.json +2 -2
  41. package/dist/template-empty/src/app.config.ts +6 -0
  42. package/dist/template-empty/src/app.ts +0 -6
  43. package/dist/template-empty/tsconfig.json +2 -0
  44. package/dist/template-starter/.ai/examples/common-patterns.md +53 -43
  45. package/dist/template-starter/.ai/examples/component-basics.md +0 -17
  46. package/dist/template-starter/.ai/guides/component-development.md +96 -214
  47. package/dist/template-starter/.ai/guides/system-prompt.md +14 -14
  48. package/dist/template-starter/.ai/reference/framework-api-quick-ref.md +46 -85
  49. package/dist/template-starter/.ai/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +13 -13
  50. package/dist/template-starter/.ai/reference/open-api/{02-storage.md → 02-/345/255/230/345/202/250.md} +13 -21
  51. package/dist/template-starter/.ai/reference/open-api/{03-router.md → 03-/350/267/257/347/224/261.md} +9 -9
  52. 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
  53. package/dist/template-starter/.ai/reference/open-api/05-/347/225/214/351/235/242-/350/276/223/345/205/245.md +42 -0
  54. package/dist/template-starter/.ai/reference/open-api/06-/347/275/221/347/273/234.md +148 -0
  55. package/dist/template-starter/.ai/reference/open-api/{07-media.md → 07-/345/252/222/344/275/223.md} +8 -8
  56. 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
  57. 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
  58. 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
  59. package/dist/template-starter/.ai/reference/open-api/11-/350/256/276/345/244/207-/345/212/240/351/200/237/345/272/246/350/256/241.md +104 -0
  60. package/dist/template-starter/.ai/reference/open-api/12-/350/256/276/345/244/207-ibeacon.md +148 -0
  61. package/dist/template-starter/.ai/reference/open-api/13-/350/256/276/345/244/207-/347/275/227/347/233/230.md +82 -0
  62. package/dist/template-starter/.ai/reference/open-api/14-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +70 -0
  63. package/dist/template-starter/.ai/reference/open-api/15-/350/256/276/345/244/207-/351/231/200/350/236/272/344/273/252.md +104 -0
  64. package/dist/template-starter/.ai/reference/open-api/16-ui-/350/276/223/345/205/245.md +65 -0
  65. package/dist/template-starter/.ai/reference/open-api/17-/350/256/276/345/244/207-/347/275/221/347/273/234.md +164 -0
  66. package/dist/template-starter/.ai/reference/open-api/18-/350/256/276/345/244/207-/347/237/255/344/277/241.md +62 -0
  67. package/dist/template-starter/.ai/reference/open-api/19-/350/256/276/345/244/207-/346/227/240/351/232/234/347/242/215.md +43 -0
  68. package/dist/template-starter/.ai/reference/open-api/20-/350/256/276/345/244/207-/347/224/265/346/261/240.md +83 -0
  69. package/dist/template-starter/.ai/reference/open-api/21-/350/256/276/345/244/207-/346/227/245/345/216/206.md +215 -0
  70. package/dist/template-starter/.ai/reference/open-api/22-/350/256/276/345/244/207-/345/211/252/350/264/264/346/235/277.md +70 -0
  71. package/dist/template-starter/.ai/reference/open-api/23-/350/256/276/345/244/207-/350/201/224/347/263/273/344/272/272.md +270 -0
  72. package/dist/template-starter/.ai/reference/open-api/24-/350/256/276/345/244/207-/345/212/240/345/257/206.md +56 -0
  73. package/dist/template-starter/.ai/reference/open-api/25-/350/256/276/345/244/207-/347/224/265/350/257/235.md +41 -0
  74. package/dist/template-starter/.ai/reference/open-api/26-/350/256/276/345/244/207-/346/211/253/347/240/201.md +100 -0
  75. package/dist/template-starter/.ai/reference/open-api/27-/350/256/276/345/244/207-/345/261/217/345/271/225.md +173 -0
  76. package/dist/template-starter/.ai/reference/open-api/28-/350/256/276/345/244/207-/351/234/207/345/212/250.md +66 -0
  77. package/dist/template-starter/.ai/reference/open-api/README.md +27 -11
  78. package/dist/template-starter/.ai/reference/open-api.md +275 -8
  79. package/dist/template-starter/.ai/rules/dos-and-donts.md +50 -37
  80. package/dist/template-starter/AGENTS.md +54 -31
  81. package/dist/template-starter/README.md +6 -1
  82. package/dist/template-starter/package.json +2 -2
  83. package/dist/template-starter/src/app.config.ts +35 -0
  84. package/dist/template-starter/src/app.ts +0 -6
  85. package/dist/template-starter/src/pages/applet/index.tsx +0 -5
  86. package/dist/template-starter/src/pages/home/index.tsx +0 -5
  87. package/dist/template-starter/src/pages/lynx/index.tsx +0 -4
  88. package/dist/template-starter/src/pages/react-lynx/index.tsx +0 -5
  89. package/dist/template-starter/src/widgets/weather-card/index.tsx +0 -4
  90. package/dist/template-starter/tsconfig.json +2 -0
  91. package/package.json +1 -1
  92. package/dist/template-empty/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +0 -95
  93. package/dist/template-empty/.ai/reference/open-api/06-network.md +0 -298
  94. package/dist/template-empty/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +0 -372
  95. 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
  96. package/dist/template-starter/.ai/reference/open-api/05-ui-/350/276/223/345/205/245.md +0 -95
  97. package/dist/template-starter/.ai/reference/open-api/06-network.md +0 -298
  98. package/dist/template-starter/.ai/reference/open-api/11-device-/344/274/240/346/204/237/345/231/250.md +0 -372
  99. 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
@@ -21,7 +21,7 @@
21
21
 
22
22
  ### **项目文档系统**
23
23
  本地项目文档(按优先级):
24
- 1. **AGENTS.md** - 项目主入口,包含快速开始和核心规则
24
+ 1. **SKILL.md** - 项目主入口,包含快速开始和核心规则
25
25
  2. **.ai/rules/** - 框架规则和约束
26
26
  3. **.ai/guides/** - 开发指南
27
27
  4. **.ai/examples/** - 代码示例库
@@ -50,7 +50,7 @@ LynxBase MCP 提供:
50
50
  ## 知识体系
51
51
 
52
52
  ### 知识优先级
53
- 1. **项目本地文档**(AGENTS.md 及 .ai/ 目录)
53
+ 1. **项目本地文档**(SKILL.md 及 .ai/ 目录)
54
54
  2. **LynxBase MCP**(Lynx 官方/内部文档)
55
55
  3. **通用编程知识**
56
56
 
@@ -64,7 +64,7 @@ LynxBase MCP 提供:
64
64
 
65
65
  [生成代码]
66
66
 
67
- 详细的开发规范请参考:[.ai/prompts/component-development.md](.ai/prompts/component-development.md)
67
+ 详细的开发规范请参考:[component-development.md](component-development.md)
68
68
  ```
69
69
 
70
70
  **错误做法**:
@@ -191,7 +191,7 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
191
191
 
192
192
  **4. 项目结构问题** → 引用本地文档
193
193
  - 示例:"如何组织组件?"
194
- - 响应:简短说明 + 引用 AGENTS.md 或 .ai/rules/
194
+ - 响应:简短说明 + 引用 SKILL.md 或 .ai/rules/
195
195
 
196
196
  **5. 问题诊断** → 分析 + 解决方案 + 预防措施
197
197
  - 示例:"报错了"
@@ -209,7 +209,7 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
209
209
 
210
210
  2. **规划方法**
211
211
  - **Lynx 相关** → 查询 **LynxBase MCP** 获取支持数据
212
- - **项目结构/规则** → 引用本地文档(AGENTS.md、.ai/)
212
+ - **项目结构/规则** → 引用本地文档(SKILL.md、.ai/)
213
213
 
214
214
  3. **调用适当工具**
215
215
  - Lynx 相关 → **LynxBase MCP**
@@ -261,7 +261,7 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
261
261
  - 提供错误处理代码
262
262
 
263
263
  4. ❌ **不要违反框架规则**
264
- - 严格遵守 AGENTS.md 和 Lynx 规范
264
+ - 严格遵守 SKILL.md 和 Lynx 规范
265
265
  - 不要为了方便走捷径
266
266
 
267
267
  5. ❌ **不要过度工程化**
@@ -280,13 +280,13 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
280
280
 
281
281
  | 用户请求 | 查阅文档 | 你的动作 |
282
282
  |---------|---------|---------|
283
- | "创建页面" | `.ai/prompts/component-development.md` (Page) + LynxBase MCP | 生成代码 + 引用文档 |
284
- | "创建卡片" | `.ai/prompts/component-development.md` (Widget) + LynxBase MCP | 生成代码 + 引用文档 |
283
+ | "创建页面" | `.ai/guides/component-development.md` (Page) + LynxBase MCP | 生成代码 + 引用文档 |
284
+ | "创建卡片" | `.ai/guides/component-development.md` (Widget) + LynxBase MCP | 生成代码 + 引用文档 |
285
285
  | "Lynx 组件如何用" | LynxBase MCP → `query-assets` → `get-assets` | 查询 + 提供示例 |
286
286
  | "如何调用 API" | `.ai/examples/common-patterns.md` + Doubao Bridge 文档 | 提供示例 + 引用文档 |
287
- | "性能优化" | `.ai/prompts/performance-optimization.md` + Lynx 性能指南 | 分析问题 + 引用文档 |
288
- | "报错了" | `.ai/prompts/troubleshooting.md` + 错误分析 | 诊断 + 修复 + 引用文档 |
289
- | "框架规则" | `.ai/rules/dos-and-donts.md` + AGENTS.md | 简要说明 + 引用文档 |
287
+ | "性能优化" | `.ai/guides/performance-optimization.md` + Lynx 性能指南 | 分析问题 + 引用文档 |
288
+ | "报错了" | `.ai/guides/troubleshooting.md` + 错误分析 | 诊断 + 修复 + 引用文档 |
289
+ | "框架规则" | `.ai/rules/dos-and-donts.md` + SKILL.md | 简要说明 + 引用文档 |
290
290
 
291
291
  ---
292
292
 
@@ -309,7 +309,7 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
309
309
  1. 调用 **LynxBase MCP** 查询主线程相关文档
310
310
  2. 简短解释:"主线程脚本是在 Lynx 主线程执行的 JS 代码,用于高频交互和实时更新..."
311
311
  3. 提供简单示例
312
- 4. 引用详细文档:"更多详情请查阅 LynxBase 文档或参考 [性能优化指南](.ai/prompts/performance-optimization.md)"
312
+ 4. 引用详细文档:"更多详情请查阅 LynxBase 文档或参考 [性能优化指南](performance-optimization.md)"
313
313
 
314
314
  ### 示例 3:项目规则
315
315
  **用户**:"组件应该放在哪里?"
@@ -324,8 +324,8 @@ ReactLynx 镜像 React API(`useState`、`useEffect` 等),但所有生命
324
324
  - `index.scss` - 样式文件
325
325
  - `types.ts` - 类型定义(可选)
326
326
 
327
- 详细规范请参考:[AGENTS.md](./AGENTS.md) 和 [组件开发指南](.ai/prompts/component-development.md)"
327
+ 详细规范请参考:[SKILL.md](../../SKILL.md) 和 [组件开发指南](component-development.md)"
328
328
 
329
329
  ---
330
330
 
331
- *系统提示词版本: 2.0.0 | 集成: Lynx + Doubao Apps SDK | 维护: Doubao Apps SDK 团队*
331
+ *系统提示词版本: 2.0.0 | 集成: Lynx + Doubao Apps SDK | 维护: Doubao Apps SDK 团队*
@@ -136,7 +136,7 @@ console.log(info.keys, info.currentSize, info.limitSize);
136
136
  ## 引入依赖
137
137
 
138
138
  ```ts
139
- import { getLocation, getPhoneNumber, openPage, request, showToast, setStorage, getStorage } from '@doubao-apps/framework/api';
139
+ import { getLocation, getPhoneNumber, navigateTo, navigateBack, request, showToast, setStorage, getStorage } from '@doubao-apps/framework/api';
140
140
  ```
141
141
 
142
142
  ## 使用示例
@@ -144,7 +144,8 @@ import { getLocation, getPhoneNumber, openPage, request, showToast, setStorage,
144
144
  ```ts
145
145
  await showToast({ message: '保存成功' });
146
146
 
147
- const { viewId } = await openPage({ pageId: 'detail', context: {} });
147
+ await navigateTo({ url: 'detail?id=123' });
148
+ await navigateBack();
148
149
 
149
150
  const res = await request({ url: '/api/data', method: 'GET' });
150
151
 
@@ -155,85 +156,57 @@ const phone = await getPhoneNumber();
155
156
 
156
157
  以下为常用端能力 API 的节选,完整以 `@doubao-apps/framework/api` 类型定义为准。
157
158
 
158
- ### openFloatingWindow
159
+ ### navigateTo
159
160
 
160
161
  **参数**:
161
162
  ```typescript
162
163
  {
163
- /** 期望要打开的 page id */
164
- pageId: string;
165
-
166
- /** 打开页面时传入的数据,运行时通过 getViewData 获取 */
167
- pageData?: string;
168
-
169
- /** view context 对象,在全页和卡片中通过 getViewContext() 获取 */
170
- context: object;
171
-
172
- /** 打开 Page 时配置页面参数 */
173
- pageSettings?: {
174
- /**
175
- * 悬浮窗口在横向上的吸附位置
176
- *
177
- * @deprecated 最新的 Lynx 悬浮窗中已失效
178
- */
179
- align?: 'left' | 'right';
180
-
181
- /**
182
- * 设置 Lynx 悬浮窗的宽度,单位是 `px`
183
- */
184
- width?: number;
185
-
186
- /**
187
- * 设置 Lynx 悬浮窗的高度,单位是 `px`
188
- */
189
- height?: number;
190
-
191
- /**
192
- * 优先级。越高代表优先级越高,取值-2~2
193
- */
194
- priority?: number;
195
-
196
- /**
197
- * 是否自动恢复展示。在被高优悬浮窗打断时会发挥作用,只有为 true 才会得到恢复的机会,否则直接释放
198
- */
199
- autoReshow?: boolean;
200
- };
164
+ /** 跳转目标,填写页面的 pageId,可拼接 query,如 'detail?id=123' */
165
+ url: string;
201
166
  }
202
167
  ```
203
168
 
204
- **返回值**:
169
+ **返回值**: Promise
170
+
171
+ ### redirectTo
172
+
173
+ **参数**:
205
174
  ```typescript
206
175
  {
207
- /** 创建出的 view id */
208
- viewId: string;
209
-
210
- /**
211
- * 返回展示悬浮窗的结果
212
- * 0: 展示失败
213
- * 1: 展示成功
214
- * 2: 排队中
215
- */
216
- floatingShowResult?: number;
176
+ /** 跳转目标,填写页面的 pageId,如 'settings' */
177
+ url: string;
217
178
  }
218
179
  ```
219
180
 
220
- ### close
181
+ **返回值**: Promise
182
+
183
+ ### reLaunch
221
184
 
222
185
  **参数**:
223
186
  ```typescript
224
187
  {
225
- /** 要关闭的页面 id,留空(undefined) 为当前页面 */
226
- viewID?: string;
227
- /** 要关闭的多个页面 id */
228
- viewIDs?: string[];
229
- /**
230
- * @default false
231
- */
232
- animated?: boolean;
188
+ /** 跳转目标,填写页面的 pageId,如 'home' */
189
+ url: string;
233
190
  }
234
191
  ```
235
192
 
236
- **返回值**: 无(空对象)
193
+ **返回值**: Promise
194
+
195
+ ### navigateBack
196
+
197
+ **参数**:
198
+ ```typescript
199
+ {
200
+ /** 返回的页面数,默认为 1 */
201
+ delta?: number;
202
+ }
203
+ ```
204
+
205
+ **返回值**: Promise
206
+
207
+ > `close()` 已废弃,公开路由场景请优先使用 `navigateBack()`。
208
+ >
209
+ > 常规页面跳转场景下,`url` 直接使用目标页面的 `pageId`,该值一般与页面的 `aiMeta.id` 一致;需要传参时可直接拼接 query string。
237
210
 
238
211
  ### showToast
239
212
 
@@ -413,7 +386,7 @@ const phone = await getPhoneNumber();
413
386
 
414
387
  | API | 功能 | 示例 |
415
388
  |-----|------|------|
416
- | `sendQueryMessage(params)` | 发送用户消息 | `sendQueryMessage({ content: '查询天气', type: 'text', context: {} })` |
389
+ | `sendQueryMessage(params)` | 发送用户消息 | `sendQueryMessage({ content: '查询天气', type: 'text' })` |
417
390
  | `setAdditionalContext(params)` | 设置上下文 | `setAdditionalContext({ additionalContext: '...' })` |
418
391
 
419
392
  ### sendQueryMessage
@@ -426,12 +399,6 @@ const phone = await getPhoneNumber();
426
399
 
427
400
  /** 消息类型,目前仅支持 text */
428
401
  type: 'text';
429
-
430
- /** Plugin tool 或 Page/Widget 携带的上下文信息 */
431
- context: object;
432
-
433
- /** 扩展信息 */
434
- ext?: Record<string, string>;
435
402
  }
436
403
  ```
437
404
 
@@ -500,21 +467,7 @@ interface PageInput {
500
467
  [key: string]: any; // URL 参数
501
468
  }
502
469
 
503
- // Widget Input Schema
504
- interface WidgetInputSchema {
505
- type: 'object';
506
- properties: {
507
- [key: string]: {
508
- type: 'string' | 'number' | 'boolean' | 'array' | 'object';
509
- title: string;
510
- description?: string;
511
- default?: any;
512
- };
513
- };
514
- required?: string[];
515
- }
516
-
517
- // aiMeta 配置
470
+ // src/app.config.ts 中的 metadata 配置
518
471
  interface PageAIMeta {
519
472
  id: string; // 页面唯一标识
520
473
  title?: string; // 页面标题
@@ -526,7 +479,15 @@ interface WidgetAIMeta {
526
479
  name?: string; // 卡片名称
527
480
  description?: string; // 卡片描述
528
481
  boxType?: 'inbox' | 'full_box'; // 卡片类型
529
- input: WidgetInputSchema; // 输入数据格式
482
+ border?: boolean; // 是否显示边框
483
+ keywords?: string[]; // 搜索关键词
484
+ titleType?: 'none' | 'normal' | 'float';
485
+ }
486
+
487
+ // Widget 渲染数据类型
488
+ interface WidgetViewData {
489
+ title: string;
490
+ content?: string;
530
491
  }
531
492
  ```
532
493
 
@@ -6,19 +6,19 @@
6
6
 
7
7
  ## 速查
8
8
 
9
- | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
- | --- | --- | --- | --- | --- | --- |
11
- | [`getAccountInfo`](#getaccountinfo) | `getAccountInfo(params?): Promise<GetAccountInfoResult>` | 异步获取账号信息 | `params?` | `Promise<GetAccountInfoResult>` | - |
12
- | [`getAccountInfoSync`](#getaccountinfosync) | `getAccountInfoSync(params?): GetAccountInfoResult` | 同步获取账号信息 | `params?` | `GetAccountInfoResult` | 同步 API |
13
- | [`authorize`](#authorize) | `authorize(params): Promise<object>` | 初始化授权 | `params: AuthorizeRequest` | `Promise<object>` | 按 scope 申请授权 |
14
- | [`canIUse`](#caniuse) | `canIUse(params): Promise<CanIUseResult>` | 检测当前宿主是否支持指定 API 或能力 | `params: CanIUseParams` | `Promise<CanIUseResult>` | 用于兼容性判断 |
15
- | [`getLocation`](#getlocation) | `getLocation(params?): Promise<GetLocationResponse>` | 获取设备当前的地理位置信息 | `params?: GetLocationParams` | `Promise<GetLocationResponse>` | 可能涉及定位授权 |
16
- | [`login`](#login) | `login(params?): Promise<LoginResult>` | 发起登录并获取登录凭证 | `params?: LoginRequest` | `Promise<LoginResult>` | - |
17
- | [`getWindowInfoSync`](#getwindowinfosync) | `getWindowInfoSync(_param?): GetWindowInfoResult` | 获取窗口信息 | `_param?` | `GetWindowInfoResult` | 同步 API |
18
- | [`getSystemSetting`](#getsystemsetting) | `getSystemSetting(params?): GetSystemSettingResult` | 获取设备设置 | `params?` | `GetSystemSettingResult` | - |
19
- | [`getAppBaseInfoSync`](#getappbaseinfosync) | `getAppBaseInfoSync(_params?): GetAppBaseInfoResult` | 获取应用基础信息 | `_params?` | `GetAppBaseInfoResult` | 同步 API |
20
- | [`getWindowInfo`](#getwindowinfo) | `getWindowInfo(_params?): Promise<GetWindowInfoResult>` | 获取窗口信息 | `_params?` | `Promise<GetWindowInfoResult>` | - |
21
- | [`getAppBaseInfo`](#getappbaseinfo) | `getAppBaseInfo(params?): Promise<GetAppBaseInfoResult>` | 获取应用基础信息 | `params?` | `Promise<GetAppBaseInfoResult>` | - |
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [getAccountInfo](#getaccountinfo) | 异步获取账号信息。 |
12
+ | [getAccountInfoSync](#getaccountinfosync) | 同步获取账号信息。<br><br>同步 API |
13
+ | [authorize](#authorize) | 初始化授权。<br><br>按 scope 申请授权。 |
14
+ | [canIUse](#caniuse) | 检测当前宿主是否支持指定 API 或能力。<br><br>用于兼容性判断。 |
15
+ | [getLocation](#getlocation) | 获取设备当前的地理位置信息。<br><br>可能涉及定位授权。 |
16
+ | [login](#login) | 发起登录并获取登录凭证。 |
17
+ | [getWindowInfoSync](#getwindowinfosync) | 获取窗口信息。<br><br>同步 API |
18
+ | [getSystemSetting](#getsystemsetting) | 获取设备设置。 |
19
+ | [getAppBaseInfoSync](#getappbaseinfosync) | 获取应用基础信息。<br><br>同步 API |
20
+ | [getWindowInfo](#getwindowinfo) | 获取窗口信息。 |
21
+ | [getAppBaseInfo](#getappbaseinfo) | 获取应用基础信息。 |
22
22
 
23
23
  ## API 详情
24
24
 
@@ -1,4 +1,4 @@
1
- # Open API: Storage
1
+ # Open API: 存储
2
2
 
3
3
  本地缓存;带 Sync 后缀的是同步 API。
4
4
 
@@ -6,18 +6,18 @@
6
6
 
7
7
  ## 速查
8
8
 
9
- | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
- | --- | --- | --- | --- | --- | --- |
11
- | [`setStorage`](#setstorage) | `setStorage<TData>(params): Promise<object>` | 将数据写入本地缓存 | `params: SetStorageParams<TData>` | `Promise<object>` | data 会 JSON 序列化 |
12
- | [`setStorageSync`](#setstoragesync) | `setStorageSync<TData>(params): object` | 将数据写入本地缓存 | `params: SetStorageParams<TData>` | `object` | data 会 JSON 序列化;同步 API |
13
- | [`getStorage`](#getstorage) | `getStorage<TData>(params): Promise<GetStorageResult<TData>>` | 从本地缓存读取数据 | `params: GetStorageParams` | `Promise<GetStorageResult<TData>>` | data 会 JSON 反序列化 |
14
- | [`getStorageSync`](#getstoragesync) | `getStorageSync<TData>(params): GetStorageResult<TData>` | 从本地缓存同步读取数据 | `params: GetStorageParams` | `GetStorageResult<TData>` | data 会 JSON 反序列化;同步 API |
15
- | [`removeStorage`](#removestorage) | `removeStorage(params): Promise<object>` | 删除本地缓存中指定 key 的数据 | `params: RemoveStorageParams` | `Promise<object>` | - |
16
- | [`removeStorageSync`](#removestoragesync) | `removeStorageSync(params?): object` | 删除本地缓存中指定 key 的数据 | `params?: RemoveStorageParams` | `object` | 同步 API |
17
- | [`clearStorage`](#clearstorage) | `clearStorage(params?): Promise<object>` | 清空本地缓存 | `params?: object` | `Promise<object>` | - |
18
- | [`clearStorageSync`](#clearstoragesync) | `clearStorageSync(params?): object` | 清空本地缓存 | `params?: object` | `object` | 同步 API |
19
- | [`getStorageInfo`](#getstorageinfo) | `getStorageInfo(params?): Promise<GetStorageInfoResult>` | 获取本地缓存信息 | `params?` | `Promise<GetStorageInfoResult>` | - |
20
- | [`getStorageInfoSync`](#getstorageinfosync) | `getStorageInfoSync(params?): GetStorageInfoResult` | 同步获取本地缓存信息 | `params?` | `GetStorageInfoResult` | 同步 API |
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [setStorage](#setstorage) | 将数据写入本地缓存。 |
12
+ | [setStorageSync](#setstoragesync) | 将数据写入本地缓存。<br><br>同步 API |
13
+ | [getStorage](#getstorage) | 从本地缓存读取数据。 |
14
+ | [getStorageSync](#getstoragesync) | 从本地缓存同步读取数据。<br><br>同步 API |
15
+ | [removeStorage](#removestorage) | 删除本地缓存中指定 key 的数据。 |
16
+ | [removeStorageSync](#removestoragesync) | 删除本地缓存中指定 key 的数据。<br><br>同步 API |
17
+ | [clearStorage](#clearstorage) | 清空本地缓存。 |
18
+ | [clearStorageSync](#clearstoragesync) | 清空本地缓存。<br><br>同步 API |
19
+ | [getStorageInfo](#getstorageinfo) | 获取本地缓存信息。 |
20
+ | [getStorageInfoSync](#getstorageinfosync) | 同步获取本地缓存信息。<br><br>同步 API |
21
21
 
22
22
  ## API 详情
23
23
 
@@ -46,8 +46,6 @@
46
46
 
47
47
  #### Remarks
48
48
 
49
- data 会 JSON 序列化。
50
-
51
49
  #### Example
52
50
 
53
51
  ```typescript
@@ -84,8 +82,6 @@ await setStorage({
84
82
 
85
83
  #### Remarks
86
84
 
87
- data 会 JSON 序列化。
88
-
89
85
  #### Example
90
86
 
91
87
  ```typescript
@@ -122,8 +118,6 @@ setStorageSync({
122
118
 
123
119
  #### Remarks
124
120
 
125
- data 会 JSON 反序列化。
126
-
127
121
  #### Example
128
122
 
129
123
  ```typescript
@@ -161,8 +155,6 @@ console.log(result.data.name, result.data.age);
161
155
 
162
156
  #### Remarks
163
157
 
164
- data 会 JSON 反序列化。
165
-
166
158
  #### Example
167
159
 
168
160
  ```typescript
@@ -1,4 +1,4 @@
1
- # Open API: Router
1
+ # Open API: 路由
2
2
 
3
3
  应用内页面跳转和关闭。
4
4
 
@@ -6,14 +6,14 @@
6
6
 
7
7
  ## 速查
8
8
 
9
- | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
- | --- | --- | --- | --- | --- | --- |
11
- | [`close`](#close) | `close(params?): Promise<object>` | 关闭栈顶页面 | `params?: CloseParams` | `Promise<object>` | 已废弃,使用 navigateBack |
12
- | [`navigateTo`](#navigateto) | `navigateTo(params): Promise<object>` | 保留当前页面,跳转到应用内的某个页面 | `params: NavigateToParams` | `Promise<object>` | - |
13
- | [`redirectTo`](#redirectto) | `redirectTo(params): Promise<object>` | 关闭当前页面,跳转到应用内的某个页面 | `params: NavigateToParams` | `Promise<object>` | - |
14
- | [`reLaunch`](#relaunch) | `reLaunch(params): Promise<object>` | 关闭所有页面并跳转到应用内页面 | `params: NavigateToParams` | `Promise<object>` | - |
15
- | [`navigateBack`](#navigateback) | `navigateBack(params?): Promise<object>` | 关闭当前页面,返回上一页面或多级页面 | `params?: NavigateBackParams` | `Promise<object>` | - |
16
- | [`exitApp`](#exitapp) | `exitApp(): Promise<object>` | 退出当前所有页面 | `-` | `Promise<object>` | 会退出当前所有页面 |
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [close](#close) | 关闭栈顶页面。<br><br>已废弃,使用 navigateBack |
12
+ | [navigateTo](#navigateto) | 保留当前页面,跳转到应用内的某个页面。 |
13
+ | [redirectTo](#redirectto) | 关闭当前页面,跳转到应用内的某个页面。 |
14
+ | [reLaunch](#relaunch) | 关闭所有页面并跳转到应用内页面。 |
15
+ | [navigateBack](#navigateback) | 关闭当前页面,返回上一页面或多级页面。 |
16
+ | [exitApp](#exitapp) | 退出当前所有页面。<br><br>会退出当前所有页面。 |
17
17
 
18
18
  ## API 详情
19
19
 
@@ -1,4 +1,4 @@
1
- # Open API: UI / 交互
1
+ # Open API: 界面 / 交互
2
2
 
3
3
  Toast、Loading、Modal、ActionSheet 和返回前提醒。
4
4
 
@@ -6,17 +6,17 @@ Toast、Loading、Modal、ActionSheet 和返回前提醒。
6
6
 
7
7
  ## 速查
8
8
 
9
- | API | 签名 | 用途 | 参数类型 | 结果类型 | 注意点 |
10
- | --- | --- | --- | --- | --- | --- |
11
- | [`showModal`](#showmodal) | `showModal(params): Promise<ShowModalResult>` | 显示模态对话框 | `params: ShowModalParams` | `Promise<ShowModalResult>` | - |
12
- | [`showLoading`](#showloading) | `showLoading(params?): Promise<object>` | 显示 loading 提示框 | `params?: ShowLoadingParams` | `Promise<object>` | 需调用 hideLoading 关闭 |
13
- | [`hideToast`](#hidetoast) | `hideToast(params?): Promise<object>` | 隐藏当前 Toast | `params?: HideInteractionParams` | `Promise<object>` | - |
14
- | [`hideLoading`](#hideloading) | `hideLoading(params?): Promise<object>` | 隐藏当前 loading | `params?: HideInteractionParams` | `Promise<object>` | - |
15
- | [`showActionSheet`](#showactionsheet) | `showActionSheet(params): Promise<ShowActionSheetResult>` | 显示操作菜单 | `params: ShowActionSheetParams` | `Promise<ShowActionSheetResult>` | - |
16
- | [`getMenuButtonBoundingClientRect`](#getmenubuttonboundingclientrect) | `getMenuButtonBoundingClientRect(params?): MenuButtonBoundingClientRect` | 获取菜单按钮的布局位置信息 | `params?` | `MenuButtonBoundingClientRect` | - |
17
- | [`enableAlertBeforeUnload`](#enablealertbeforeunload) | `enableAlertBeforeUnload(params): Promise<object>` | 开启页面返回前提醒 | `params: EnableAlertBeforeUnloadParams` | `Promise<object>` | 配合 disableAlertBeforeUnload 使用 |
18
- | [`disableAlertBeforeUnload`](#disablealertbeforeunload) | `disableAlertBeforeUnload(params?): Promise<object>` | 关闭页面返回前提醒 | `params?: Record<string, never>` | `Promise<object>` | - |
19
- | [`showToast`](#showtoast) | `showToast(params): Promise<object>` | 显示 Toast 提示 | `params: ShowToastParams` | `Promise<object>` | duration 和 icon 可控制提示表现 |
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [showModal](#showmodal) | 显示模态对话框。 |
12
+ | [showLoading](#showloading) | 显示 loading 提示框。<br><br>需调用 hideLoading 关闭。 |
13
+ | [hideToast](#hidetoast) | 隐藏当前 Toast |
14
+ | [hideLoading](#hideloading) | 隐藏当前 loading |
15
+ | [showActionSheet](#showactionsheet) | 显示操作菜单。 |
16
+ | [getMenuButtonBoundingClientRect](#getmenubuttonboundingclientrect) | 获取菜单按钮的布局位置信息。 |
17
+ | [enableAlertBeforeUnload](#enablealertbeforeunload) | 开启页面返回前提醒。<br><br>配合 disableAlertBeforeUnload 使用。 |
18
+ | [disableAlertBeforeUnload](#disablealertbeforeunload) | 关闭页面返回前提醒。 |
19
+ | [showToast](#showtoast) | 显示 Toast 提示。<br><br>duration 和 icon 可控制提示表现。 |
20
20
 
21
21
  ## API 详情
22
22
 
@@ -0,0 +1,42 @@
1
+ # Open API: 界面 / 输入
2
+
3
+ 键盘和输入框选区能力。
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [onKeyboardHeightChange](#onkeyboardheightchange) | 监听键盘高度变化事件。<br><br>返回取消监听函数。 |
12
+
13
+ ## API 详情
14
+
15
+ <a id="onkeyboardheightchange"></a>
16
+ ### onKeyboardHeightChange()
17
+
18
+ > **onKeyboardHeightChange**(`handler`): () => `void`
19
+
20
+ 监听键盘高度变化事件。
21
+
22
+ #### Parameters
23
+
24
+ • **handler**
25
+
26
+ #### Returns
27
+
28
+ `Function`
29
+
30
+ ##### Returns
31
+
32
+ `void`
33
+
34
+ #### Example
35
+
36
+ ```typescript
37
+ import { onKeyboardHeightChange } from '@doubao-apps/framework/api';
38
+
39
+ const unsubscribe = onKeyboardHeightChange(({ height }) => {
40
+ console.log('Keyboard height change event:', { height });
41
+ });
42
+ ```
@@ -0,0 +1,148 @@
1
+ # Open API: 网络
2
+
3
+ 网络请求
4
+
5
+ [返回目录](./README.md) | [返回速查](../open-api.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [request](#request) | 发起网络请求。<br><br>返回 statusCode、header 和 data。 |
12
+
13
+ ## API 详情
14
+
15
+ <a id="request"></a>
16
+ ### request()
17
+
18
+ > **request**(`params`): `Promise`\<[`RequestResponse`](#requestresponse)\>
19
+
20
+ 发起网络请求。
21
+
22
+ #### Parameters
23
+
24
+ • **params**: [`RequestParams`](#requestparams)
25
+
26
+ 请求参数,字段见 [RequestParams](#requestparams)。
27
+
28
+ #### Returns
29
+
30
+ `Promise`\<[`RequestResponse`](#requestresponse)\>
31
+
32
+ 返回一个 Promise,解析为 [RequestResponse](#requestresponse)。
33
+
34
+ #### Remarks
35
+
36
+ 返回 statusCode、header 和 data。
37
+
38
+ #### Example
39
+
40
+ ```typescript
41
+ import { request } from '@doubao-apps/framework/api';
42
+
43
+ const result = await request({
44
+ url: 'https://postman-echo.com/post',
45
+ method: 'POST',
46
+ dataType: 'json',
47
+ header: { 'content-type': 'application/json' },
48
+ data: { hello: 'world' }
49
+ });
50
+
51
+ console.log(result.statusCode, result.data);
52
+ ```
53
+
54
+ ## 相关类型
55
+
56
+ <a id="requestparams"></a>
57
+ ### RequestParams
58
+
59
+ 网络请求参数。
60
+
61
+ #### Properties
62
+
63
+ ##### data?
64
+
65
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
66
+
67
+ 请求体数据。
68
+
69
+ 传给服务器的数据最终会是 `String` 或 `ArrayBuffer`:
70
+ - 若 `data` 是 `string` 或 `ArrayBuffer`,直接使用;
71
+ - 若 `header['content-type']` 是 `application/x-www-form-urlencoded`,会被编码为 query string,例如:`encodeURIComponent(k)=encodeURIComponent(v)`;
72
+ - 若 `header['content-type']` 是 `application/json`,会执行 JSON 序列化;
73
+ - 若 `data` 是普通对象且未命中上述类型,也会执行 JSON 序列化;
74
+ - 其他类型会调用 `toString()`
75
+
76
+ ##### dataType?
77
+
78
+ > `optional` **dataType**: `"string"` \| `"json"`
79
+
80
+ 期望返回的数据格式。
81
+ - `json`: 尝试按 JSON 解析;
82
+ - `string`: 按字符串返回。
83
+
84
+ ###### Default
85
+
86
+ ```ts
87
+ "json"
88
+ ```
89
+
90
+ ##### header?
91
+
92
+ > `optional` **header**: `Record`\<`string`, `string`\>
93
+
94
+ 请求 Header。
95
+
96
+ ###### Default
97
+
98
+ ```ts
99
+ {"content-type": "application/json"}
100
+ ```
101
+
102
+ ##### method?
103
+
104
+ > `optional` **method**: [`RequestMethod`](#requestmethod)
105
+
106
+ 请求方法。
107
+
108
+ ###### Default
109
+
110
+ ```ts
111
+ "GET"
112
+ ```
113
+
114
+ ##### url
115
+
116
+ > **url**: `string`
117
+
118
+ 请求地址,需为完整的 **HTTPS** URL。
119
+
120
+ <a id="requestresponse"></a>
121
+ ### RequestResponse
122
+
123
+ 网络请求返回结果。
124
+
125
+ #### Properties
126
+
127
+ ##### data?
128
+
129
+ > `optional` **data**: `string` \| `Record`\<`string`, `any`\> \| `ArrayBuffer`
130
+
131
+ 响应数据,类型由 `dataType` 决定。
132
+
133
+ ##### header
134
+
135
+ > **header**: `Record`\<`string`, `string`\>
136
+
137
+ HTTP 响应头。
138
+
139
+ ##### statusCode
140
+
141
+ > **statusCode**: `number`
142
+
143
+ HTTP 状态码。
144
+
145
+ <a id="requestmethod"></a>
146
+ ### RequestMethod
147
+
148
+ > **RequestMethod**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"HEAD"` \| `"OPTIONS"` \| `"TRACE"` \| `"CONNECT"`