@quicktvui/ai 1.0.3 → 1.0.5

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 (62) hide show
  1. package/README.md +99 -19
  2. package/USAGE.md +74 -0
  3. package/package.json +1 -1
  4. package/postinstall.js +10 -2
  5. package/rules/.clinerules +7 -3
  6. package/rules/.cursorrules +9 -4
  7. package/rules/.docs/examples/css/pseudo-classes/v-pseudo.vue +57 -0
  8. package/rules/.docs/examples/guide/slot/lifecycle-hooks.vue +108 -0
  9. package/rules/.docs/examples/module/key/component-event.vue +36 -0
  10. package/rules/.docs/examples/module/key/es-back-hooks.vue +30 -0
  11. package/rules/.docs/examples/module/key/es-dispatch-hooks.vue +36 -0
  12. package/rules/.docs/examples/module/key/es-event-hooks.vue +31 -0
  13. package/rules/.docs/examples/module/page/es-app-lifecycle-hooks.vue +85 -0
  14. package/rules/.docs/examples/module/page/es-page-lifecycle-hooks.vue +78 -0
  15. package/rules/.docs/examples/module/page/es-page-state-hooks.vue +35 -0
  16. package/rules/.docs/zh-CN/component/button.md +3 -3
  17. package/rules/.docs/zh-CN/component/column.md +3 -0
  18. package/rules/.docs/zh-CN/component/html/installation.md +8 -2
  19. package/rules/.docs/zh-CN/component/html/video.md +1 -0
  20. package/rules/.docs/zh-CN/component/media-series.md +3 -3
  21. package/rules/.docs/zh-CN/component/overview.md +1 -3
  22. package/rules/.docs/zh-CN/component/poster.md +1 -1
  23. package/rules/.docs/zh-CN/component/row.md +2 -0
  24. package/rules/.docs/zh-CN/component/text.md +1 -1
  25. package/rules/.docs/zh-CN/component/waterfall_structure.md +266 -0
  26. package/rules/.docs/zh-CN/css/animation-transition/overview.md +23 -0
  27. package/rules/.docs/zh-CN/css/auto/overview.md +18 -0
  28. package/rules/.docs/zh-CN/css/cheat-sheet.md +19 -0
  29. package/rules/.docs/zh-CN/css/color/overview.md +20 -0
  30. package/rules/.docs/zh-CN/css/function/overview.md +27 -0
  31. package/rules/.docs/zh-CN/css/installation.md +53 -0
  32. package/rules/.docs/zh-CN/css/introduction.md +33 -0
  33. package/rules/.docs/zh-CN/css/layout/background.md +21 -0
  34. package/rules/.docs/zh-CN/css/layout/display.md +1 -2
  35. package/rules/.docs/zh-CN/css/layout-model/overview.md +21 -0
  36. package/rules/.docs/zh-CN/css/media/overview.md +27 -0
  37. package/rules/.docs/zh-CN/css/pseudo-classes/overview.md +79 -0
  38. package/rules/.docs/zh-CN/css/selector/overview.md +90 -0
  39. package/rules/.docs/zh-CN/css/size/overview.md +28 -0
  40. package/rules/.docs/zh-CN/css/specificity-inheritance/overview.md +21 -0
  41. package/rules/.docs/zh-CN/css/style/font-family.md +13 -4
  42. package/rules/.docs/zh-CN/css/transform/overview.md +23 -0
  43. package/rules/.docs/zh-CN/css/variable/overview.md +21 -0
  44. package/rules/.docs/zh-CN/guide/ai/ai-assistant.md +74 -0
  45. package/rules/.docs/zh-CN/guide/faq/layout-style-faq.md +3 -3
  46. package/rules/.docs/zh-CN/guide/key/back.md +31 -0
  47. package/rules/.docs/zh-CN/guide/key/dispatch-key-event.md +34 -1
  48. package/rules/.docs/zh-CN/guide/key/key-event.md +54 -6
  49. package/rules/.docs/zh-CN/guide/layout/adapter.md +0 -2
  50. package/rules/.docs/zh-CN/guide/layout/layout.md +2 -9
  51. package/rules/.docs/zh-CN/guide/layout/style.md +6 -33
  52. package/rules/.docs/zh-CN/guide/layout/theming.md +24 -139
  53. package/rules/.docs/zh-CN/guide/page/application-lifecycle.md +28 -4
  54. package/rules/.docs/zh-CN/guide/page/page-lifecycle.md +37 -9
  55. package/rules/.docs/zh-CN/guide/page/page-state.md +24 -1
  56. package/rules/.docs/zh-CN/guide/slot/lifecycle.md +27 -1
  57. package/rules/.github/copilot-instructions.md +6 -2
  58. package/rules/.windsurfrules +7 -3
  59. package/rules/AGENTS.md +7 -3
  60. package/rules/AI_HANDOFF.md +6 -6
  61. package/rules/CLAUDE.md +8 -4
  62. package/rules/GEMINI.md +9 -5
package/README.md CHANGED
@@ -1,25 +1,25 @@
1
1
  # @quicktvui/ai
2
2
 
3
- QuickTVUI 官方提供的 AI 辅助开发规范包。
4
- 安装后,会自动将 QuickTVUI 的严格开发规范、架构避坑指南(不支持 HTML、组件用法等)、以及本地文档库注入到你的项目中。
3
+ > **让 AI 助你丝滑开发 QuickTVUI,彻底告别“Web 习惯”导致的运行报错。**
5
4
 
6
- ## 它可以做什么?
5
+ `@quicktvui/ai` 是 QuickTVUI 官方提供的 AI 辅助开发规范包。它通过向你的项目中注入经过深度调优的 AI 指令(Rules)和本地知识库,让 Cursor、Windsurf、Copilot、Cline 等 AI 助手瞬间化身为“QuickTVUI 资深专家”。
7
6
 
8
- 安装本包后,它会自动在你的项目根目录下生成并配置:
9
- - `.cursorrules` (供 Cursor 使用)
10
- - `.windsurfrules` (供 Windsurf 使用)
11
- - `.clinerules` (供 Cline/Roo-Code 使用)
12
- - `.github/copilot-instructions.md` (供 GitHub Copilot 使用)
13
- - `GEMINI.md` / `CLAUDE.md` / `AGENTS.md` (供其他模型使用)
14
- - `.docs/` (本地轻量级 QuickTVUI 知识库)
7
+ ---
15
8
 
16
- 这些规则会强制 AI:
17
- 1. **停止捏造标签**(如禁止使用 `qt-web-view`,强制使用 `qt-web`)。
18
- 2. **遵守非浏览器环境**(禁止使用 `window`, `document` 和任何标准 HTML 标签,如 `p`, `div` 以外的标签)。
19
- 3. **正确的播放器架构**(强制使用 `es-player-manager`)。
20
- 4. **严格的 CSS 子集**(禁止简写,禁止 auto 等)。
9
+ ## 🚀 为什么需要它?
21
10
 
22
- ## 安装方式
11
+ QuickTVUI 运行在 TV 端原生环境(Hippy-based),虽然使用 Vue 语法,但它**不是浏览器**。开发者在使用 AI 辅助编程时,AI 极其容易带入传统的 Web 开发习惯,导致生成无法运行的代码:
12
+
13
+ - ❌ **误用 HTML 标签**:生成了 `<p>`, `<img>`, `<a>` 等标签(QuickTVUI 必须使用 `qt-text`, `qt-image`)。
14
+ - ❌ **误用 DOM API**:使用了 `window`, `document`, `alert()`(原生环境不存在这些对象)。
15
+ - ❌ **无效的 CSS**:使用了简写(`margin: 10px`)或 `auto` 尺寸(QuickTVUI 严格要求拆写且必须是 `px`)。
16
+ - ❌ **错误的播放器架构**:直接使用 `<video>` 标签(必须使用 `es-player-manager`)。
17
+
18
+ **安装 `@quicktvui/ai` 后,这些问题将不复存在。AI 将严格遵守框架规范,生成 100% 可运行的 TV 端代码。**
19
+
20
+ ---
21
+
22
+ ## 📦 安装方式
23
23
 
24
24
  在你的 QuickTVUI 项目根目录下运行:
25
25
 
@@ -29,8 +29,88 @@ npm install @quicktvui/ai --save-dev
29
29
  yarn add @quicktvui/ai --dev
30
30
  ```
31
31
 
32
- > 安装完成后,脚本会自动将相关规范和文档拷贝到你的项目根目录。如果你的项目使用 Git,它还会自动执行 `git add`。
32
+ 安装完成后,脚本会自动执行以下操作:
33
+ 1. **注入配置文件**:在根目录生成 `.cursorrules`, `.clinerules`, `GEMINI.md`, `CLAUDE.md` 等。
34
+ 2. **配置 Copilot**:在 `.github/` 下注入 Copilot 专用指令。
35
+ 3. **关联知识库**:让 AI 能够检索 `node_modules` 中内置的组件详细文档。
36
+ 4. **自动忽略**:自动更新 `.gitignore`,确保这些辅助配置文件不会污染你的 Git 提交。
37
+
38
+ ---
39
+
40
+ ## 🤖 支持的 AI 工具与配置
41
+
42
+ 本包一次性适配了市面上主流的 AI 编程助手,安装后会自动在项目根目录生成对应的配置文件:
43
+
44
+ | AI 工具 | 核心配置文件 | 配置方式 |
45
+ | :--- | :--- | :--- |
46
+ | **Cursor** | `.cursorrules` | 自动加载,无需额外设置 |
47
+ | **Windsurf** | `.windsurfrules` | 自动加载,级联项目上下文 |
48
+ | **Cline (Roo-Code)** | `.clinerules` | 自动加载,作为 Agent 的全局指令 |
49
+ | **GitHub Copilot** | `.github/copilot-instructions.md` | 自动生效 (需较新版本的 Copilot 插件) |
50
+ | **Gemini CLI** | `GEMINI.md` | 自动被 Gemini 及其相关工具链引用 |
51
+ | **Claude Code** | `CLAUDE.md` / `.claude/` | 深度适配,提供 `/create-page` 等快捷指令 |
52
+
53
+ ---
54
+
55
+ ## 🌟 强力推荐:最佳模型选择
56
+
57
+ 为了获得最精准的 QuickTVUI 代码生成效果,我们**强烈建议**开发者配合以下最新一代 AI 模型使用:
58
+
59
+ 1. **Claude 3.5 Sonnet (推荐)**:目前对 QuickTVUI 复杂焦点逻辑和样式约束理解最深刻的模型,逻辑严密,极少幻觉。
60
+ 2. **GitHub Copilot (基于 Codex/GPT-4o)**:响应速度快,适合日常组件编写和代码补全。
61
+ 3. **Gemini 1.5 Pro / Flash**:拥有超长上下文窗口,能够一次性理解项目中的多个页面关系,适合进行大型功能重构。
62
+
63
+ > **提示**:在使用这些 AI 时,请确保已启用“读取项目文件”或“代码库索引”功能,以便 AI 能够自动发现并遵循本项目注入的 `.docs` 文档。
64
+
65
+ ---
66
+
67
+ ## ✨ 它强制 AI 遵守的核心规范
68
+
69
+ 安装后,AI 将掌握以下“生存法则”:
70
+
71
+ ### 1. 零 HTML 与 零 DOM
72
+ - 绝对禁止使用 `p`, `img`, `ul`, `li`, `h1`, `button` 等标签。
73
+ - 绝对禁止使用 `window`, `document`, `e.preventDefault()`。
74
+ - 必须使用 `qt-text`, `qt-image`, `qt-view` 等原生对应组件。
75
+
76
+ ### 2. 严格的 CSS 子集
77
+ - 必须使用 `px` 单位,严禁使用 `%`, `auto`, `rem`, `vh` 等。
78
+ - 严禁 CSS 属性简写(如 `margin` 必须拆分为 `margin-top` 等)。
79
+ - 必须显式声明 `display: flex` 且默认方向为 `column`。
80
+
81
+ ### 3. TV 特有的焦点系统
82
+ - 自动为交互元素添加 `:focusable="true"`。
83
+ - 自动处理 `focusScale` 带来的 `clipChildren="false"` 适配问题。
84
+
85
+ ### 4. 正确的命名协议
86
+ - 返回键处理函数必须叫 `onBackPressed`。
87
+ - 生命周期必须叫 `onESCreate`, `onESResume` 等。
88
+
89
+ ### 5. AI 哨兵:自动化问题上报
90
+ 当 AI 发现代码符合规范但仍运行报错,或者同一问题修复 3 次未果时,它会启动**问题上报机制**:
91
+ - **脱敏诊断**:自动整理报错日志、环境信息并编写最小可复现 Demo。
92
+ - **一键上报**:在获得你授权后,AI 会自动尝试打开浏览器或生成 GitHub Issue 链接,助你快速反馈给官方。
93
+
94
+ ---
95
+
96
+ ## 🔍 验证注入是否成功
97
+
98
+ 安装完成后,检查项目根目录,如果出现以下文件,说明注入成功:
99
+ - `.cursorrules`
100
+ - `.clinerules`
101
+ - `.windsurfrules`
102
+ - `GEMINI.md`
103
+ - `CLAUDE.md`
104
+ - `.quicktvui-ai-backup/` (如有旧配置,会自动备份在此)
105
+
106
+ ---
107
+
108
+ ## 🛠️ 进阶使用:本地知识库
109
+
110
+ 本包在 `node_modules/@quicktvui/ai/rules/.docs/` 下内置了约 400 篇 QuickTVUI 核心组件及 API 文档。你的 AI 助手现在具备了“离线查阅文档”的能力,生成代码前它会先检索本地文档,确保参数和用法 100% 准确。
111
+
112
+ ---
33
113
 
34
- ## 验证
114
+ ## 📄 开源协议
35
115
 
36
- 安装完毕后,请检查你的项目根目录是否多出了 `.cursorrules` 等文件以及 `.docs` 目录。如果有,说明注入成功,尽情享受不踩坑的 AI 编程体验吧!
116
+ MIT License.
package/USAGE.md ADDED
@@ -0,0 +1,74 @@
1
+ # @quicktvui/ai 开发者使用指南
2
+
3
+ 本指南将帮助你利用 AI 助手高效地开发 QuickTVUI 应用。
4
+
5
+ ## 1. 快速上手
6
+
7
+ ### 第一步:安装规范包
8
+
9
+ 在你的 QuickTVUI 项目(建议使用 `quicktvui-template` 创建)中安装:
10
+
11
+ ```bash
12
+ npm install @quicktvui/ai --save-dev
13
+ ```
14
+
15
+ ### 第二步:配置并开启推荐模型
16
+
17
+ 为了达到最佳辅助效果,请在你的 AI 工具中优先选择以下模型:
18
+
19
+ - **Claude **
20
+ - **Codex**
21
+ - **Gemini**
22
+
23
+ AI 助手将自动读取项目根目录下的 `.cursorrules`, `GEMINI.md`, `CLAUDE.md` 等文件中的指令。
24
+
25
+ ## 2. 常见场景 AI 辅助示例
26
+
27
+ ### 场景 A:创建新页面
28
+
29
+ **输入:** `/create-page 首页`
30
+ **AI 将生成:** 包含 `onESCreate`, `onBackPressed`, `:autofocus="true"` 以及正确 CSS(kebab-case + px 单位)的代码。
31
+
32
+ ### 场景 B:API 查询
33
+
34
+ **输入:** “qt-image 支持哪些属性?”
35
+ **AI 将检索:** 它会查阅 `node_modules/@quicktvui/ai/rules/.docs/component/image.md` 并返回:`src`, `enableFade`,
36
+ `resizeMode` 等原生支持的属性。
37
+
38
+ ### 场景 C:样式纠错
39
+
40
+ **输入:** “这段样式哪里不对? `.box { margin: 10px; width: 100%; }`”
41
+ **AI 将纠错:** “在 QuickTVUI 中不能使用 `margin` 简写,必须拆写为 `margin-top` 等;且不能使用 `100%`,必须使用具体的 `px`
42
+ 值。”
43
+
44
+ ## 3. 开发检查清单 (Checklist)
45
+
46
+ 当 AI 为你生成代码后,请务必核对以下关键点:
47
+
48
+ - [ ] **标签检查**:是否误用了 `p`, `img`, `h1`?(必须是 `qt-text`, `qt-image`)
49
+ - [ ] **生命周期**:入口函数是否叫 `onESCreate(params)`?
50
+ - [ ] **返回键**:处理函数是否叫 `onBackPressed()` 且已 `return`?
51
+ - [ ] **焦点系统**:页面是否至少有一个元素设置了 `:autofocus="true"`?
52
+ - [ ] **样式单位**:是否所有数值都带 `px`?是否误用了 `auto` 或 `%`?
53
+ - [ ] **属性命名**:`<template>` 标签属性用 `camelCase`,`<style>` 样式名用 `kebab-case`。
54
+
55
+ ## 4. 如何使用 AI 反馈框架问题 (Bug Reporting)
56
+
57
+ 如果你在开发中发现框架可能存在 Bug(例如 AI 生成的代码符合规范但仍运行报错),你可以直接通过 AI 进行上报:
58
+
59
+ 1. **触发上报**:你可以直接对 AI 说:“我想上报一个 Bug”、“这段代码运行报错,帮我反馈给官方”。
60
+ 2. **AI 自动诊断**:
61
+ - AI 会自动检测你的运行环境和报错日志。
62
+ - 它会尝试编写一个**脱敏后的最小可复现 Demo**。
63
+ 3. **寻求授权**:AI 会询问你:“检测到该问题可能属于框架缺陷,是否允许我协助将其上报到 GitHub 官方仓库?”
64
+ 4. **快速提交**:获得授权后,AI 会自动尝试在你的电脑上**打开浏览器并预填充 GitHub Issue 内容**,你只需核对后点击提交即可。
65
+
66
+ ---
67
+
68
+ ## 5. 故障排除
69
+
70
+ 如果 AI 生成了错误的代码(例如使用了 Web 标签):
71
+
72
+ 1. **重新引用规则**:告诉它:“请参考项目根目录下的 `.cursorrules` (或 `GEMINI.md`) 重新检查规范。”
73
+ 2. **强制读取文档**:告诉它:“请读取 `node_modules/@quicktvui/ai/rules/.docs/` 下的相关组件文档后再回答。”
74
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/ai",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "QuickTVUI AI 开发规范与脚手架注入工具",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -41,7 +41,7 @@ function copyDirectorySync(src, dest) {
41
41
  }
42
42
 
43
43
  try {
44
- const rootItems = fs.readdirSync(rulesDir);
44
+ const rootItems = fs.readdirSync(rulesDir).filter((item) => item !== ".docs");
45
45
  let backupNeeded = false;
46
46
 
47
47
  // 1. 检查并备份现有配置
@@ -69,7 +69,15 @@ try {
69
69
  }
70
70
 
71
71
  // 2. 注入新规则
72
- copyDirectorySync(rulesDir, projectRoot);
72
+ rootItems.forEach((item) => {
73
+ const srcPath = path.join(rulesDir, item);
74
+ const destPath = path.join(projectRoot, item);
75
+ if (fs.lstatSync(srcPath).isDirectory()) {
76
+ copyDirectorySync(srcPath, destPath);
77
+ } else {
78
+ fs.copyFileSync(srcPath, destPath);
79
+ }
80
+ });
73
81
  console.log("🎉 [@quicktvui/ai] AI 规范注入成功!");
74
82
 
75
83
  // 3. 更新 .gitignore
package/rules/.clinerules CHANGED
@@ -6,14 +6,14 @@
6
6
 
7
7
  **AI MUST refer to the official documentation and source code below BEFORE generating any code. NEVER hallucinate component names, attribute names, or APIs. These are the ONLY authorities.**
8
8
 
9
- 1. **Local Documentation (PRIMARY)**: The `.docs/` folder in the project root. Contains detailed MD documentation for all components, CSS, and native modules. **AI MUST use `grep_search` or `read_file` to retrieve relevant content from the `.docs/` directory before generating code.**
9
+ 1. **Local Documentation (PRIMARY)**: The `node_modules/@quicktvui/ai/rules/.docs/` folder. Contains detailed MD documentation for all components, CSS, and native modules. **AI MUST use `grep_search` or `read_file` to retrieve relevant content from the `node_modules/@quicktvui/ai/rules/.docs/` directory before generating code.**
10
10
  2. **Official Docs**: https://quicktvui.com
11
11
  3. **Core Library Samples**: https://github.com/quicktvui/quicktvui.git
12
12
  4. **Cross-platform Framework Samples**: https://github.com/quicktvui/es-vue3.git
13
13
  5. **Best Practice App**: https://github.com/quicktvui/hellotv.git
14
14
 
15
15
  **STRICT RULES:**
16
- - **VERIFY CAPABILITIES FIRST**: Before implementing features like "video playback," search the `.docs/` directory to verify component capabilities. DO NOT assume web behavior. **For example, `qt-web-view` does NOT support video playback; you MUST use the native `es-video-player` and `es-player-manager` components.**
16
+ - **VERIFY CAPABILITIES FIRST**: Before implementing features like "video playback," search the `node_modules/@quicktvui/ai/rules/.docs/` directory to verify component capabilities. DO NOT assume web behavior. **For example, `qt-web-view` does NOT support video playback; you MUST use the native `es-video-player` and `es-player-manager` components.**
17
17
  - **NOT A BROWSER & NO HTML**: **This framework does NOT support HTML. Standard HTML tags (like `p`, `img`, `a`, `ul`, `li`, `h1`) are STRICTLY PROHIBITED. It does NOT support `window`, `document` (DOM), or DOM APIs. You must exclusively use framework tags (like `qt-text`, `qt-image`) and Vue `ref`s.**
18
18
  - **NO HALLUCINATED TAGS**: e.g. `qt-web` is wrong, it is `qt-web-view`.
19
19
  - **NO HALLUCINATED APIs**: e.g. `onBack` is wrong, it must be `onBackPressed`.
@@ -38,6 +38,10 @@ AI assistants frequently fail by applying traditional Web paradigms to QuickTVUI
38
38
  2. **List Components (`qt-list-view`, `qt-grid-view`, `qt-waterfall`)**:
39
39
  * You MUST set `listenBoundEvent="true"` and listen to `@item-bind`.
40
40
  * The "Loading More" template `type` **MUST** be `1002`. The "End of List" template `type` **MUST** be `1003`.
41
+ * **Waterfall Critical Rules (qt-waterfall)**:
42
+ * Custom item root nodes **MUST** include `layout="${layout}"` and `flexStyle="${style}"` to avoid stacking/overlapping.
43
+ * Local image paths in waterfall data **MUST** use the `file://` protocol (e.g., `file://${icon}`).
44
+ * Refer to `node_modules/@quicktvui/ai/rules/.docs/zh-CN/component/waterfall_structure.md` for full layout logic.
41
45
  3. **Zero HTML & Zero DOM**:
42
46
  * **This is NOT a browser.** It compiles to Hippy Native Android Views.
43
47
  * **Banned Tags**: Standard HTML tags (`<p>`, `<img>`, `<ul>`, `<li>`, `<a>`, `<h1>`, `<button>`) will **CRASH** the app. Use only `div`, `span`, or `qt-*` tags.
@@ -147,7 +151,7 @@ Other CSS rules:
147
151
 
148
152
  当用户通过以下方式表达困惑时:
149
153
  - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
150
- - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
154
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `node_modules/@quicktvui/ai/rules/.docs/` 规范 but 无法在用户端运行。
151
155
 
152
156
  **AI 执行协议:**
153
157
  1. **脱敏诊断 (Sanitized Diagnosis)**:
@@ -6,14 +6,14 @@
6
6
 
7
7
  **AI MUST refer to the official documentation and source code below BEFORE generating any code. NEVER hallucinate component names, attribute names, or APIs. These are the ONLY authorities.**
8
8
 
9
- 1. **Local Documentation (PRIMARY)**: The `.docs/` folder in the project root. Contains detailed MD documentation for all components, CSS, and native modules. **AI MUST use `grep_search` or `read_file` to retrieve relevant content from the `.docs/` directory before generating code.**
9
+ 1. **Local Documentation (PRIMARY)**: The `node_modules/@quicktvui/ai/rules/.docs/` folder. Contains detailed MD documentation for all components, CSS, and native modules. **AI MUST use `grep_search` or `read_file` to retrieve relevant content from the `node_modules/@quicktvui/ai/rules/.docs/` directory before generating code.**
10
10
  2. **Official Docs**: https://quicktvui.com
11
11
  3. **Core Library Samples**: https://github.com/quicktvui/quicktvui.git
12
12
  4. **Cross-platform Framework Samples**: https://github.com/quicktvui/es-vue3.git
13
13
  5. **Best Practice App**: https://github.com/quicktvui/hellotv.git
14
14
 
15
15
  **STRICT RULES:**
16
- - **VERIFY CAPABILITIES FIRST**: Before implementing features like "video playback," search the `.docs/` directory to verify component capabilities. DO NOT assume web behavior. **For example, `qt-web-view` does NOT support video playback; you MUST use the native `es-video-player` and `es-player-manager` components.**
16
+ - **VERIFY CAPABILITIES FIRST**: Before implementing features like "video playback," search the `node_modules/@quicktvui/ai/rules/.docs/` directory to verify component capabilities. DO NOT assume web behavior. **For example, `qt-web-view` does NOT support video playback; you MUST use the native `es-video-player` and `es-player-manager` components.**
17
17
  - **NOT A BROWSER & NO HTML**: **This framework does NOT support HTML. Standard HTML tags (like `p`, `img`, `a`, `ul`, `li`, `h1`) are STRICTLY PROHIBITED. It does NOT support `window`, `document` (DOM), or DOM APIs. You must exclusively use framework tags (like `qt-text`, `qt-image`) and Vue `ref`s.**
18
18
  - **NO HALLUCINATED TAGS**: e.g. `qt-web` is wrong, it is `qt-web-view`.
19
19
  - **NO HALLUCINATED APIs**: e.g. `onBack` is wrong, it must be `onBackPressed`.
@@ -35,9 +35,14 @@ AI assistants frequently fail by applying traditional Web paradigms to QuickTVUI
35
35
  1. **Media Playback Architecture**:
36
36
  * **NEVER** use HTML5 `<video>`, `<audio>`, or `qt-web-view` for media.
37
37
  * **Best Practice**: You MUST prioritize using **`es-player-manager`** wrapping `es-video-player` or `es-audio-player`. The manager handles playlists, window sizing (full/small), and focus. Using the base player alone leads to missing logic.
38
- 2. **List Components (`qt-list-view`, `qt-grid-view`, `qt-waterfall`)**:
38
+ 2. **List Components (`qt-list-view`, `qt-grid-view`, `qt-waterfall`)**:
39
39
  * You MUST set `listenBoundEvent="true"` and listen to `@item-bind`.
40
40
  * The "Loading More" template `type` **MUST** be `1002`. The "End of List" template `type` **MUST** be `1003`.
41
+ * **Waterfall Critical Rules (qt-waterfall)**:
42
+ * Custom item root nodes **MUST** include `layout="${layout}"` and `flexStyle="${style}"` to avoid stacking/overlapping.
43
+ * Local image paths in waterfall data **MUST** use the `file://` protocol (e.g., `file://${icon}`).
44
+ * Refer to `node_modules/@quicktvui/ai/rules/.docs/zh-CN/component/waterfall_structure.md` for full layout logic.
45
+
41
46
  3. **Zero HTML & Zero DOM**:
42
47
  * **This is NOT a browser.** It compiles to Hippy Native Android Views.
43
48
  * **Banned Tags**: Standard HTML tags (`<p>`, `<img>`, `<ul>`, `<li>`, `<a>`, `<h1>`, `<button>`) will **CRASH** the app. Use only `div`, `span`, or `qt-*` tags.
@@ -147,7 +152,7 @@ Other CSS rules:
147
152
 
148
153
  当用户通过以下方式表达困惑时:
149
154
  - **关键词触发**:用户提到“问题上报”、“碰到问题”、“反馈”、“Bug 反馈”、“还是没改好”、“运行报错”、“API 报错”等。
150
- - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `.docs` 规范但无法在用户端运行。
155
+ - **自动检测触发**:同一段代码逻辑在 3 次修复后仍然报错,或 AI 确认生成的代码符合 `node_modules/@quicktvui/ai/rules/.docs/` 规范但无法在用户端运行。
151
156
 
152
157
  **AI 执行协议:**
153
158
  1. **脱敏诊断 (Sanitized Diagnosis)**:
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <div class="es-sdk-root-css" :clipChildren="false">
3
+ <div class="es-sdk-content-column-css" :clipChildren="false">
4
+ <qt-button text="改变值" @click="onButtonClicked" />
5
+ <div
6
+ v-pseudo:test="value"
7
+ class="div-v-pseudo-css"
8
+ :focusable="true"
9
+ :enableFocusBorder="true"
10
+ :focusScale="1"
11
+ @focus="onFocus"
12
+ />
13
+ </div>
14
+ </div>
15
+ </template>
16
+
17
+ <script lang="ts">
18
+ import { ref } from "vue";
19
+ import { defineComponent } from "@vue/runtime-core";
20
+
21
+ export default defineComponent({
22
+ emits: [],
23
+ setup() {
24
+ const value = ref<boolean>(false);
25
+
26
+ function onButtonClicked() {
27
+ value.value = !value.value;
28
+ }
29
+
30
+ const onFocus = (e) => {
31
+ const focused = e.isFocused;
32
+ };
33
+
34
+ return {
35
+ onFocus,
36
+ onButtonClicked,
37
+ value,
38
+ };
39
+ },
40
+ });
41
+ </script>
42
+
43
+ <style scoped>
44
+ .div-v-pseudo-css {
45
+ width: 192px;
46
+ height: 108px;
47
+ margin: 20px;
48
+ background: green;
49
+ }
50
+
51
+ .div-v-pseudo-css:test {
52
+ width: 384px;
53
+ height: 216px;
54
+ margin: 20px;
55
+ background: palevioletred;
56
+ }
57
+ </style>
@@ -0,0 +1,108 @@
1
+ <script>
2
+ import { defineComponent } from '@vue/runtime-core'
3
+ import { ESLogLevel, ESSlotEventName, useESLog } from '@extscreen/es3-core'
4
+ import {
5
+ onESAttached,
6
+ onESBind,
7
+ onESCreate,
8
+ onESDestroy,
9
+ onESDetached,
10
+ onESNewIntent,
11
+ onESPause,
12
+ onESRecycle,
13
+ onESRestart,
14
+ onESRestoreInstanceState,
15
+ onESResume,
16
+ onESSaveInstanceState,
17
+ onESSlotEvent,
18
+ onESStart,
19
+ onESStop,
20
+ } from '@extscreen/es3-vue'
21
+ import type { ESData, ESSlotEvent } from '@extscreen/es3-core'
22
+
23
+ const TAG = 'Lifecycle'
24
+
25
+ export default defineComponent({
26
+ name: 'JsView生命周期',
27
+ setup() {
28
+ const log = useESLog()
29
+
30
+ onESCreate((params) => {
31
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
32
+ log.d(TAG, '---onESCreate----->>>', params)
33
+ }
34
+ })
35
+
36
+ onESBind((data: ESData) => {
37
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
38
+ log.d(TAG, '---onESBind----->>>', data)
39
+ }
40
+ })
41
+
42
+ onESAttached((data: ESData) => {
43
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
44
+ log.d(TAG, '---onESAttached----->>>', data)
45
+ }
46
+ })
47
+
48
+ onESStart(() => {
49
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
50
+ log.d(TAG, '---onESStart----->>>')
51
+ }
52
+ })
53
+
54
+ onESRestart(() => {
55
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
56
+ log.d(TAG, '---onESRestart----->>>')
57
+ }
58
+ })
59
+
60
+ onESResume(() => {
61
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
62
+ log.d(TAG, '---onESResume----->>>')
63
+ }
64
+ })
65
+
66
+ onESPause(() => {
67
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
68
+ log.d(TAG, '---onESPause----->>>')
69
+ }
70
+ })
71
+
72
+ onESStop(() => {
73
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
74
+ log.d(TAG, '---onESStop----->>>')
75
+ }
76
+ })
77
+
78
+ onESDetached((data: ESData) => {
79
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
80
+ log.d(TAG, '---onESDetached----->>>', data)
81
+ }
82
+ })
83
+
84
+ onESRecycle(() => {
85
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
86
+ log.d(TAG, '---onESRecycle----->>>')
87
+ }
88
+ })
89
+
90
+ onESDestroy(() => {
91
+ if (log.isLoggable(ESLogLevel.DEBUG)) {
92
+ log.d(TAG, '---onESDestroy----->>>')
93
+ }
94
+ })
95
+
96
+ onESSlotEvent((event: ESSlotEvent) => {
97
+ //JsView焦点事件
98
+ if (event.eventName == ESSlotEventName.ES_SLOT_EVENT_NAME_FOCUS) {
99
+ if (event.eventData.isFocused) {
100
+ //
101
+ } else {
102
+ //
103
+ }
104
+ }
105
+ })
106
+ },
107
+ })
108
+ </script>
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div class="es-key-event-view-css" @keydown="onKeyDown" @keyup="onKeyUp" />
3
+ </template>
4
+
5
+ <script lang="ts">
6
+ import { defineComponent } from "@vue/runtime-core";
7
+ import type { ESKeyEvent } from "@extscreen/es3-core";
8
+
9
+ const TAG = "ESKeyEventView";
10
+
11
+ export default defineComponent({
12
+ name: "EsKeyEventView",
13
+ emits: [],
14
+ setup() {
15
+ function onKeyDown(keyEvent: ESKeyEvent) {
16
+ //
17
+ }
18
+
19
+ function onKeyUp(keyEvent: ESKeyEvent) {
20
+ //
21
+ }
22
+
23
+ return {
24
+ onKeyDown,
25
+ onKeyUp,
26
+ };
27
+ },
28
+ });
29
+ </script>
30
+
31
+ <style scoped>
32
+ .es-key-event-view-css {
33
+ width: 1920px;
34
+ height: 1080px;
35
+ }
36
+ </style>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <div class="es-sdk-root-css">
3
+ <s-title-view class="es-sdk-content-title-css" :text="$options.name" />
4
+ <div class="es-sdk-content-divider-css" />
5
+ <div class="es-sdk-content-row-css">
6
+ <s-text-view text="按返回键查看效果" />
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script lang="ts">
12
+ import { defineComponent } from "@vue/runtime-core";
13
+ import { useESToast } from "@extscreen/es3-core";
14
+ import { useESRouter } from "@extscreen/es3-router";
15
+ import { onBackPressed } from "@extscreen/es3-vue";
16
+
17
+ export default defineComponent({
18
+ name: "返回键",
19
+ emits: [],
20
+ setup() {
21
+ const toast = useESToast();
22
+ const router = useESRouter();
23
+
24
+ onBackPressed(() => {
25
+ toast.showToast("按了返回键");
26
+ router.back();
27
+ });
28
+ },
29
+ });
30
+ </script>
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div class="es-sdk-root-css">
3
+ <s-title-view class="es-sdk-content-title-css" :text="$options.name" />
4
+ <div class="es-sdk-content-divider-css" />
5
+ <div class="es-sdk-content-row-css">
6
+ <s-text-view :text="textRef" />
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script lang="ts">
12
+ import { ref } from "vue";
13
+ import { defineComponent } from "@vue/runtime-core";
14
+ import { useESToast } from "@extscreen/es3-core";
15
+ import { onDispatchKeyEvent } from "@extscreen/es3-vue";
16
+ import type { ESKeyEvent } from "@extscreen/es3-core";
17
+
18
+ export default defineComponent({
19
+ name: "监听分发按键事件",
20
+ emits: [],
21
+ setup() {
22
+ const toast = useESToast();
23
+ const textRef = ref<string>("按键查看效果");
24
+
25
+ onDispatchKeyEvent((keyEvent: ESKeyEvent) => {
26
+ toast.showToast(`onKeyDown${JSON.stringify(keyEvent)}`);
27
+ textRef.value = JSON.stringify(keyEvent);
28
+ });
29
+
30
+ return {
31
+ textRef,
32
+ onDispatchKeyEvent,
33
+ };
34
+ },
35
+ });
36
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <div class="es-sdk-root-css">
3
+ <s-title-view class="es-sdk-content-title-css" :text="$options.name" />
4
+ <div class="es-sdk-content-divider-css" />
5
+ <div class="es-sdk-content-row-css">
6
+ <s-text-view text="按键查看效果" />
7
+ </div>
8
+ </div>
9
+ </template>
10
+ <script lang="ts">
11
+ import { defineComponent } from "@vue/runtime-core";
12
+ import { useESToast } from "@extscreen/es3-core";
13
+ import { onKeyDown, onKeyUp } from "@extscreen/es3-vue";
14
+ import type { ESKeyEvent } from "@extscreen/es3-core";
15
+
16
+ export default defineComponent({
17
+ name: "按键",
18
+ emits: [],
19
+ setup() {
20
+ const toast = useESToast();
21
+
22
+ onKeyDown((keyEvent: ESKeyEvent) => {
23
+ toast.showToast(`onKeyDown${JSON.stringify(keyEvent)}`);
24
+ });
25
+
26
+ onKeyUp((keyEvent: ESKeyEvent) => {
27
+ toast.showToast(`onKeyUp${JSON.stringify(keyEvent)}`);
28
+ });
29
+ },
30
+ });
31
+ </script>