` indicating whether a preview was requested. `downloadCsv(options?)` initiates a browser download. `copyImage(options?)` reports whether a PNG was written to the clipboard.
diff --git a/apps/docs/examples/AdminExample.vue b/apps/docs/examples/AdminExample.vue
index b6f2dec3..45de6428 100644
--- a/apps/docs/examples/AdminExample.vue
+++ b/apps/docs/examples/AdminExample.vue
@@ -9,11 +9,14 @@
@@ -24,7 +27,7 @@
diff --git a/apps/docs/guide/appearance.md b/apps/docs/guide/appearance.md
index d3fe9781..eb28e048 100644
--- a/apps/docs/guide/appearance.md
+++ b/apps/docs/guide/appearance.md
@@ -11,7 +11,7 @@
| Material | 紫色调、较大的圆角、胶囊按钮和分层表面 |
| 朴素 | 中性灰、小圆角和无阴影表面 |
-手动选择的主题色优先于预设,并随风格保留;点击「使用风格默认色」可恢复当前风格的配色。自定义主色的实心按钮会按各交互状态的实际填充色选择黑字或白字,半透明主色按当前主题卡片底色合成。新用户、恢复默认设置,以及缺少风格的历史配置都使用现代化。已有的显式风格选择会在刷新和导入时保留。
+手动选择的主题色优先于预设,并随风格保留。点击「使用风格默认色」可恢复当前风格的配色。浅色模式下,自定义主色的实心按钮使用白字,主题会适度加深过浅的按钮色以保持可读性。深色模式按实际填充色选择黑字或白字。半透明主色按当前主题卡片底色合成。新用户、恢复默认设置和缺少风格的历史配置都使用现代化。已有的显式风格选择会在刷新和导入时保留。
### 样式放在哪里
diff --git a/apps/docs/guide/curd-examples.md b/apps/docs/guide/curd-examples.md
new file mode 100644
index 00000000..e6073fca
--- /dev/null
+++ b/apps/docs/guide/curd-examples.md
@@ -0,0 +1,48 @@
+# CURD 交互示例
+
+Ray Admin 的「CURD 示例」菜单包含两套业务。下方可直接运行,每个示例使用独立的演示数据。后台菜单中的修改保存在当前浏览器会话,内嵌示例刷新后会恢复初始数据。
+
+初始路由配置包含这两个菜单项。已有路由快照可以从初始配置取出「CURD 示例」分组并合并到当前配置。
+
+
+
+## 简单示例:标签管理 {#tags}
+
+在工具栏新增标签,或从行操作编辑现有标签。两个动作分别提供默认值或现有记录,并把各自的保存函数交给同一个短表单。点击标签名称可在抽屉里快速查看备注,原列表保留在原处。
+
+试着输入已有的标签名,例如 `Design`。保存失败后,表单会保留输入。修改一个字段后按 Esc,可以选择继续编辑或放弃更改。删除确认会显示目标标签。
+
+
+
+::: details 查看标签示例源码
+<<< ../../admin/src/views/demo/curd/tags.tsx
+
+<<< ../../admin/src/views/demo/curd/TagEditorModal.tsx
+:::
+
+## 复杂示例:项目与里程碑 {#projects}
+
+项目列表有名称和状态筛选、排序及分页。新增、详情和编辑各有独立路由。新增和编辑复用同一个编辑器,详情页用只读内容展示基本信息和里程碑。
+
+1. 筛选「进行中」,打开一个项目详情,再进入编辑。
+2. 修改负责人或添加里程碑。取消时可保留草稿继续编辑,或放弃更改并返回详情。
+3. 保存后,详情会展示新值。返回列表时,会恢复应用过的筛选、排序和页码。
+4. 从列表直接编辑,则保存或取消后回到列表。删除项目时,确认弹窗会说明里程碑也将删除。
+
+
+
+::: details 查看项目列表与动作容器源码
+<<< ../../admin/src/views/demo/curd/projects.tsx
+
+<<< ../../admin/src/views/demo/curd/project-create.tsx
+
+<<< ../../admin/src/views/demo/curd/project-edit.tsx
+
+<<< ../../admin/src/views/demo/curd/project-detail.tsx
+
+<<< ../../admin/src/views/demo/curd/ProjectEditor.tsx
+:::
+
+[第一个业务页面](./first-page) · [路由、菜单与权限](./routing)
diff --git a/apps/docs/guide/first-page.md b/apps/docs/guide/first-page.md
index 1d103b86..86b3e6c6 100644
--- a/apps/docs/guide/first-page.md
+++ b/apps/docs/guide/first-page.md
@@ -55,6 +55,8 @@ orders: { load: () => import('@/views/orders'), name: 'Orders' },
现成的「系统管理 → 用户管理」已演示组织筛选、远端查询、新增编辑、详情、批量操作和接口权限。可先对照这条完整流程,再接入自己的业务。其 API 与数据结构见[标准契约](./backend)。
+在 [CURD 交互示例](./curd-examples) 中,可以对比同一列表中的弹窗和抽屉,以及用独立路由组合新增、详情和编辑的做法。
+
## 接入 API
在 `apps/admin/src/api` 写订单请求函数,将 TablePro 的分页、筛选条件映射成后端的字段,并把 `data` 替换成 `request={loadOrders}`。接口需返回当前页数据和筛选后的总数。参照[远端 TablePro 在线示例](../reference/table-pro-examples#远端查询与失败恢复)接入排序、取消和错误重试。
diff --git a/apps/docs/guide/routing.md b/apps/docs/guide/routing.md
index 7528d5a9..d4fdb16f 100644
--- a/apps/docs/guide/routing.md
+++ b/apps/docs/guide/routing.md
@@ -20,6 +20,8 @@ import RouteConfigDemo from '../examples/RouteConfigDemo.vue'
有 `routes:write` 权限时,可视化和 JSON 页面从编辑接口加载完整草稿,通过 `PUT /admin/route-config` 保存,随后刷新运行路由。Mock 写入会保存在当前浏览器,也可以切换本机或内置配置。标准后端模式以远端为准,读取失败时显示错误。 若配置了只读的 `VITE_ROUTE_CONFIG_URL`,在 JSON 页面选择远程来源并点击“启用远程配置”即可恢复读取该地址。修改只读来源的草稿可以保存在本地或导出。
+编辑器中有未保存的修改时,切换页面、重新读取配置或导入替换草稿都会先请求确认。选择「继续编辑」会保留草稿,也可以从当前编辑器导出草稿。
+
接口请求体为 `{ version: 1, routes: [...] }`,读取和写入响应都放在统一 `{ code, msg, data }` 包络的 `data` 中。`component` 必须是 `router/config/views.ts` 的注册 ID;新增前端页面先注册 ID,再由接口返回其路由记录。详见[服务端标准契约](./backend)。
## 常用元数据
diff --git a/apps/docs/reference/table-pro-examples.md b/apps/docs/reference/table-pro-examples.md
index d17334da..5ae5b12f 100644
--- a/apps/docs/reference/table-pro-examples.md
+++ b/apps/docs/reference/table-pro-examples.md
@@ -31,7 +31,7 @@ import AdminExample from '../examples/AdminExample.vue'
1. 复制某行姓名或邮箱的一部分,填入上方筛选区并提交。查询回到第 1 页,分页使用筛选后的总数。
2. 清除条件后排序「年龄」并翻页。年龄排序通过 `onUpdateSorter` 转成 `params.sortAge`,在分页前作用于整个结果集。
3. 分别在两页勾选行;工具栏显示跨页选中总数。「更多操作 → 导出 CSV」导出当前页可见数据列。
-4. 点击「模拟请求失败」,观察旧行清空和错误提示;点击「刷新」恢复。传给 `request` 的 `signal` 可转交给 HTTP 客户端。
+4. 点击「模拟请求失败」,观察旧行清空和表内错误提示。点击「重试」恢复。传给 `request` 的 `signal` 可转交给 HTTP 客户端。
@@ -59,7 +59,7 @@ import AdminExample from '../examples/AdminExample.vue'
2. **联动和取消**:快速切换北区和南区。负责人草稿会清空,旧的候选请求会取消。在南区候选项中搜索「王雨」。
3. **零值与布尔值**:点击「交付与金额」,应用条件后展开订单。查看商品级联、仓库树、配送控件和日期时间字段如何配合,确认参数保留 `minAmount: 0` 与 `invoiced: false`。
4. **校验与自动查询**:提交单字符关键词,确认旧结果仍在;修正输入后切换为输入后自动应用,连续编辑观察防抖。
-5. **分别恢复失败**:让负责人候选或列表失败一次。候选可在字段处重试,列表可再次提交。
+5. **分别恢复失败**:让负责人候选或列表失败一次。候选可在字段处重试,列表可在表格内重试。
diff --git a/apps/docs/reference/table-pro.md b/apps/docs/reference/table-pro.md
index 2928dc79..43a84844 100644
--- a/apps/docs/reference/table-pro.md
+++ b/apps/docs/reference/table-pro.md
@@ -50,7 +50,7 @@ const renderRemote = () => (
)
```
-- 远端 `request(params, signal)` 返回 `Promise<{ data, total }>`。组件只采用最新请求结果;切换请求源或筛选范围时清空旧行和总数,切页或修改每页条数时隐藏旧行。没有当前页结果时,实例取数为空、CSV 和打印不可用。请求失败时清空行与总数,沿用空态,并通过宿主 Toast 提醒;调用方可用实例 `reload()` 重试。要中止底层 HTTP,请把 signal 交给请求客户端。
+- 远端 `request(params, signal)` 返回 `Promise<{ data, total }>`。组件只采用最新请求结果;切换请求源或筛选范围时清空旧行和总数,切页或修改每页条数时隐藏旧行。没有当前页结果时,实例取数为空、CSV 和打印不可用。请求失败时清空行与总数,表格会显示错误和重试按钮。调用方也可以用实例 `reload()` 重试。要中止底层 HTTP,请把 signal 交给请求客户端。
- 搜索提交回到第 1 页。外部筛选用 `params`,复杂表单可从 `filters` 插槽调用 `submit(values)`。服务端排序和过滤由调用方将事件值映射进 `params`。
- 默认每页 10 条;用 `pageSize`、`pagination.pageSizes` 调整,或传 `pagination={false}` 关闭。关闭时不添加分页字段;`bare pagination` 可单独开启分页。
- 初始页用 `pagination.defaultPage`。远端模式下组件管理当前页、每页条数和总数;调用方已有自己的远端控制时可传 `remote + data + pagination`,并自行处理范围切换。受控分页由调用方在回调中更新页码和每页条数;搜索重置和实例操作都触发对应回调。
@@ -64,7 +64,7 @@ const renderRemote = () => (
- **交付与金额**填入商品级联、仓库树、最低金额、开票状态、自定义配送方式和交付时间。应用后展开匹配订单核对交付信息,留意请求中保留了 `minAmount: 0` 与 `invoiced: false`。
- **试试校验**提交一个字符的关键词,查看校验提示及保留的列表。修正输入后,可以切换「输入后自动应用」,快速连续编辑并观察列表请求。
-在「最近请求」里还能让负责人或列表请求失败一次。负责人选项使用字段下方的重试;列表失败显示空态,通过再次查询恢复。
+在「最近请求」里还能让负责人或列表请求失败一次。负责人选项使用字段下方的重试。列表请求失败时,使用表格内的重试按钮。
@@ -227,9 +227,10 @@ Naive UI DataTable 的列定义、选择、展开、加载、空态和虚拟滚
| `filters` | 表格上方;接收 `{ submit(values) }`,传入字符串或数字键值,提交后回第一页。优先于内置 `search`。 |
| `title` / `toolbar` | 标题区左侧 / 操作区右侧;`bare` 下两者隐藏。 |
| `notice` | 正常情况下显示自定义提示。 |
-| `error` | 显式提供时在请求失败后替换 `notice`,接收 `{ reload }` 并接管默认 Toast。 |
+| `error` | 请求失败时接管默认反馈并替换 `notice`,接收 `{ reload }`。 |
| `tableFooter` / `tableAction` | DataTable 之后的额外区域。 |
-| 其余插槽 | 转给 Naive UI DataTable,例如空态和加载。 |
+| `empty` | 自定义查询成功后的空态。默认区分无数据和无匹配结果,后者为内置筛选提供重置操作。 |
+| 其余插槽 | 转给 Naive UI DataTable,例如加载状态。 |
`TableProInst` 的 `reload(resetPage?)`、`setPage(page)`、`setPageSize(size)` 返回 `Promise`。请求错误由事件报告;该 Promise 的完成不能用作业务成功判据。`getTableInstance()` 可能为 `null`;`print(options?)` 返回 `Promise` 表示是否发起预览;`downloadCsv(options?)` 发起浏览器下载;`copyImage(options?)` 返回是否成功写入 PNG 剪贴板。
diff --git a/docs/curd-conventions.md b/docs/curd-conventions.md
new file mode 100644
index 00000000..8b64926d
--- /dev/null
+++ b/docs/curd-conventions.md
@@ -0,0 +1,83 @@
+# CURD interaction conventions
+
+Use these conventions when adding or changing business lists and record workflows in Ray Template. Keep short actions close to the list, give work that needs independent access or more space a dedicated page, and return users to a predictable place when the task ends. Create, Edit, and Detail each have an action container and can share the same layout.
+
+Try the [runnable examples](../apps/docs/en/guide/curd-examples.md) for a short tag form and a routed project workflow with milestones.
+
+## Choose the surface
+
+| Surface | Choose it when | Examples |
+| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| Dedicated page | The task needs its own URL for direct access, refresh, sharing, or browser history. Also use it for multistep flows, long or wide content, and editing related records or working across sections. | Configure a project, manage an order with line items, open a linked record from a notification. |
+| Drawer | A row-level task benefits from keeping its place in the list and fits in a single side-panel flow. Use it by default for list-bound detail previews and for short edits where the surrounding list provides context. | Preview a member's details or update a record's basic settings. |
+| Modal | A brief, focused task needs the user's attention and fits comfortably in one view at the intended sizes. Use it for confirmations and short forms that need little source context. | Create a tag, rename a record, confirm deletion. |
+| Inline or split view | Use inline for a small, local change that is easy to reverse. Use a split view when the user needs to interact with the list and record at the same time. | Toggle a reversible preference, inspect several rows in a master–detail view. |
+
+Check for a dedicated-page requirement first. A modal drawer preserves visual context and blocks interaction with the background. Use the same surface for Create and Edit when their workflows are comparable. A drawer preview can offer a link to the full Detail page. [Carbon form variants](https://www.carbondesignsystem.com/building-blocks/core/patterns/forms#variants)
+
+## Start and finish in context
+
+- Put Create in the list toolbar. Give each record a clear Detail entry, such as a linked name for a route or a View button for a drawer. Place Edit and less frequent actions in the row action area. Put destructive actions in its overflow menu when space or prominence calls for it.
+- Use distinct verbs for different outcomes. **Create** makes a new record, **Add** attaches an existing one, **Save changes** applies an edit, **Cancel** exits a form, and **Close** dismisses a read-only overlay. Use an object name in the title or confirmation when it helps identify the target. [Carbon common actions](https://www.carbondesignsystem.com/building-blocks/core/patterns/common-actions)
+- When Edit starts from Detail, return to Detail on cancel or after a successful save. If both fit in a drawer, replace its Detail content with the Edit container and reuse the same drawer. When editing needs a page, navigate to its route. After a save, show the updated record.
+- For Create or Edit launched from the list, return to the same list context on cancel or save. Preserve the applied filters, sort, page, and scroll position as far as the updated results allow. Open the saved record's Detail when the user has a clear next step there. Keep a successful save visible through feedback even when the current filter excludes the saved record.
+- Return focus to an overlay's opener. If the opener is gone, focus a logical surviving row or the list toolbar. After deleting a record from its Detail page, return to the list. [WAI-ARIA modal dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)
+
+## Compose the action containers
+
+The surface renders the title, content, and actions, manages scrolling, and forwards close requests. The action container owns record identity, access checks, data loading and mapping, the write command, and the destination after saving or cancelling. A shared editor owns the working draft, field validation, and the submit interaction. Expose its dirty and pending state to the action container for exit checks.
+
+| Container | Data and behavior | Visible actions |
+| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
+| Create | Initialize a fresh draft from defaults and explicit context, such as the current department. Bind the create command. | **Create**, **Cancel** |
+| Edit | Load the record by ID, capture its revision when supported, and map the response into a fresh draft. Bind the update command to that ID and revision. | **Save changes**, **Cancel** |
+| Detail | Load by ID and render readable values, labels, and sections with a description component. Offer Edit only when permitted and applicable. | **Back** on a page or **Close** in an overlay, plus **Edit** when available |
+
+Each project action container can render the same workspace, whether users enter from a route or a list action.
+
+```text
+ProjectCreate → ProjectWorkspace → ProjectEditor (defaults, create command)
+ProjectEdit → ProjectWorkspace → ProjectEditor (mapped record, bound update command)
+ProjectDetail → ProjectWorkspace → ProjectDescription (record)
+```
+
+Select the action container at the route or overlay entry point. A single page can select it from local action state such as `{ kind: 'edit', id }`. Let the container supply the title, button copy, permissions, and action-specific fields. The shared editor receives initial values, validation rules, and a save function. Compose separate field groups when Create and Edit diverge. Share labels, section layout, and value formatters between editor and Detail. Keep the containers feature-local and extract shared pieces once their contracts match across consumers.
+
+Reuse `AppPageHeader` for route pages, `RModal` or Naive UI's `NModal` for modal content, `NDrawer` with `NDrawerContent` for drawers, `RForm` with `useForm` for editors, and `NDescriptions` for labelled values. Import shared components from their feature entry points. Add interface copy in Simplified Chinese and English. [UI entry points](../harness/context/ui.md) · [Locale resources](../apps/admin/src/locales/README.md)
+
+## Routes and state ownership
+
+- Use distinct named routes for independent entries, such as `/projects`, `/projects/new`, `/projects/:id`, and `/projects/:id/edit`. Reserve action segments such as `new` from the ID namespace. Open routes inside the current browser tab by default. Register the views and use `hidden` or `sameLevel` as appropriate for parameterized pages. Choose the menu, workspace tab, breadcrumbs, and cache behavior together. [Routing contract](../apps/admin/src/router/README.md)
+- Load routed Detail and Edit from their URL identity so direct entry and reload work. Local overlays open from the list or detail page and use local state. Use an ID and the necessary shareable view state in the URL. Fetch record content through the feature API. Reset or reload when the active ID changes, including in reused route views. [Vue Router route parameters](https://router.vuejs.org/guide/essentials/dynamic-matching#reacting-to-params-changes)
+- For a page, return to the known in-app origin or use the feature's named fallback on direct entry. The fallback is the list for Create and Detail, and Detail for Edit when accessible. Use the list if Detail is unavailable. After saving, return through known history or replace the completed editing location so browser Back reaches a meaningful page.
+- Keep editor routes uncached by default. Make draft retention across workspace tabs an explicit workflow decision. Let the list own its query and selection. Encode the shareable part in route query parameters when needed and account for the shell's full-URL view keys. Clear selection when the page or applied query changes unless the feature explicitly supports cross-page selection with a visible scope and count. [Shell view keys](../packages/admin-shell/src/RouteTransition.vue)
+
+## List and detail states
+
+- Distinguish initial loading, an empty dataset, zero search matches, and load failure. Offer Create on an empty dataset when permitted, clear filters for zero matches, and a retry for failed reads. Detail and Edit also need states for a missing record and denied access. Show content and enable writes for the current, loaded record. Use list rows for summaries and IDs, and load the complete record for an editor.
+- Hide actions the user lacks permission to perform. If an otherwise available action is blocked by the record's state, give an accessible reason. Enforce authorization on the server for each read and write, including direct links and batch targets.
+
+## Editing and saving
+
+1. **Start each session or record change with its own draft and baseline.** Determine whether the draft is dirty by comparing editable values with that baseline. Keep draft mutations local to the editor. Cancel superseded reads where supported and let only the current session's results update the editor.
+2. **Use one submit path for keyboard and button actions.** Mark required fields, use visible labels, and validate on submit or after interacting with a field. Show actionable errors near their fields and focus the first invalid control or error summary on failed submission. Map the draft to a typed API input and validate it on the server as well.
+3. **Allow one submission at a time.** Show progress on the primary action and guard repeated triggers while the write is pending. Display field errors by the affected inputs and other save failures within the editor. Preserve the draft on failure. For a revision conflict, offer a way to review the latest data before resubmitting. If a timeout leaves the outcome unknown, reconcile the result or use the API's supported idempotent retry.
+4. **Show success after the write is confirmed.** Use the saved response or re-fetch the changed record. On a remote list, call the `RTablePro` instance's `reload()` to preserve the current page. It handles a page that goes out of range after deletion. Use `reload(true)` for an intentional return to page one. If refreshing fails after a successful write, report the refresh failure and offer a refresh retry. [TablePro contract](../packages/ui/src/RTablePro/README.md)
+5. **Use the same exit check for Cancel, close, Escape, navigation, and record changes.** Allow clean exits directly. For dirty drafts, offer **Keep editing** and **Discard changes**. Keep the editor in place while saving and make the pending state visible. Use route leave and update guards as applicable for page editors, and include any workspace controls that refresh or close the current editor. [Vue Router navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards)
+
+## Delete and batch actions
+
+- Use a confirmation modal for irreversible or consequential deletion and for batch deletion. Identify the record or count, state the effect on related data when relevant, and label the destructive action **Delete**. Focus the least destructive action first and disable accidental backdrop dismissal for the confirmation. Direct deletion is reserved for low-impact actions with a reliable undo. [Carbon common actions](https://www.carbondesignsystem.com/building-blocks/core/patterns/common-actions#delete) · [WAI-ARIA initial focus guidance](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)
+- Confirm and submit a snapshot of the selected IDs. Show pending feedback, refresh after confirmed changes, and remove successful targets from the selection. When the API reports partial success, report the succeeded and failed counts, keep failed eligible targets identifiable for retry, and retry only those targets. Start with current-page selection and support cross-page or all-matching selection only when its scope is explicit in both the UI and API.
+
+## Overlay and responsive behavior
+
+- Give modal surfaces an accessible name and a visible exit. On open, focus the first field for a short editor or a heading for long read-only content. Keep keyboard focus inside modal surfaces. Use one record overlay at a time. Its own confirmation may temporarily take focus and return it to the overlay when dismissed. [WAI-ARIA modal dialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)
+- Disable backdrop dismissal on editing overlays. Give the body one scroll area when content overflows and keep the actions reachable. Let drawers use the viewport width on narrow screens while preserving the same draft and exit behavior. Use semantic theme tokens and shell dimensions for any custom styling. [UI styling contract](ui-design.md#custom-css-contract)
+
+## Verify a CURD flow
+
+- Exercise the intended list entry, permissions, loading and empty states, Create, Detail, Edit, and Delete as applicable. Check success, failure, dirty cancellation, rapid record changes, and duplicate submit protection on the affected flows.
+- For a page, check direct entry, reload, Back, and return to the previous list query. For an overlay, check keyboard focus, Escape, narrow-screen scrolling, and access to actions. For bulk operations, check selection scope and the reported result.
+
+Select the affected paths and dimensions using [Harness verification](../harness/README.md#choosing-the-verification-scope).
diff --git a/docs/ui-design.md b/docs/ui-design.md
index 275b0c18..f32b1909 100644
--- a/docs/ui-design.md
+++ b/docs/ui-design.md
@@ -70,6 +70,8 @@ Use `minmax(0, 1fr)`, `min-inline-size: 0`, logical sizing/spacing, and content-
## Page composition
+Use the [CURD interaction conventions](curd-conventions.md) for business lists, record details, and editing workflows.
+
- Limit dashboard and explanatory demo content to 1360px and center it. Business tables continue to honor fluid/fixed-width layout preferences; do not narrow them globally.
- Use `DemoPage` and `HookExample`, grouped by function. Separate interactive content from expandable code. Use native details elements for code, retain keyboard operation, and provide copying.
- Hook examples use two columns when the content container reaches 900px. The layout lab uses settings/preview columns at 760px. Default to a single stacked column below those thresholds. Base decisions on available content width, not only browser-window width.
diff --git a/harness/context/ui.md b/harness/context/ui.md
index c008f040..e86f18b4 100644
--- a/harness/context/ui.md
+++ b/harness/context/ui.md
@@ -12,6 +12,8 @@ Use this topic when adding or changing pages, shared UI, themes, bilingual copy,
The application's `@/components` and some hook/directive paths retain compatibility exports. Follow exports into the owning shared package before fixing common behavior. Inject host-specific services instead of referencing application aliases from shared packages. Add both Chinese and English for new interface copy.
+For business screens, follow the [CURD interaction conventions](../../docs/curd-conventions.md) for surface selection, action containers, and list and editor behavior.
+
For custom CSS, follow the [semantic-token and scope contract](../../docs/ui-design.md#custom-css), then use the [reader recipe](../../apps/docs/guide/appearance.md#custom-css) or [independent-host example](../../apps/docs/examples/ThemeScopeExample.vue). The authoritative token definitions remain in [theme.css](../../packages/ui/src/theme.css) and its [mapping](../../packages/ui/src/theme-presets.ts); do not copy preset palettes into page styles.
Before adding a component, check existing capabilities using the [Harness reuse conventions](../README.md#engineering-conventions). For full-height content and independent scrolling, start with [TablePro height styles](../../packages/ui/src/RTablePro/src/index.scss), [layout height variables](../../packages/admin-shell/src/layout-css-vars.ts), and the [user management page](../../apps/admin/src/views/user-management/index.tsx). `RTablePro autoHeight` uses `--r-table-height` to fill its host. Naive UI's `NCard contentScrollable` and `NScrollbar` handle scrolling; the parent uses Flex/Grid and `min-block-size: 0` to provide a definite height that can shrink.
diff --git a/packages/admin-shell/src/LayoutSettings.scss b/packages/admin-shell/src/LayoutSettings.scss
index 4c9dab90..f2d0063a 100644
--- a/packages/admin-shell/src/LayoutSettings.scss
+++ b/packages/admin-shell/src/LayoutSettings.scss
@@ -15,12 +15,10 @@
.r-layout-presets {
box-sizing: border-box;
display: grid;
- grid-auto-flow: column;
- grid-auto-columns: minmax(72px, 1fr);
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 72px), 1fr));
gap: 6px;
max-inline-size: min(100%, 410px);
padding: 5px;
- overflow-x: auto;
}
.r-layout-preset {
diff --git a/packages/demo-data/src/route-catalog.json b/packages/demo-data/src/route-catalog.json
index 6c765ce2..af03dd0b 100644
--- a/packages/demo-data/src/route-catalog.json
+++ b/packages/demo-data/src/route-catalog.json
@@ -24,6 +24,26 @@
"id": "demo/context-menu",
"name": "ContextMenuDemo"
},
+ {
+ "id": "demo/curd/tags",
+ "name": "CurdTags"
+ },
+ {
+ "id": "demo/curd/projects",
+ "name": "CurdProjects"
+ },
+ {
+ "id": "demo/curd/project-create",
+ "name": "CurdProjectCreate"
+ },
+ {
+ "id": "demo/curd/project-detail",
+ "name": "CurdProjectDetail"
+ },
+ {
+ "id": "demo/curd/project-edit",
+ "name": "CurdProjectEdit"
+ },
{
"id": "demo/directive",
"name": "RDirective"
@@ -183,6 +203,10 @@
"icons": [
"action/add",
"action/adjustment",
+ "action/archive",
+ "action/bookmark",
+ "action/check",
+ "action/clipboard",
"action/close",
"action/close_all",
"action/close_left",
@@ -190,35 +214,149 @@
"action/close_right",
"action/copy",
"action/copy-image",
+ "action/crop",
+ "action/cut",
"action/delete",
"action/download",
"action/draggable",
"action/edit",
+ "action/erase",
"action/external-link",
+ "action/eye",
+ "action/eye-off",
"action/filter",
"action/fullscreen",
"action/fullscreen_fold",
+ "action/heart",
"action/link",
+ "action/link-off",
"action/lock",
+ "action/minus",
"action/more",
"action/mouse",
"action/out",
+ "action/pause",
"action/pin",
+ "action/play",
"action/print",
+ "action/redo",
"action/reload",
+ "action/save",
+ "action/scan",
"action/search",
"action/setting",
"action/shared",
+ "action/sort-ascending",
+ "action/sort-descending",
+ "action/star",
+ "action/star-filled",
+ "action/stop",
"action/table-bordered",
"action/table-striped",
+ "action/undo",
+ "action/unlock",
"action/upload",
+ "action/zoom-in",
+ "action/zoom-out",
+ "analytics/area-chart",
+ "analytics/bar-chart",
+ "analytics/bar-chart-horizontal",
+ "analytics/candlestick-chart",
+ "analytics/dashboard-gauge",
+ "analytics/data-sheet",
+ "analytics/donut-chart",
+ "analytics/line-chart",
+ "analytics/pie-chart",
+ "analytics/pulse",
+ "analytics/report",
+ "analytics/scatter-chart",
+ "analytics/target",
+ "analytics/trend-down",
+ "analytics/trend-up",
+ "commerce/bag",
+ "commerce/bank",
+ "commerce/credit-card",
+ "commerce/currency-exchange",
+ "commerce/discount",
+ "commerce/gift",
+ "commerce/invoice",
+ "commerce/order",
+ "commerce/package",
+ "commerce/shop",
+ "commerce/shopping-cart",
+ "commerce/tag",
+ "commerce/truck",
+ "commerce/wallet",
+ "communication/announcement",
+ "communication/at-sign",
+ "communication/bell",
+ "communication/bell-off",
+ "communication/chat",
+ "communication/chat-unread",
+ "communication/headset",
+ "communication/inbox",
+ "communication/mail",
+ "communication/mail-open",
+ "communication/messages",
+ "communication/microphone",
+ "communication/microphone-off",
+ "communication/phone",
+ "communication/phone-off",
+ "communication/reply",
+ "communication/send",
+ "communication/video-call",
+ "communication/voicemail",
+ "directional/arrow-down",
+ "directional/arrow-down-left",
+ "directional/arrow-down-right",
+ "directional/arrow-up",
+ "directional/arrow-up-left",
+ "directional/arrow-up-right",
+ "directional/chevron-left",
+ "directional/chevron-right",
+ "directional/chevron-up",
+ "directional/chevrons-left",
+ "directional/chevrons-right",
+ "directional/circle-down",
+ "directional/circle-up",
"directional/enter",
"directional/expanded",
"directional/left_arrow",
+ "directional/move",
"directional/resize_h",
"directional/right_arrow",
"directional/row_end",
"directional/row_head",
+ "directional/swap-horizontal",
+ "directional/vertical-sort",
+ "files/book",
+ "files/book-open",
+ "files/books",
+ "files/camera",
+ "files/cloud-download",
+ "files/cloud-upload",
+ "files/file-add",
+ "files/file-archive",
+ "files/file-audio",
+ "files/file-check",
+ "files/file-code",
+ "files/file-gif",
+ "files/file-jpg",
+ "files/file-lock",
+ "files/file-pdf",
+ "files/file-presentation",
+ "files/file-search",
+ "files/file-spreadsheet",
+ "files/file-text",
+ "files/file-video",
+ "files/file-word",
+ "files/folder",
+ "files/folder-add",
+ "files/folder-open",
+ "files/folder-search",
+ "files/image",
+ "files/paperclip",
+ "files/video",
"logo/axios",
"logo/github",
"logo/google",
@@ -226,31 +364,89 @@
"logo/twitter",
"navigation/appearance",
"navigation/barcode",
+ "navigation/building",
+ "navigation/calendar",
+ "navigation/calendar-check",
+ "navigation/calendar-date",
+ "navigation/cards",
+ "navigation/compass",
"navigation/components",
"navigation/dashboard",
"navigation/database",
"navigation/document",
"navigation/echart",
+ "navigation/flag",
"navigation/flow",
"navigation/form",
+ "navigation/globe",
+ "navigation/grid",
+ "navigation/home",
"navigation/icons",
+ "navigation/layers",
"navigation/layout",
+ "navigation/list",
+ "navigation/map",
+ "navigation/map-pin",
"navigation/menu",
"navigation/other",
+ "navigation/panel-grid",
"navigation/qr_code",
"navigation/rely",
"navigation/routing",
"navigation/table",
+ "navigation/timeline",
+ "navigation/tree",
"navigation/window",
+ "navigation/workbench",
+ "status/blocked",
"status/error",
+ "status/info",
+ "status/loading",
+ "status/pending",
"status/question",
"status/success",
"status/warning",
+ "system/battery",
+ "system/bluetooth",
+ "system/bug",
+ "system/cloud-storage",
+ "system/code",
+ "system/code-brackets",
+ "system/command",
+ "system/cpu",
"system/dark",
+ "system/desktop",
+ "system/fingerprint",
+ "system/hard-drive",
+ "system/key",
"system/language",
"system/light",
+ "system/mobile",
+ "system/network",
+ "system/plug",
+ "system/power",
+ "system/puzzle",
+ "system/server",
+ "system/shield",
+ "system/shield-check",
"system/system_os",
- "system/watermark"
+ "system/tablet",
+ "system/terminal",
+ "system/watermark",
+ "system/wifi",
+ "users/contact",
+ "users/handshake",
+ "users/id-card",
+ "users/organization",
+ "users/team",
+ "users/user",
+ "users/user-add",
+ "users/user-circle",
+ "users/user-location",
+ "users/user-remove",
+ "users/user-search",
+ "users/user-shield",
+ "users/users"
],
"iconAliases": {
"action/export_excel": "action/download",
diff --git a/packages/demo-data/src/routes.json b/packages/demo-data/src/routes.json
index 75c55d65..d53e0ee2 100644
--- a/packages/demo-data/src/routes.json
+++ b/packages/demo-data/src/routes.json
@@ -154,6 +154,48 @@
}
]
},
+ {
+ "path": "/curd",
+ "meta": {
+ "i18nKey": "menu.CurdExamples",
+ "icon": "navigation/form",
+ "order": 18
+ },
+ "children": [
+ {
+ "path": "tags",
+ "name": "CurdTags",
+ "component": "demo/curd/tags",
+ "meta": { "i18nKey": "menu.CurdTags" }
+ },
+ {
+ "path": "projects",
+ "name": "CurdProjects",
+ "component": "demo/curd/projects",
+ "meta": { "i18nKey": "menu.CurdProjects" }
+ },
+ {
+ "path": "projects/new",
+ "name": "CurdProjectCreate",
+ "component": "demo/curd/project-create",
+ "meta": { "i18nKey": "menu.CurdProjectCreate", "sameLevel": true }
+ },
+ {
+ "path": "projects/:id",
+ "name": "CurdProjectDetail",
+ "component": "demo/curd/project-detail",
+ "props": true,
+ "meta": { "i18nKey": "menu.CurdProjectDetail", "sameLevel": true }
+ },
+ {
+ "path": "projects/:id/edit",
+ "name": "CurdProjectEdit",
+ "component": "demo/curd/project-edit",
+ "props": true,
+ "meta": { "i18nKey": "menu.CurdProjectEdit", "sameLevel": true }
+ }
+ ]
+ },
{
"path": "/examples/components",
"meta": {
diff --git a/packages/ui/src/RTablePro/README.md b/packages/ui/src/RTablePro/README.md
index e7bf9fb0..45f10ec9 100644
--- a/packages/ui/src/RTablePro/README.md
+++ b/packages/ui/src/RTablePro/README.md
@@ -25,7 +25,7 @@ import { RTablePro } from '@/components'
- 普通模式按 Naive UI 卡片组织搜索、表头工具、数据与页脚。搜索区在结果上方;`bare` 保留纯表格外观。表格左上方可用 `title` 传文字,或用同名插槽放筛选开关、快捷操作等;都不传时不占位。`toolbar` 插槽和默认工具集中在表格右上方。
- 行标识默认取 `row.id` 或 `row.key`,其他字段使用 `rowKey`。宽表可设置 `scrollX` 和列宽,横向滚动留在表格内部。根列拖动或固定时保留分组的子列。
- `autoHeight` 默认使用当前布局的可用高度,宿主外部使用视口高度;嵌入特定区域时可以用 CSS 变量 `--r-table-height` 覆盖。较短的屏幕保留表格的最小操作高度。
-- 只接收最新的请求结果。切换请求源或有效筛选条件会立即清空旧行和总数;切页或修改每页条数会隐藏旧行并保留同一范围的总数。当前页未加载时,实例取数返回空、底层实例返回 `null`,CSV 和打印不会启动。请求失败后显示空态并清空总数,通过宿主 Toast 提醒。可用 `onRequestError` 接收详情、用实例 `reload()` 重试,或显式提供 `error` 插槽接管提示。
+- 只接收最新的请求结果。切换请求源或有效筛选条件会立即清空旧行和总数;切页或修改每页条数会隐藏旧行并保留同一范围的总数。当前页未加载时,实例取数返回空、底层实例返回 `null`,CSV 和打印不会启动。请求失败后清空行与总数,在表格中显示错误和重试按钮。可用 `onRequestError` 接收详情、用实例 `reload()` 重试,或提供 `error` 插槽自定义反馈。应用筛选后无结果时,默认显示无匹配提示,并为内置筛选提供重置操作。
- 需要实例时使用 `shallowRef()`。实例提供 `reload(resetPage?)`、`setPage`、`setPageSize`、`getCurrentPageData`、`downloadCsv`、`print`、`copyImage` 和 `getTableInstance`。额外区域可用 `toolbar`、`tableFooter`、`tableAction` 插槽。
- 工具栏将业务 `toolbar` 插槽与内置工具分组。`request` 模式提供刷新,列设置、复制图片和全屏保持直接入口;「更多操作」统一收纳密度、斑马纹、边框与 CSV。斑马纹和边框的功能图标始终显示,选中状态在文字右侧单独标记;密度子菜单只保留文字和选中标记。TablePro 的 `size` 默认是 `medium`(标准),菜单与表格共用该值;传入 `small` 或 `large` 时分别选中紧凑或宽松。打印默认隐藏,设置 `showPrint` 后出现在该菜单。`tool={false}` 隐藏全部内置工具,仍保留业务插槽。
diff --git a/packages/ui/src/RTablePro/src/TablePro.tsx b/packages/ui/src/RTablePro/src/TablePro.tsx
index 31d14d69..e6cc4751 100644
--- a/packages/ui/src/RTablePro/src/TablePro.tsx
+++ b/packages/ui/src/RTablePro/src/TablePro.tsx
@@ -1,5 +1,6 @@
import { call } from '@ray-template/composables/vue/call'
import { isEqual } from 'lodash-es'
+import { NButton, NEmpty } from 'naive-ui'
import type { PaginationProps } from 'naive-ui'
import {
computed,
@@ -12,7 +13,6 @@ import {
watch,
} from 'vue'
import type { ExtractPublicPropTypes, PropType } from 'vue'
-import { useUiServices } from '../../services'
import Search from './components/Search'
import type { TableSearchFormInst } from './components/Search'
import { useTableLocale } from './locale'
@@ -123,7 +123,6 @@ export default defineComponent({
},
setup(props, { attrs, slots, expose, emit }) {
const { t } = useTableLocale()
- const { reportError } = useUiServices()
const table = shallowRef()
const searchForm = useTemplateRef('searchForm')
const customFilters = ref(!!slots.filters)
@@ -261,11 +260,7 @@ export default defineComponent({
? { page: page.value, pageSize: pageSize.value }
: void 0,
updatePage,
- reportError: (error) => {
- emit('request-error', error)
-
- if (!slots.error) reportError?.(t('requestError'))
- },
+ reportError: (error) => emit('request-error', error),
})
const reload = (resetPage = false) => {
if (resetPage) updatePage(1)
@@ -481,7 +476,40 @@ export default defineComponent({
return () => {
const { request, search, loading: externalLoading, remote } = props
- const { filters, error, notice, ...panelSlots } = slots
+ const { filters, error, notice, empty, ...panelSlots } = slots
+ const failed = !!request && requestPhase.value === 'failed'
+ const loading = requestPhase.value === 'loading' || externalLoading
+ const searched = Object.keys(applied.value.values).length > 0
+ let renderEmpty = empty
+
+ if (failed && error) renderEmpty = () => []
+ else if (failed || (!loading && !empty && searched)) {
+ renderEmpty = () => [
+
+ {{
+ default: () => (
+
+ {t(failed ? 'requestError' : 'noMatches')}
+
+ ),
+ extra: () =>
+ failed ? (
+ void reload()}>
+ {t('retry')}
+
+ ) : searchFields.value.length ? (
+ void instance.resetSearch()}
+ >
+ {t('resetFilters')}
+
+ ) : null,
+ }}
+ ,
+ ]
+ }
+
const paginationProps: false | PaginationProps =
pagination.value === false
? false
@@ -510,7 +538,7 @@ export default defineComponent({
}
rowActionsDisabled={!!request && !activeResult.value}
reload={request ? reload : void 0}
- loading={requestPhase.value === 'loading' || externalLoading}
+ loading={loading}
pagination={paginationProps}
onUpdatePage={setPage}
onUpdatePageSize={setPageSize}
@@ -536,10 +564,8 @@ export default defineComponent({
/>
)
: void 0,
- notice:
- requestPhase.value === 'failed' && error
- ? () => error({ reload })
- : notice,
+ empty: renderEmpty,
+ notice: failed && error ? () => error({ reload }) : notice,
}}
)
diff --git a/packages/ui/src/RTablePro/src/components/Search.tsx b/packages/ui/src/RTablePro/src/components/Search.tsx
index 7a626ee6..27e1cbdd 100644
--- a/packages/ui/src/RTablePro/src/components/Search.tsx
+++ b/packages/ui/src/RTablePro/src/components/Search.tsx
@@ -67,7 +67,14 @@ export default defineComponent({
const wrapper = useTemplateRef('wrapper')
const form = useTemplateRef('form')
const { width } = useElementSize(wrapper)
- const collapsed = ref(props.options?.defaultCollapsed ?? false)
+ const chosenCollapsed = ref()
+ const collapsed = computed({
+ get: () =>
+ chosenCollapsed.value ?? props.options?.defaultCollapsed ?? false,
+ set: (value) => {
+ chosenCollapsed.value = value
+ },
+ })
const measuredColumns = computed(() =>
Math.min(
gridSize(props.options?.maxColumns, 4),
diff --git a/packages/ui/src/RTablePro/src/en-US.json b/packages/ui/src/RTablePro/src/en-US.json
index f4e48f92..56a81eab 100644
--- a/packages/ui/src/RTablePro/src/en-US.json
+++ b/packages/ui/src/RTablePro/src/en-US.json
@@ -33,6 +33,8 @@
"total": "{count} records",
"clearSelection": "Clear selection ({count})",
"requestError": "Couldn't load the data",
+ "noMatches": "No results match the filters",
+ "resetFilters": "Reset filters",
"retry": "Retry",
"density": "Table density",
"compact": "Compact",
diff --git a/packages/ui/src/RTablePro/src/zh-CN.json b/packages/ui/src/RTablePro/src/zh-CN.json
index 9dffc815..7f7045e8 100644
--- a/packages/ui/src/RTablePro/src/zh-CN.json
+++ b/packages/ui/src/RTablePro/src/zh-CN.json
@@ -33,6 +33,8 @@
"total": "共 {count} 条",
"clearSelection": "清除已选({count})",
"requestError": "数据加载失败",
+ "noMatches": "没有符合筛选条件的数据",
+ "resetFilters": "重置筛选",
"retry": "重试",
"density": "表格密度",
"compact": "紧凑",