create-vela-workflow 1.0.0
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 +136 -0
- package/bin/cli.js +188 -0
- package/docs/ai-workflow-tutorial.md +462 -0
- package/docs/official-site-tutorial.md +391 -0
- package/package.json +34 -0
- package/templates/.github/HARNESS-ENGINEERING-GUIDE.md +407 -0
- package/templates/.github/agents/vela-knowledge.agent.md +45 -0
- package/templates/.github/agents/vela-s1-prd.agent.md +69 -0
- package/templates/.github/agents/vela-s2-tech.agent.md +66 -0
- package/templates/.github/agents/vela-s3-coding.agent.md +301 -0
- package/templates/.github/agents/vela-workflow.agent.md +110 -0
- package/templates/.github/copilot-instructions.md +64 -0
- package/templates/.github/prompts/vela-apis.prompt.md +98 -0
- package/templates/.github/prompts/vela-best-practices.prompt.md +93 -0
- package/templates/.github/prompts/vela-components.prompt.md +118 -0
- package/templates/.github/prompts/vela-dev-guide.prompt.md +622 -0
- package/templates/.github/rules/project-init.md +45 -0
- package/templates/.github/rules/vela-coding-convention.md +324 -0
- package/templates/.github/rules/vela-css.md +217 -0
- package/templates/.github/rules/vela-design-driven.md +306 -0
- package/templates/.github/rules/vela-figma-mcp.md +198 -0
- package/templates/.github/rules/vela-format.md +119 -0
- package/templates/.github/rules/vela-layout.md +67 -0
- package/templates/.github/rules/vela-platform.md +46 -0
- package/templates/.github/rules/vela-quality.md +109 -0
- package/templates/.kiro/hooks/figma-design-check.kiro.hook +14 -0
- package/templates/.kiro/hooks/post-coding-validation.kiro.hook +13 -0
- package/templates/.kiro/hooks/validate-ux-files.kiro.hook +16 -0
- package/templates/.kiro/settings/mcp.json +7 -0
- package/templates/.kiro/skills/vela-js-app/SKILL.md +1072 -0
- package/templates/.kiro/steering/workflow-conventions.md +110 -0
- package/templates/.workflow/resource-paths.json +62 -0
- package/templates/.workflow/scripts/.gitkeep +0 -0
- package/templates/.workflow/scripts/checkpoint_manager.js +284 -0
- package/templates/.workflow/scripts/context_loader.js +841 -0
- package/templates/.workflow/scripts/figma_export.js +346 -0
- package/templates/.workflow/scripts/session_manager.js +438 -0
- package/templates/.workflow/stages/.gitkeep +0 -0
- package/templates/.workflow/stages/commands.md +171 -0
- package/templates/.workflow/stages/s1_prd.md +286 -0
- package/templates/.workflow/stages/s2_tech_design.md +302 -0
- package/templates/.workflow/stages/s3_coding.md +699 -0
- package/templates/.workflow/stages/s4_simulator.md +259 -0
- package/templates/.workflow/workflow-config.json +46 -0
- package/templates/.workflow/workflow_starter.md +912 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Vela 快应用编码规范 — 基于官方文档(https://iot.mi.com/vela/quickapp/zh/guide/)的强制编码约束
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vela 快应用编码规范
|
|
7
|
+
|
|
8
|
+
> ⚠️ 本文件为强制执行规则,AI 必须无条件遵守。所有生成的 Vela 快应用代码必须严格符合官方文档规范。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 一、组件导入规范(最重要)
|
|
13
|
+
|
|
14
|
+
### 1.1 `<import>` 标签导入(模板层)
|
|
15
|
+
|
|
16
|
+
**必须**在 `<template>` 标签之前使用 `<import>` 标签声明组件:
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<import name="header" src="../../components/Header"></import>
|
|
20
|
+
<import name="searchbar" src="../../components/SearchBar"></import>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div>
|
|
24
|
+
<header title="标题" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 1.2 组件命名规则
|
|
30
|
+
|
|
31
|
+
| 规则 | 说明 | 示例 |
|
|
32
|
+
|------|------|------|
|
|
33
|
+
| `name` 属性 | 小写字母,无分隔符 | `name="appcard"` |
|
|
34
|
+
| 模板使用 | 与 `name` 一致的小写标签 | `<appcard />` |
|
|
35
|
+
| `src` 路径 | 不带 `.ux` 后缀 | `src="../../components/Header"` |
|
|
36
|
+
|
|
37
|
+
### 1.3 禁止行为
|
|
38
|
+
|
|
39
|
+
| ❌ 错误 | ✅ 正确 |
|
|
40
|
+
|---------|---------|
|
|
41
|
+
| `import Header from './Header.ux'` | `<import name="header" src="./Header"></import>` |
|
|
42
|
+
| `<Header title="x" />` | `<header title="x" />` |
|
|
43
|
+
| `src="../../components/Header.ux"` | `src="../../components/Header"` |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 二、.ux 文件结构规范
|
|
48
|
+
|
|
49
|
+
### 2.1 三段式结构
|
|
50
|
+
|
|
51
|
+
每个 `.ux` 文件必须包含三部分,顺序固定:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<import name="comp" src="./Comp"></import>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<!-- 只能有一个根节点 -->
|
|
58
|
+
<div class="container">
|
|
59
|
+
<comp />
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
.container { flex-direction: column; }
|
|
65
|
+
</style>
|
|
66
|
+
|
|
67
|
+
<script>
|
|
68
|
+
export default {
|
|
69
|
+
props: [],
|
|
70
|
+
data: {},
|
|
71
|
+
onInit() {},
|
|
72
|
+
onDestroy() {}
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2.2 模板规则
|
|
78
|
+
|
|
79
|
+
- **根节点唯一**:`<template>` 内只能有一个根节点
|
|
80
|
+
- **组件标签小写**:所有自定义组件标签必须小写
|
|
81
|
+
- **事件绑定**:使用 `on` 前缀(`onclick`、`ontap`、`onchange`)
|
|
82
|
+
- **数据绑定**:使用 `{{}}` 双花括号语法
|
|
83
|
+
|
|
84
|
+
### 2.3 样式规则
|
|
85
|
+
|
|
86
|
+
- **Flexbox 布局**:所有布局使用 Flexbox
|
|
87
|
+
- **单位省略**:数字默认为 px,无需写单位
|
|
88
|
+
- **类名规范**:使用 kebab-case(`app-card`)
|
|
89
|
+
- **禁止 `@import`**:使用 `<style src="./style.css"></style>` 外部引入
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 三、数据绑定规范
|
|
94
|
+
|
|
95
|
+
### 3.1 组件 Props
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<!-- 父组件传递 -->
|
|
99
|
+
<appcard app="{{item}}" ontap="onTap" />
|
|
100
|
+
|
|
101
|
+
<!-- 子组件接收 -->
|
|
102
|
+
<script>
|
|
103
|
+
export default {
|
|
104
|
+
props: ['app'],
|
|
105
|
+
// props 自动绑定到 this
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 3.2 事件处理
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<!-- 事件绑定:on + 事件名 -->
|
|
114
|
+
<button onclick="handleClick">点击</button>
|
|
115
|
+
<list onscroll="handleScroll">...</list>
|
|
116
|
+
|
|
117
|
+
<!-- 子组件触发事件 -->
|
|
118
|
+
this.$emit('tap', { app: this.app });
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3.3 条件渲染
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<div if="{{show}}">显示内容</div>
|
|
125
|
+
<div elif="{{other}}">其他内容</div>
|
|
126
|
+
<div else>默认内容</div>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3.4 列表渲染
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<list>
|
|
133
|
+
<list-item for="{{items}}">
|
|
134
|
+
<text>{{$idx}} - {{$item.name}}</text>
|
|
135
|
+
</list-item>
|
|
136
|
+
</list>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 四、生命周期规范
|
|
142
|
+
|
|
143
|
+
### 4.1 页面生命周期
|
|
144
|
+
|
|
145
|
+
```javascript
|
|
146
|
+
export default {
|
|
147
|
+
data: {}, // 页面数据(非 private)
|
|
148
|
+
|
|
149
|
+
onInit() {}, // 页面初始化(最早触发)
|
|
150
|
+
onReady() {}, // 页面渲染完成
|
|
151
|
+
onShow() {}, // 页面显示
|
|
152
|
+
onHide() {}, // 页面隐藏
|
|
153
|
+
onDestroy() {} // 页面销毁(必须清理资源)
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 4.2 组件生命周期
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
export default {
|
|
161
|
+
props: [],
|
|
162
|
+
data: {},
|
|
163
|
+
|
|
164
|
+
onInit() {}, // 组件初始化
|
|
165
|
+
onReady() {}, // 组件渲染完成
|
|
166
|
+
onDestroy() {} // 组件销毁
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 4.3 资源清理(必须)
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
onDestroy() {
|
|
174
|
+
// 清理定时器
|
|
175
|
+
if (this.timer) clearInterval(this.timer);
|
|
176
|
+
// 清理事件监听
|
|
177
|
+
// 清理网络请求
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 五、系统 API 调用规范
|
|
184
|
+
|
|
185
|
+
### 5.1 导入方式
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
import router from '@system.router';
|
|
189
|
+
import fetch from '@system.fetch';
|
|
190
|
+
import storage from '@system.storage';
|
|
191
|
+
import file from '@system.file';
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 5.2 常用 API 示例
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
// 路由跳转
|
|
198
|
+
router.push({ uri: '/pages/detail', params: { id: '1' } });
|
|
199
|
+
router.back();
|
|
200
|
+
|
|
201
|
+
// 网络请求
|
|
202
|
+
fetch.fetch({
|
|
203
|
+
url: 'https://api.example.com/data',
|
|
204
|
+
method: 'GET',
|
|
205
|
+
responseType: 'json',
|
|
206
|
+
success: (response) => { /* 处理响应 */ },
|
|
207
|
+
fail: (data, code) => { /* 处理错误 */ }
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// 本地存储
|
|
211
|
+
storage.set({ key: 'user', value: JSON.stringify(data) });
|
|
212
|
+
storage.get({ key: 'user', success: (data) => { /* ... */ } });
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 5.3 错误处理(必须)
|
|
216
|
+
|
|
217
|
+
所有 API 调用必须包含错误处理:
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
fetch.fetch({
|
|
221
|
+
url: apiUrl,
|
|
222
|
+
success: (response) => {
|
|
223
|
+
// 成功处理
|
|
224
|
+
},
|
|
225
|
+
fail: (data, code) => {
|
|
226
|
+
console.error('请求失败:', code);
|
|
227
|
+
// 错误提示
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 六、manifest.json 规范
|
|
235
|
+
|
|
236
|
+
### 6.1 必需字段
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"package": "com.company.appname",
|
|
241
|
+
"name": "应用名称",
|
|
242
|
+
"icon": "/common/logo.png",
|
|
243
|
+
"versionCode": 1,
|
|
244
|
+
"minPlatformVersion": 1200,
|
|
245
|
+
"deviceTypeList": ["watch"],
|
|
246
|
+
"config": {
|
|
247
|
+
"logLevel": "log",
|
|
248
|
+
"designWidth": 480
|
|
249
|
+
},
|
|
250
|
+
"features": [
|
|
251
|
+
{ "name": "system.router" }
|
|
252
|
+
],
|
|
253
|
+
"router": {
|
|
254
|
+
"entry": "pages/index",
|
|
255
|
+
"pages": {
|
|
256
|
+
"pages/index": { "component": "index" }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 6.2 features 声明
|
|
263
|
+
|
|
264
|
+
使用哪个 API 就必须声明对应的 feature:
|
|
265
|
+
|
|
266
|
+
| API | feature 声明 |
|
|
267
|
+
|-----|-------------|
|
|
268
|
+
| `@system.router` | `{ "name": "system.router" }` |
|
|
269
|
+
| `@system.fetch` | `{ "name": "system.fetch" }` |
|
|
270
|
+
| `@system.storage` | `{ "name": "system.storage" }` |
|
|
271
|
+
| `@system.file` | `{ "name": "system.file" }` |
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 七、项目目录规范
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
project/
|
|
279
|
+
├── package.json # aiot-toolkit(禁止 hap-toolkit)
|
|
280
|
+
├── src/
|
|
281
|
+
│ ├── manifest.json
|
|
282
|
+
│ ├── app.ux
|
|
283
|
+
│ ├── pages/
|
|
284
|
+
│ │ └── PageName/
|
|
285
|
+
│ │ └── index.ux
|
|
286
|
+
│ ├── components/
|
|
287
|
+
│ │ └── CompName.ux
|
|
288
|
+
│ ├── common/
|
|
289
|
+
│ │ └── logo.png
|
|
290
|
+
│ └── i18n/
|
|
291
|
+
│ ├── defaults.json
|
|
292
|
+
│ └── zh-CN.json
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 八、自检清单
|
|
298
|
+
|
|
299
|
+
每次生成代码前必须逐项检查:
|
|
300
|
+
|
|
301
|
+
### 组件导入
|
|
302
|
+
- [ ] 使用 `<import>` 标签而非 ES6 `import`
|
|
303
|
+
- [ ] `src` 路径不带 `.ux` 后缀
|
|
304
|
+
- [ ] 模板中组件标签全部小写
|
|
305
|
+
- [ ] `name` 属性为小写字母
|
|
306
|
+
|
|
307
|
+
### 文件结构
|
|
308
|
+
- [ ] `<template>` 只有一个根节点
|
|
309
|
+
- [ ] 三段式顺序:`<import>` → `<template>` → `<style>` → `<script>`
|
|
310
|
+
- [ ] 样式使用 Flexbox
|
|
311
|
+
|
|
312
|
+
### 数据与事件
|
|
313
|
+
- [ ] 事件绑定使用 `on` 前缀
|
|
314
|
+
- [ ] 列表渲染使用 `$idx` 和 `$item`
|
|
315
|
+
- [ ] 条件渲染使用 `if/elif/else`
|
|
316
|
+
|
|
317
|
+
### API 调用
|
|
318
|
+
- [ ] 已导入所需系统 API
|
|
319
|
+
- [ ] 已在 manifest.json 声明 features
|
|
320
|
+
- [ ] 所有 API 调用包含错误处理
|
|
321
|
+
|
|
322
|
+
### 资源清理
|
|
323
|
+
- [ ] `onDestroy()` 中清理定时器
|
|
324
|
+
- [ ] `onDestroy()` 中清理事件监听
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: CSS 编码规范 — 选择器限制、嵌套规则、样式编写约束
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vela 快应用 CSS 编码规范
|
|
7
|
+
|
|
8
|
+
> ⚠️ 本文件为强制执行规则,AI 必须无条件遵守。
|
|
9
|
+
|
|
10
|
+
## 选择器规则
|
|
11
|
+
|
|
12
|
+
### 只允许使用 class 选择器
|
|
13
|
+
|
|
14
|
+
**禁止**使用以下选择器类型:
|
|
15
|
+
|
|
16
|
+
| 禁止类型 | 示例 | 原因 |
|
|
17
|
+
|----------|------|------|
|
|
18
|
+
| 元素选择器 | `div { }` | 耦合度高,难以维护 |
|
|
19
|
+
| ID 选择器 | `#header { }` | 特异性过高 |
|
|
20
|
+
| 后代选择器 | `.parent .child { }` | 性能差,作用域不可控 |
|
|
21
|
+
| 子选择器 | `.parent > .child { }` | 嵌套耦合 |
|
|
22
|
+
| 伪类选择器 | `.item:hover { }` | 穿戴设备无鼠标交互 |
|
|
23
|
+
| 伪元素选择器 | `.item::before { }` | 不支持或兼容性差 |
|
|
24
|
+
| 属性选择器 | `[type="text"] { }` | 不支持 |
|
|
25
|
+
| 通配选择器 | `* { }` | 不支持 |
|
|
26
|
+
|
|
27
|
+
**正确写法** ✅:
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
.page-container {
|
|
31
|
+
width: 480px;
|
|
32
|
+
height: 480px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.section-title {
|
|
36
|
+
font-size: 28px;
|
|
37
|
+
color: #ffffff;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.app-card {
|
|
41
|
+
background-color: #1a1a1a;
|
|
42
|
+
border-radius: 12px;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**错误写法** ❌:
|
|
47
|
+
|
|
48
|
+
```css
|
|
49
|
+
/* 后代选择器 */
|
|
50
|
+
.page .title { }
|
|
51
|
+
|
|
52
|
+
/* 伪类 */
|
|
53
|
+
.item:active { }
|
|
54
|
+
|
|
55
|
+
/* 元素选择器 */
|
|
56
|
+
div { padding: 10px; }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 禁止嵌套写法
|
|
60
|
+
|
|
61
|
+
Vela 快应用 **不支持** CSS 嵌套语法,所有样式必须扁平编写。
|
|
62
|
+
|
|
63
|
+
**正确写法** ✅:
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
.parent {
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.child {
|
|
71
|
+
font-size: 24px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.grandchild {
|
|
75
|
+
color: #ffffff;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**错误写法** ❌:
|
|
80
|
+
|
|
81
|
+
```css
|
|
82
|
+
/* 禁止嵌套 */
|
|
83
|
+
.parent {
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
|
|
86
|
+
.child {
|
|
87
|
+
font-size: 24px;
|
|
88
|
+
|
|
89
|
+
.grandchild {
|
|
90
|
+
color: #ffffff;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 不推荐使用 Less/Sass
|
|
97
|
+
|
|
98
|
+
- **禁止**使用 Less、Sass、SCSS 等 CSS 预处理器
|
|
99
|
+
- 所有样式使用**原生 CSS** 编写
|
|
100
|
+
- 变量、混合宏等功能不被 Vela 快应用支持
|
|
101
|
+
|
|
102
|
+
**正确写法** ✅:
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
/* 使用原生 CSS */
|
|
106
|
+
.primary-button {
|
|
107
|
+
background-color: #4CAF50;
|
|
108
|
+
border-radius: 20px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.secondary-button {
|
|
112
|
+
background-color: #2196F3;
|
|
113
|
+
border-radius: 20px;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**错误写法** ❌:
|
|
118
|
+
|
|
119
|
+
```less
|
|
120
|
+
/* Less 变量 */
|
|
121
|
+
@primary-color: #4CAF50;
|
|
122
|
+
|
|
123
|
+
.primary-button {
|
|
124
|
+
background-color: @primary-color;
|
|
125
|
+
.border-radius();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Less 混合 */
|
|
129
|
+
.border-radius() {
|
|
130
|
+
border-radius: 20px;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## class 命名规范
|
|
135
|
+
|
|
136
|
+
| 规则 | 说明 | 示例 |
|
|
137
|
+
|------|------|------|
|
|
138
|
+
| kebab-case | 多单词用连字符连接 | `app-card`, `section-title` |
|
|
139
|
+
| 语义化 | 名称体现用途 | `user-info` 而非 `info1` |
|
|
140
|
+
| 前缀区分 | 组件级样式加前缀 | `app-card__icon` |
|
|
141
|
+
| 避免缩写 | 使用完整单词 | `container` 而非 `ctn` |
|
|
142
|
+
|
|
143
|
+
**推荐命名模式**:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
{模块}-{元素}
|
|
147
|
+
{模块}-{状态}
|
|
148
|
+
|
|
149
|
+
示例:
|
|
150
|
+
app-card — 应用卡片
|
|
151
|
+
app-card__icon — 卡片中的图标
|
|
152
|
+
app-card--active — 卡片激活状态
|
|
153
|
+
section-title — 区域标题
|
|
154
|
+
search-input — 搜索输入框
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 样式编写规范
|
|
158
|
+
|
|
159
|
+
### 属性顺序
|
|
160
|
+
|
|
161
|
+
推荐按以下顺序编写 CSS 属性:
|
|
162
|
+
|
|
163
|
+
```css
|
|
164
|
+
.custom-class {
|
|
165
|
+
/* 1. 尺寸 */
|
|
166
|
+
width: 100%;
|
|
167
|
+
height: 80px;
|
|
168
|
+
|
|
169
|
+
/* 2. 布局 */
|
|
170
|
+
flex-direction: row;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
align-items: center;
|
|
173
|
+
|
|
174
|
+
/* 3. 间距 */
|
|
175
|
+
padding: 12px;
|
|
176
|
+
margin-bottom: 16px;
|
|
177
|
+
|
|
178
|
+
/* 4. 外观 */
|
|
179
|
+
background-color: #1a1a1a;
|
|
180
|
+
border-radius: 12px;
|
|
181
|
+
|
|
182
|
+
/* 5. 文字 */
|
|
183
|
+
font-size: 28px;
|
|
184
|
+
color: #ffffff;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 颜色规范
|
|
189
|
+
|
|
190
|
+
| 用途 | 推荐值 | 说明 |
|
|
191
|
+
|------|--------|------|
|
|
192
|
+
| 页面背景 | `#000000` | 深色主题 |
|
|
193
|
+
| 卡片背景 | `#1a1a1a` | 次级背景 |
|
|
194
|
+
| 主文字 | `#ffffff` | 标题、正文 |
|
|
195
|
+
| 辅助文字 | `#888888` | 次要信息 |
|
|
196
|
+
| 禁用文字 | `#666666` | 不可操作 |
|
|
197
|
+
| 主题色 | `#4CAF50` | 按钮、强调 |
|
|
198
|
+
| 警告色 | `#FF9800` | 提示信息 |
|
|
199
|
+
| 错误色 | `#FF6B6B` | 错误、删除 |
|
|
200
|
+
|
|
201
|
+
### 尺寸单位
|
|
202
|
+
|
|
203
|
+
- 使用 **px** 作为唯一单位
|
|
204
|
+
- 不使用 `rem`、`em`、`%`(除 width: 100% 等特殊情况)
|
|
205
|
+
- 不使用 `vw`、`vh` 视口单位
|
|
206
|
+
|
|
207
|
+
## 代码自检清单(CSS 部分)
|
|
208
|
+
|
|
209
|
+
- [ ] 所有选择器均为 class 选择器
|
|
210
|
+
- [ ] 无后代选择器、子选择器
|
|
211
|
+
- [ ] 无伪类、伪元素选择器
|
|
212
|
+
- [ ] 无嵌套写法
|
|
213
|
+
- [ ] 无 Less/Sass/SCSS 语法
|
|
214
|
+
- [ ] class 命名符合 kebab-case 规范
|
|
215
|
+
- [ ] 样式属性顺序合理
|
|
216
|
+
- [ ] 颜色使用推荐色值
|
|
217
|
+
- [ ] 尺寸单位使用 px
|