@ucloud-fe/udesign-cli 0.1.3 → 0.2.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/package.json +1 -1
- package/skills/cpn-basic-box/SKILL.md +40 -2
- package/skills/cpn-basic-breadcrumb/SKILL.md +17 -2
- package/skills/cpn-basic-button/SKILL.md +64 -2
- package/skills/cpn-basic-card/SKILL.md +34 -2
- package/skills/cpn-basic-checkbox/SKILL.md +20 -2
- package/skills/cpn-basic-combine/SKILL.md +27 -2
- package/skills/cpn-basic-date-picker/SKILL.md +21 -2
- package/skills/cpn-basic-editable-table/SKILL.md +6 -2
- package/skills/cpn-basic-icon/SKILL.md +10 -2
- package/skills/cpn-basic-input/SKILL.md +39 -2
- package/skills/cpn-basic-loading/SKILL.md +41 -2
- package/skills/cpn-basic-message/SKILL.md +48 -2
- package/skills/cpn-basic-modal/SKILL.md +73 -2
- package/skills/cpn-basic-notice/SKILL.md +45 -2
- package/skills/cpn-basic-number-input/SKILL.md +42 -2
- package/skills/cpn-basic-popover/SKILL.md +30 -2
- package/skills/cpn-basic-radio/SKILL.md +40 -2
- package/skills/cpn-basic-select/SKILL.md +46 -2
- package/skills/cpn-basic-slider/SKILL.md +45 -2
- package/skills/cpn-basic-switch/SKILL.md +37 -2
- package/skills/cpn-basic-table/SKILL.md +48 -2
- package/skills/cpn-basic-tabs/SKILL.md +46 -2
- package/skills/cpn-basic-tag/SKILL.md +37 -2
- package/skills/cpn-basic-textarea/SKILL.md +40 -2
- package/skills/cpn-basic-tooltip/SKILL.md +39 -2
- package/skills/cpn-basic-tree/SKILL.md +40 -2
- package/skills/udesign/SKILL.md +2 -2
|
@@ -570,13 +570,51 @@ const Demo = () => {
|
|
|
570
570
|
<!-- MANUAL_START: best-practices -->
|
|
571
571
|
## 最佳实践
|
|
572
572
|
|
|
573
|
-
|
|
573
|
+
1. **Key 必须为唯一字符串**:所有节点的 key 不得重复
|
|
574
|
+
2. **异步加载设置 isParent**:需要异步加载子节点的父节点设置 `isParent: true`
|
|
575
|
+
3. **异步加载更新引用**:更新 dataSource 时需要更新引用(spread 新数组)
|
|
576
|
+
4. **异步加载不支持多选**:因为数据未加载无法获取选中数据
|
|
577
|
+
|
|
578
|
+
### 常见场景
|
|
579
|
+
|
|
580
|
+
#### 资源选择树
|
|
581
|
+
|
|
582
|
+
```jsx
|
|
583
|
+
<Form.Item label="选择子网">
|
|
584
|
+
<Tree
|
|
585
|
+
dataSource={subnetTree}
|
|
586
|
+
selectedKeys={selectedSubnets}
|
|
587
|
+
onChange={setSelectedSubnets}
|
|
588
|
+
search
|
|
589
|
+
/>
|
|
590
|
+
</Form.Item>
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
#### 多选权限树
|
|
594
|
+
|
|
595
|
+
```jsx
|
|
596
|
+
<Tree
|
|
597
|
+
ref={treeRef}
|
|
598
|
+
multiple
|
|
599
|
+
dataSource={permissionTree}
|
|
600
|
+
selectedKeys={selectedPermissions}
|
|
601
|
+
onChange={setSelectedPermissions}
|
|
602
|
+
/>
|
|
603
|
+
<Button onClick={() => treeRef.current.selectAll()}>全选</Button>
|
|
604
|
+
<Button onClick={() => treeRef.current.unSelectAll()}>取消全选</Button>
|
|
605
|
+
```
|
|
574
606
|
<!-- MANUAL_END: best-practices -->
|
|
575
607
|
|
|
576
608
|
<!-- MANUAL_START: faq -->
|
|
577
609
|
## 常见问题
|
|
578
610
|
|
|
579
|
-
|
|
611
|
+
### Q: 选中回调中包含父节点吗?
|
|
612
|
+
|
|
613
|
+
A: 不包含。onChange 回调的 keys 只包含叶子节点。父节点仅做展示和折叠控制。
|
|
614
|
+
|
|
615
|
+
### Q: 异步加载时为什么没有展开按钮?
|
|
616
|
+
|
|
617
|
+
A: 需要在父节点数据中添加 `isParent: true` 来告知组件显示展开按钮。
|
|
580
618
|
<!-- MANUAL_END: faq -->
|
|
581
619
|
|
|
582
620
|
<!-- MANUAL_START: critical -->
|
package/skills/udesign/SKILL.md
CHANGED
|
@@ -5,14 +5,14 @@ description: "Use when the user's task involves UDesign (react-components) — w
|
|
|
5
5
|
|
|
6
6
|
# UDesign CLI
|
|
7
7
|
|
|
8
|
-
You have access to `@udesign
|
|
8
|
+
You have access to `@ucloud-fe/udesign-cli` — a local CLI tool with bundled UDesign component metadata. Use it to query component knowledge, analyze projects, and check for issues. All data is offline, no network needed.
|
|
9
9
|
|
|
10
10
|
You also have access to **per-component skills** (`cpn-basic-*`, `cpn-pro-*`) that contain detailed Props, Demos, Design Tokens, and best practices for each component. When working with a specific component, load its skill first — it has everything you need. Fall back to CLI commands for cross-component queries, project analysis, and token comparisons.
|
|
11
11
|
|
|
12
12
|
## Setup
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
which udesign || npm install -g @udesign
|
|
15
|
+
which udesign || npm install -g @ucloud-fe/udesign-cli
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
**Always use `--format json` for structured output you can parse programmatically.**
|