跳转到内容

示例路线图

examples 已按文档路径重新分组。对外命令保持稳定,例如 cargo run --example counter;源码按学习路径放进子目录,并在根 Cargo.toml 里用 [[example]] 显式登记。

每个重要 example 都应该满足:

  • 可以独立 cargo run --example name
  • 对应一篇教程或组件说明。
  • 有可重复的 VHS tape。
  • 录制产物放在 docs/public/recordings/
分组用途examples
start入门和核心心智模型hello_worldcounter
hooks状态、副作用、异步数据async_stateatom_state
core组件模型、Element DSL 和宏语法control_flow
routingshell、动态参数、history 和页面状态router
input输入层、互斥、快捷键input_mutex
components内置组件逐个展示,外加 theme 主题演示inputsearch_inputscrollviewwrapped_textmodalconfirm_modalalert_modalshortcut_info_modalselectmulti_selecttree_selecttablevirtual_listvirtual_multi_selecttheme
advanced自定义 Hook、Provider、手写 Component、原生 widget 桥接custom_widgetcustom_hookcustom_provider
apps组合型完整 demotodo_app

Cargo 只能自动发现顶层 examples/name.rsexamples/name/main.rs。分组目录下的示例必须在根 Cargo.toml 里显式登记:

[[example]]
name = "counter"
path = "examples/start/counter.rs"

新增 example 时也应该同步文档页和 VHS tape,避免文档和可运行代码脱节。

旧的 list / custom_list 已被移除:普通选择看 Select / MultiSelect / VirtualList,原生 ratatui widget 桥接看 custom_widget

目录examples状态
examples/start/hello_worldcounter已登记到 Cargo.toml
examples/hooks/async_stateatom_state已登记到 Cargo.toml
examples/core/control_flow已登记到 Cargo.toml
examples/routing/router已登记到 Cargo.toml
examples/input/input_mutex已登记到 Cargo.toml
examples/components/inputsearch_inputscrollviewwrapped_textmodalconfirm_modalalert_modalshortcut_info_modalselectmulti_selecttree_selecttablevirtual_listvirtual_multi_selecttheme已登记到 Cargo.toml
examples/advanced/custom_widgetcustom_hookcustom_provider已登记到 Cargo.toml
examples/apps/todo_app已登记到 Cargo.toml
example文档录制
hello_world快速开始docs/tapes/hello-world.tape
counter计数器教程docs/tapes/counter.tape
async_state异步数据三态docs/tapes/async-state.tape
atom_stateAtom 全局状态docs/tapes/atom-state.tape
control_flow控制流语法docs/tapes/control-flow.tape
input_mutex输入互斥docs/tapes/input_mutex.tape
scrollviewScrollView 滚动容器docs/tapes/scrollview.tape
wrapped_textWrappedText 长文本docs/tapes/wrapped-text.tape
inputInput 单行输入docs/tapes/input.tape
search_inputSearchInput 搜索输入docs/tapes/search-input.tape
modalModal 基础弹层docs/tapes/modal.tape
confirm_modalConfirmModal 确认弹窗docs/tapes/confirm-modal.tape
alert_modalAlertModal 提示弹窗docs/tapes/alert-modal.tape
shortcut_info_modalShortcutInfoModal 快捷键帮助docs/tapes/shortcut-info-modal.tape
router路由工作台docs/tapes/router.tape
selectSelect 单选docs/tapes/select.tape
multi_selectMultiSelect 多选docs/tapes/multi-select.tape
tree_selectTreeSelect 树形选择docs/tapes/tree-select.tape
tableTable 数据表格docs/tapes/table.tape
virtual_listVirtualList 虚拟列表docs/tapes/virtual-list.tape
virtual_multi_selectVirtual Multi Select 虚拟多选docs/tapes/virtual-multi-select.tape
todo_appTodo Appdocs/tapes/todo-app.tape
custom_widget原生 Widget 桥接docs/tapes/custom-widget.tape
custom_hook自定义 Hookdocs/tapes/custom-hook.tape
custom_provider自定义 Providerdocs/tapes/custom-provider.tape