@doubao-apps/ai 0.0.28 → 0.0.29

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 (28) hide show
  1. package/dist/contexts/doubao-apps-dev/references/examples/common-patterns.md +4 -15
  2. package/dist/contexts/doubao-apps-dev/references/examples/component-basics.md +34 -17
  3. package/dist/contexts/doubao-apps-dev/references/guides/component-development.md +103 -69
  4. package/dist/contexts/doubao-apps-dev/references/guides/performance-optimization.md +0 -2
  5. package/dist/contexts/doubao-apps-dev/references/guides/troubleshooting.md +0 -4
  6. package/dist/contexts/doubao-apps-dev/references/reference/framework-api-quick-ref.md +52 -39
  7. package/dist/contexts/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +12 -2
  8. package/dist/contexts/doubao-apps-dev/references/reference/open-api/10-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +34 -0
  9. package/dist/contexts/doubao-apps-dev/references/reference/open-api/README.md +1 -1
  10. package/dist/contexts/doubao-apps-dev/references/reference/open-api.md +2 -1
  11. package/dist/contexts/doubao-apps-dev/references/rules/dos-and-donts.md +113 -36
  12. package/dist/manifest.json +2 -2
  13. package/dist/skills/doubao-apps-dev/SKILL.md +57 -13
  14. package/dist/skills/doubao-apps-dev/references/examples/common-patterns.md +4 -15
  15. package/dist/skills/doubao-apps-dev/references/examples/component-basics.md +34 -17
  16. package/dist/skills/doubao-apps-dev/references/guides/component-development.md +103 -69
  17. package/dist/skills/doubao-apps-dev/references/guides/performance-optimization.md +0 -2
  18. package/dist/skills/doubao-apps-dev/references/guides/troubleshooting.md +0 -4
  19. package/dist/skills/doubao-apps-dev/references/reference/framework-api-quick-ref.md +52 -39
  20. package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200-/350/264/246/345/217/267-/347/263/273/347/273/237.md +12 -2
  21. package/dist/skills/doubao-apps-dev/references/reference/open-api/10-/350/256/276/345/244/207-/350/256/276/345/244/207/346/226/271/345/220/221.md +34 -0
  22. package/dist/skills/doubao-apps-dev/references/reference/open-api/README.md +1 -1
  23. package/dist/skills/doubao-apps-dev/references/reference/open-api.md +2 -1
  24. package/dist/skills/doubao-apps-dev/references/rules/dos-and-donts.md +113 -36
  25. package/dist/skills/douyin-to-doubao/references/mapping/lifecycle-mapping.md +2 -2
  26. package/dist/skills/quality-gate/screenshots/doubao-faq.md +1 -1
  27. package/dist/skills/uniapp-to-doubao/references/mapping/lifecycle-mapping.md +15 -9
  28. package/package.json +1 -1
@@ -22,29 +22,105 @@ npm install @doubao-apps/framework
22
22
 
23
23
  ### 组件开发
24
24
 
25
- #### ✅ 定义完整的 aiMeta
26
- ```tsx
25
+ #### ✅ app.config.ts 配置 App 元信息
26
+ ```ts
27
+ import { defineAppConfig } from '@doubao-apps/kit';
28
+
29
+ export default defineAppConfig({
30
+ appId: 'com.example.my-doubao-app',
31
+ name: '我的豆包应用'
32
+ });
33
+ ```
34
+
35
+ #### ✅ 需要稳定首页时在 app.config.ts 明确入口
36
+ ```ts
37
+ // ✅ pages 数组第一项会作为首页(appletEntry)
38
+ import { defineAppConfig } from '@doubao-apps/kit';
39
+
40
+ export default defineAppConfig({
41
+ appId: 'com.example.my-doubao-app',
42
+ name: '我的豆包应用',
43
+ pages: [
44
+ {
45
+ entry: 'pages/home/index',
46
+ id: 'home',
47
+ title: '首页',
48
+ description: '应用默认打开的页面'
49
+ }
50
+ ]
51
+ });
52
+ ```
53
+
54
+ 一级页面目录不写进 `pages` 也会自动发现;如果首页不是历史默认的 `index`,或需要固定首页顺序,建议显式配置 `pages`
55
+ 数组第一项。
56
+
57
+ #### ✅ 需要补充展示信息时在 app.config.ts 定义 metadata
58
+ ```ts
27
59
  // ✅ 好的做法
28
- export default definePage({
29
- aiMeta: {
30
- id: 'user-profile',
31
- title: '用户资料',
32
- description: '展示和编辑用户个人资料'
33
- },
34
- // ...
60
+ import { defineAppConfig } from '@doubao-apps/kit';
61
+
62
+ export default defineAppConfig({
63
+ appId: 'com.example.my-doubao-app',
64
+ name: '我的豆包应用',
65
+ pages: [
66
+ {
67
+ entry: 'pages/user-profile/index',
68
+ id: 'user-profile',
69
+ title: '用户资料',
70
+ description: '展示和编辑用户个人资料'
71
+ }
72
+ ]
35
73
  });
36
74
  ```
37
75
 
38
- ```tsx
39
- // ❌ 不好的做法
40
- export default definePage({
41
- aiMeta: {
42
- id: 'page1' // 缺少 title、description 等信息
43
- },
44
- // ...
76
+ ```ts
77
+ // ❌ 不好的做法:缺少 title、description 等信息
78
+ import { defineAppConfig } from '@doubao-apps/kit';
79
+
80
+ export default defineAppConfig({
81
+ appId: 'com.example.my-doubao-app',
82
+ name: '我的豆包应用',
83
+ pages: [
84
+ {
85
+ entry: 'pages/user-profile/index',
86
+ id: 'page1'
87
+ }
88
+ ]
89
+ });
90
+ ```
91
+
92
+ #### ✅ 多级目录必须显式声明 entry
93
+ ```ts
94
+ // src/pages/account/demo/index.tsx
95
+ // src/widgets/order/detail/index.tsx
96
+ import { defineAppConfig } from '@doubao-apps/kit';
97
+
98
+ export default defineAppConfig({
99
+ appId: 'com.example.my-doubao-app',
100
+ name: '我的豆包应用',
101
+ pages: [
102
+ // 只声明入口、不补 metadata 时,可以直接写字符串
103
+ 'pages/account/demo/index',
104
+ {
105
+ entry: 'pages/account/settings/index',
106
+ id: 'account-settings',
107
+ title: '账号设置页'
108
+ }
109
+ ],
110
+ widgets: [
111
+ 'widgets/order/detail/index',
112
+ {
113
+ entry: 'widgets/order/summary/index',
114
+ id: 'order-summary',
115
+ name: '订单摘要卡片'
116
+ }
117
+ ]
45
118
  });
46
119
  ```
47
120
 
121
+ 如果不配置 `id`,默认取入口最后一级目录名:`pages/account/demo/index` 默认为 `demo`,`widgets/order/detail/index`
122
+ 默认为 `detail`。
123
+
48
124
  #### ✅ 分离样式文件
49
125
  ```tsx
50
126
  // ✅ 好的做法
@@ -88,8 +164,8 @@ interface UserInfo {
88
164
 
89
165
  export default defineWidget({
90
166
  render() {
91
- const input = getViewData<UserInfo>();
92
- return <view>{input.name}</view>;
167
+ const viewData = getViewData<UserInfo>();
168
+ return <view>{viewData.name}</view>;
93
169
  }
94
170
  });
95
171
  ```
@@ -99,13 +175,16 @@ export default defineWidget({
99
175
  import { defineAppConfig } from '@doubao-apps/kit';
100
176
 
101
177
  export default defineAppConfig({
102
- widgets: {
103
- 'widgets/user-card': {
178
+ appId: 'com.example.my-doubao-app',
179
+ name: '我的豆包应用',
180
+ widgets: [
181
+ {
182
+ entry: 'widgets/user-card/index',
104
183
  id: 'user-card',
105
184
  name: '用户卡片',
106
185
  description: '用户信息卡片'
107
186
  }
108
- }
187
+ ]
109
188
  });
110
189
  ```
111
190
 
@@ -113,8 +192,8 @@ export default defineAppConfig({
113
192
  // ❌ 不好的做法
114
193
  export default defineWidget({
115
194
  render() {
116
- const input = getViewData<any>(); // 使用 any 类型,失去类型检查
117
- return <view>{input.name}</view>;
195
+ const viewData = getViewData<any>(); // 使用 any 类型,失去类型检查
196
+ return <view>{viewData.name}</view>;
118
197
  }
119
198
  });
120
199
  ```
@@ -123,8 +202,6 @@ export default defineWidget({
123
202
  ```tsx
124
203
  // ✅ 好的做法
125
204
  export default definePage({
126
- aiMeta: { /* ... */ },
127
-
128
205
  onShow() {
129
206
  console.log('Page shown');
130
207
  },
@@ -149,15 +226,15 @@ export default definePage({
149
226
  // ✅ 好的做法
150
227
  export default defineWidget({
151
228
  render() {
152
- const input = getViewData<{ items: string[] }>();
229
+ const viewData = getViewData<{ items: string[] }>();
153
230
  // 处理空数据
154
- if (!input.items || input.items.length === 0) {
231
+ if (!viewData.items || viewData.items.length === 0) {
155
232
  return <view>暂无数据</view>;
156
233
  }
157
234
 
158
235
  return (
159
236
  <view>
160
- {input.items.map((item, index) => (
237
+ {viewData.items.map((item, index) => (
161
238
  <view key={index}>{item}</view>
162
239
  ))}
163
240
  </view>
@@ -170,11 +247,11 @@ export default defineWidget({
170
247
  // ❌ 不好的做法
171
248
  export default defineWidget({
172
249
  render() {
173
- const input = getViewData<any>();
174
- // 没有检查 input.items 是否存在
250
+ const viewData = getViewData<any>();
251
+ // 没有检查 viewData.items 是否存在
175
252
  return (
176
253
  <view>
177
- {input.items.map(item => <view>{item}</view>)}
254
+ {viewData.items.map(item => <view>{item}</view>)}
178
255
  </view>
179
256
  );
180
257
  }
@@ -321,24 +398,24 @@ export default definePage({
321
398
  // ❌ 错误
322
399
  export default defineWidget({
323
400
  render() {
324
- const input = getViewData<any>();
401
+ const viewData = getViewData<any>();
325
402
  // @ts-ignore
326
- return <view>{input.unknownProperty}</view>;
403
+ return <view>{viewData.unknownProperty}</view>;
327
404
  }
328
405
  });
329
406
  ```
330
407
 
331
408
  ```tsx
332
409
  // ✅ 正确
333
- interface Input {
410
+ interface UserInfo {
334
411
  name: string;
335
412
  age: number;
336
413
  }
337
414
 
338
415
  export default defineWidget({
339
416
  render() {
340
- const input = getViewData<Input>();
341
- return <view>{input.name}</view>;
417
+ const viewData = getViewData<UserInfo>();
418
+ return <view>{viewData.name}</view>;
342
419
  }
343
420
  });
344
421
  ```
@@ -68,8 +68,8 @@ import { FC, definePage, getViewData, useEffect, useState } from '@doubao-apps/f
68
68
  import { request } from '@doubao-apps/framework/api';
69
69
 
70
70
  const DetailPage: FC = () => {
71
- const input = getViewData() as { id?: string } | undefined;
72
- const id = input?.id ?? '';
71
+ const viewData = getViewData() as { id?: string } | undefined;
72
+ const id = viewData?.id ?? '';
73
73
  const [detail, setDetail] = useState<any>(null);
74
74
 
75
75
  useEffect(() => {
@@ -67,7 +67,7 @@ adb -s "$DEVICE" shell am broadcast -a com.bytedance.applet.SET_APPLET_DEBUG_HOS
67
67
  典型例子:
68
68
 
69
69
  ```ts
70
- const { product, qty: initialQty = 1 } = getViewData<CheckoutInput>();
70
+ const { product, qty: initialQty = 1 } = getViewData<CheckoutViewData>();
71
71
  ```
72
72
 
73
73
  如果对这类页面统一传 `'{}'`,很容易在测试阶段白屏,或者只渲染出宿主错误层。
@@ -70,14 +70,14 @@ export default {
70
70
  import { definePage, getViewData, useEffect } from '@doubao-apps/framework';
71
71
 
72
72
  function DetailPage() {
73
- const input = getViewData() as { id?: string } | undefined;
73
+ const viewData = getViewData() as { id?: string } | undefined;
74
74
 
75
75
  useEffect(() => {
76
- if (!input?.id) {
76
+ if (!viewData?.id) {
77
77
  return;
78
78
  }
79
- // fetchDetail(input.id)
80
- }, [input?.id]);
79
+ // fetchDetail(viewData.id)
80
+ }, [viewData?.id]);
81
81
 
82
82
  return <view />;
83
83
  }
@@ -122,14 +122,20 @@ uni-app 组件本质上是 Vue2 组件生命周期:
122
122
  ### 示例
123
123
 
124
124
  ```ts
125
- // After (Doubao Apps)
125
+ // src/app.config.ts
126
+ import { defineAppConfig } from '@doubao-apps/kit';
127
+
128
+ export default defineAppConfig({
129
+ appId: 'uniapp-migrated-app',
130
+ name: 'uniapp-migrated-app'
131
+ });
132
+ ```
133
+
134
+ ```ts
135
+ // src/app.ts
126
136
  import { defineApp } from '@doubao-apps/framework';
127
137
 
128
138
  export default defineApp({
129
- aiMeta: {
130
- id: 'app',
131
- name: 'uniapp-migrated-app'
132
- },
133
139
  onLaunch() {
134
140
  console.log('app launched');
135
141
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-apps/ai",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Doubao Apps SDK AI tools with context and skills management",
5
5
  "type": "module",
6
6
  "bin": {