docs: refresh project overview and screenshots

This commit is contained in:
XiaoDaiGua-Ray 2026-11-06 16:29:00 +08:00
parent 50506cda2b
commit 22c9f55f27
No known key found for this signature in database
7 changed files with 206 additions and 182 deletions

194
README.md
View File

@ -1,54 +1,109 @@
# Ray Template · Vue 3 Admin Dashboard Template
# Ray Template
[简体中文](README.zh-CN.md) · **[Live demo](https://xiaodaigua-ray.github.io/ray-template/)** · **[Documentation](https://xiaodaigua-ray.github.io/ray-template/docs/)** · [Quick start](#quick-start)
**Four visual styles. Five navigation layouts. A Vue 3 workspace you can make your own.**
Ray Template is an **open-source, ready-to-run frontend template** for admin dashboards, back-office tools, and internal apps. Run the demo to try a workspace with role-based menus and page tabs, then reuse TablePro list pages, workspace layouts, and route modules in your own app.
[简体中文](README.zh-CN.md) · **[Live demo](https://xiaodaigua-ray.github.io/ray-template/)** · **[Documentation](https://xiaodaigua-ray.github.io/ray-template/docs/)** · [Quick start](#quick-start) · [Architecture](#one-workspace-shared-building-blocks)
**Ray Template 6.0.0 starts a new major version.** It organizes Ray Admin, the documentation site, and reusable packages in one workspace. v6 does not offer an in-place upgrade from v5 or guarantee compatibility with v5 imports, APIs, deployment settings, or browser data. Existing projects can stay on [legacy/v5](https://github.com/XiaoDaiGua-Ray/ray-template/tree/legacy/v5), the final v5 main snapshot at `6f095b7` with manifest version `5.2.5`, or use the existing [v5.2.4 tag](https://github.com/XiaoDaiGua-Ray/ray-template/tree/v5.2.4).
Ray Template is an open-source frontend template for admin dashboards, operations consoles, and internal tools. It brings together a working application, reusable packages, and interactive documentation. Start with the demo, choose a look, and connect your business APIs.
[v6 architecture and adoption guide](apps/docs/guide/architecture.md) · [Version boundaries](apps/docs/migration.md)
**4 visual styles · 5 navigation layouts · 11 TablePro examples · 9 shared packages**
**Stack**: Vue 3 · TypeScript / TSX · Naive UI · Vue Router · Pinia · Vue I18n · Vite / Rolldown · Axios · Vitest
[![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/welcome-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/dashboard)
[![Ray Template's TablePro people directory with search, pagination, column settings, and sidebar navigation](docs/assets/tablepro-preview.jpg)](https://xiaodaigua-ray.github.io/ray-template/)
[![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/table-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/tables/auto-height)
Sign in with the prefilled form. Open **Tables → Remote search and pagination** to try the list shown above, or **Layout playground** to experiment with the workspace.
_The complete welcome page · Default Modern style · Light mode._
## Core features
## Choose your look and layout
### TablePro for simple tables and data-heavy pages
### Four styles across the interface
Use `RTablePro` with `bare` for a plain table, or add search, pagination, and a toolbar for a full list page. Column definitions, selection, sorting, and custom cells follow Naive UI DataTable.
| Style | Character |
| ------------ | ------------------------------------------------------------------------ |
| **Modern** | Blue accents, balanced spacing, and soft corners. The default workspace. |
| **Naive UI** | Native controls, familiar proportions, and green accents. |
| **Material** | Tonal surfaces, larger corners, and capsule-shaped buttons. |
| **Plain** | Neutral colors, compact corners, and flat surfaces. |
- **Search and pagination**: Pass local `data` or a `request(params, signal)` function that returns `{ data, total }`. Remote queries accept only the latest result. A failed query keeps existing rows visible and lets users retry.
- **Long lists and column controls**: Fill the available workspace and use virtual scrolling for large lists. Users can show, hide, reorder, or pin columns. Set `columnStateKey` to remember hidden columns across reloads.
- **CSV and printing**: Export or print the current page's visible data columns by default. Point printing at a custom region for documents that need their own layout.
Styles cover the shell, controls, tables, and chart themes. Each supports light and dark modes; follow the system or choose a mode yourself. Customize the primary color and export or import your preferences as JSON.
[TablePro API and data contract](packages/ui/src/RTablePro/README.md)
![The complete Ray Admin welcome page in Modern dark mode, using the same layout as the light version](docs/assets/readme/welcome-modern-dark.png)
### A configurable workspace
[![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/table-modern-dark.png)](https://xiaodaigua-ray.github.io/ray-template/#/tables/auto-height)
Switch between sidebar, top, and mixed navigation. Narrow screens use a menu drawer. The workspace supports fixed or fluid width, a pinned header and footer, and a maximized content area. Pinia saves layout preferences. Try changes live in the layout playground or use named slots to replace the header, sidebar, tabs, and footer.
_The same welcome page in Modern dark mode._
Page tabs keep multiple tasks open, and breadcrumbs show where you are. Find menu items with `⌘/Ctrl + K`, and switch between light and dark themes or English and Simplified Chinese.
### Five ways to organize the workspace
[Layout playground source](apps/admin/src/views/demo/layout-demo.tsx) · [Layout configuration and slots](apps/admin/src/layout/README.md)
**Side · Top · Mixed · Right · Split**
### HTTP route configuration connects pages, menus, and permissions
Keep navigation in a sidebar, move it to the top or right, or separate top-level groups from their child menus. Choose fluid or centered content, adjust spacing, and pin the header or footer. Narrow screens use a menu drawer.
Register the page component ID in `apps/admin/src/router/config/views.ts`, then return its route record from the API to generate navigation and breadcrumbs. Initial demo records live in `apps/admin/src/mocks/data/routes.json`. Route metadata controls menu labels and icons, roles, visibility, and `keepAlive`. Detail pages can extend the breadcrumb while keeping the current menu and tab. Role checks cover both menu filtering and direct navigation. Connect your backend to validate sessions and authorize API requests.
Page tabs, KeepAlive, breadcrumbs, `⌘/Ctrl + K` search, content maximization, page transitions, and English / Simplified Chinese are built in. Layout, appearance, and menu preferences update live and persist in the browser.
[Routing guide](apps/admin/src/router/README.md) · [Nested navigation and caching example](apps/admin/src/mocks/data/routes.json)
[Appearance and theme tokens](apps/docs/guide/appearance.md) · [Layout playground](apps/docs/guide/layout.md) · [Shell integration](apps/admin/src/layout/README.md)
### Reusable components, composables, and SVG icons
## TablePro, ready for business workflows
- **Components**: Start with `RForm` and `RModal` for forms and dialogs. `RChart` manages ECharts initialization, resizing, and theme changes. The demo also includes LogicFlow diagrams, barcodes, and draggable cards. [Component guide](apps/admin/src/components/README.md)
- **Composables**: Template hooks cover page refresh, content maximization, menu badges, and watermarks. Web hooks demonstrate screenshots, printing, and element fullscreen. The examples include expandable usage code. [Composables and examples](apps/admin/src/hooks/README.md)
- **SVG icons**: Add an SVG to a group under `packages/icons/src` to generate typed names and sprites. Routes and `RIcon` share names such as `navigation/dashboard`. The icon gallery lets you browse by group and copy TSX usage. [SVG icon workflow](packages/icons/src/A_README.md)
Use `RTablePro` for a plain table, a searchable directory, or a dense operations page. Column definitions and custom cells follow Naive UI DataTable.
- **Search that grows with the page.** Text, numbers, multiple selection, dates, trees, cascades, and custom fields; validation, dependent remote options, and manual or debounced submission.
- **Local and remote data.** Local filtering, component-managed requests, or pagination controlled by the page. Remote queries accept only the latest result and forward cancellation signals.
- **A usable data workspace.** Automatic height, virtual scrolling, column visibility, reordering, pinning, and stored column preferences.
- **Everyday tools.** Copy the table as a PNG, export CSV, print a table or custom region, and add row menus or toolbar actions.
- **Control from your page.** `useTablePro` exposes search, pagination, current-page data, and request state. Selection stays in the page's controlled row keys.
Failed queries clear the failed result and report the error; users can query again or reload. The examples cover success, cancellation, and failure recovery.
Explore [11 runnable examples](https://xiaodaigua-ray.github.io/ray-template/docs/reference/table-pro-examples.html), including advanced search, controlled pagination, column settings, printing, and instance hooks. Each includes the source that actually runs.
[TablePro API](apps/docs/reference/table-pro.md) · [Component contract](packages/ui/src/RTablePro/README.md) · [First business page](apps/docs/guide/first-page.md)
## A working application to build on
| Area | Included |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **Users and organizations** | Organization tree, member search, create/edit/detail flows, account status, roles, and permission-aware actions. |
| **Routes and permissions** | Visual and JSON route editors, menu generation, role-based navigation, direct-route guards, and page caching. |
| **Forms and dialogs** | `RForm`, `useForm`, and `RModal` with validation, reset, loading, and runnable examples. |
| **Charts and interaction** | ECharts lifecycle and theme handling, LogicFlow, draggable cards, context menus, screenshots, printing, and fullscreen. |
| **Icons and utilities** | Typed SVG names and generated sprites, QR codes, barcodes, precision arithmetic, storage helpers, composables, and directives. |
| **Documentation** | Guides, API references, and interactive examples using the same workspace packages as the application. |
The demo uses **MSW HTTP mocks** for login, users, routes, and example data, both in development and on the static hosted site. To connect a backend, set `VITE_API_BASE_URL` and `VITE_API_MOCK=false`. Shared schemas and generated **OpenAPI 3.1** describe the contract; your backend owns real sessions and API authorization.
[Backend integration](apps/docs/guide/backend.md) · [Routing guide](apps/admin/src/router/README.md) · [Components](apps/docs/reference/components.md) · [Composables](apps/docs/reference/hooks.md)
## One workspace, shared building blocks
Ray Admin and the documentation live in one **pnpm monorepo**. Business integration stays in the application; reusable capabilities have explicit package entry points.
```mermaid
flowchart TB
Admin["Ray Admin · apps/admin"]
Docs["Interactive docs · apps/docs"]
Shared["9 shared workspace packages"]
UI["Interface: ui · admin-shell"]
Interaction["Interaction: composables · directives · icons"]
Data["Data: http · api-contracts · routing · utils"]
Admin --> Shared
Docs --> Shared
Shared --> UI
Shared --> Interaction
Shared --> Data
```
- **[apps/admin](apps/admin)** owns pages, sessions, Pinia, route registration, API integration, and mocks.
- **[apps/docs](apps/docs)** runs shared components and embeds application examples from the same build.
- **[packages](packages)** exposes public `exports`; boundary checks validate imports, declared dependencies, and cycles. These are workspace packages, not separately published npm packages.
Semantic theme tokens let custom pages follow the selected style, mode, and primary color. The shell exposes runtime layout dimensions and slots for the header, sidebar, tabs, footer, and content.
[Architecture map](docs/architecture.md) · [API contracts](packages/api-contracts/README.md) · [Custom CSS contract](docs/ui-design.md#custom-css-contract)
## Quick start
Use the pinned **Node.js 26.13.0** and **pnpm 12.16.1**. With nvm:
Use **Node.js 26.13.0** and **pnpm 12.16.1**, as pinned in the repository.
```sh
git clone https://github.com/XiaoDaiGua-Ray/ray-template.git
@ -60,78 +115,35 @@ pnpm install --frozen-lockfile
pnpm dev
```
Open [http://127.0.0.1:9527/ray-template/](http://127.0.0.1:9527/ray-template/) or use the URL printed by Vite. The prefilled demo sign-in and mock data let you run the template before connecting a backend.
Open [http://127.0.0.1:9527/ray-template/](http://127.0.0.1:9527/ray-template/) and click **Continue with demo account**. The login page also offers manager and read-only accounts. No business backend is needed to explore the demo.
Run `pnpm docs:dev` to develop the [documentation and interactive examples](apps/docs/README.md) from the same checkout.
1. **Try the interface.** Open Settings to change styles and layouts, then explore Users and TablePro.
2. **Build a page.** Start with an [existing example](apps/admin/src/views/demo), register its view ID, and add a route with bilingual menu labels.
3. **Connect your API.** Keep the page contract and connect your backend using the [integration guide](apps/docs/guide/backend.md).
## Project structure
## Development and delivery
```text
ray-template/
├── apps/
│ ├── admin/ # Ray Admin: pages, sessions, permissions, env and mocks
│ └── docs/ # VitePress: guides, API reference and live examples
├── packages/
│ ├── admin-shell/ # Layout, navigation, tabs, settings and transitions
│ ├── ui/ # TablePro, RBarcode, RChart and other shared components
│ ├── composables/ # Reusable Vue composables and browser helpers
│ ├── directives/ # Vue directives
│ ├── icons/ # SVG assets, icon names and manifest
│ ├── routing/ # Route schemas, validation and menu helpers
│ ├── http/ # HTTP clients, interceptors and request cancellation
│ └── utils/ # Precision, object and storage utilities
├── harness/ # Regression checks and local reports
└── pnpm-lock.yaml # Shared workspace lockfile
```
**Vue 3 · TypeScript / TSX · Naive UI · Vite / Rolldown · Pinia · Vue Router · Vue I18n · Axios · MSW · Vitest**
Ray Admin starts in `apps/admin/src/main.ts`. Its `App.tsx` supplies theme, translations, icons, and column preference storage. Shared packages expose public entry points through `exports`. The documentation runs the same packages. The [TablePro demo](apps/docs/reference/table-pro.md) uses simulated requests to show cancellation and retry, while the [layout playground](apps/docs/guide/layout.md) runs with its own in-memory router.
| Command | Purpose |
| ------------------------------ | ------------------------------------------------------------------------------------------------------ |
| `pnpm dev` / `pnpm docs:dev` | Develop the application or documentation. |
| `pnpm build` / `pnpm preview` | Build or preview the admin application. |
| `pnpm pages:build` | Assemble the admin and documentation into `dist/pages`. |
| `pnpm harness context <scope>` | Find the implementation, contracts, and relevant checks. |
| `pnpm harness verify <scope>` | Run checks for the affected area and save a report. |
| `pnpm check` | Check the environment, contracts, package boundaries, types, lint, formatting, tests, and both builds. |
See the [architecture map](docs/architecture.md) for how these modules work together.
CI is configured for **Linux, Windows, and macOS**. The [task index](llms.txt) and [AI Harness](harness/README.md) provide navigable engineering context for maintainers and coding agents.
## Build your first business page
Default deployment paths are `/ray-template/` for the admin and `/ray-template/docs/` for documentation. See [deployment guidance](docs/architecture.md#deployment-and-search-discovery) before changing the base paths.
This small people directory uses the template's mock query function. To adapt it for orders or inventory, replace the columns, search fields, and request function.
## Version boundaries
```tsx
import { getPersonList } from '@/api/demo/mock/person'
import { RTablePro } from '@ray-template/ui/table-pro'
import { defineComponent } from 'vue'
**v6 introduces the monorepo architecture.** It does not provide an in-place upgrade from v5 or guarantee compatibility with v5 imports, APIs, deployment settings, or browser data.
export default defineComponent({
setup() {
return () => (
<RTablePro
columns={[
{ title: 'Name', key: 'name' },
{ title: 'Email', key: 'email' },
]}
request={getPersonList}
search={[{ key: 'name', label: 'Name' }]}
columnStateKey="demo:people"
/>
)
},
})
```
Existing projects can stay on [legacy/v5](https://github.com/XiaoDaiGua-Ray/ray-template/tree/legacy/v5), the final v5 main snapshot `6f095b7` with manifest version `5.2.5`, or use the [v5.2.4 tag](https://github.com/XiaoDaiGua-Ray/ray-template/tree/v5.2.4). Read the [migration notes](apps/docs/migration.md) before adopting v6.
1. **Build the view.** Add a page in `apps/admin/src/views`. The [remote table example](apps/admin/src/views/demo/tables/remote.tsx) shows sorting, row selection, and toolbar actions.
2. **Connect navigation.** Register the page component ID and add its route to the Mock JSON or your backend response, with English and Simplified Chinese menu labels. Follow the [routing guide](apps/admin/src/router/README.md) when setting up page caching.
3. **Connect your data.** Define your API in `apps/admin/src/api`, use `apps/admin/src/axios` for interceptors and request cancellation, and connect your real sign-in and session. Development and static previews use the same HTTP Mock API. The [backend contract](apps/docs/guide/backend.md) includes authentication, permission codes, users, routes, and a generated OpenAPI specification. [Request layer guide](apps/admin/src/axios/README.md)
---
## Checks, builds, and deployment
| Command | What it does |
| ----------------------------- | --------------------------------------------------------------------------------------------- |
| `pnpm test:run` | Run the Vitest suite |
| `pnpm check` | Run the same checks as CI, including types, lint, formatting, tests, and a production build |
| `pnpm harness context` | Find entry points and checks for areas such as routing, UI, and APIs |
| `pnpm harness verify <scope>` | Run targeted checks and save a local report; use `all` for full integration or release checks |
| `pnpm build` / `pnpm preview` | Build into `dist/production` or serve the build locally |
`pnpm docs:build` builds the documentation separately. `pnpm pages:build` assembles both builds under `dist/pages` for `/ray-template/` and `/ray-template/docs/`.
Use the [architecture map](docs/architecture.md) to find module and configuration entry points. See the [deployment guide](docs/architecture.md#deployment-and-search-discovery) for root or subpath hosting and search metadata. Contributors and coding agents share the instructions in [AGENTS.md](AGENTS.md) and the [AI Harness](harness/README.md).
[MIT License](LICENSE) · [Changelog](CHANGELOG.md) · [Issues](https://github.com/XiaoDaiGua-Ray/ray-template/issues)
Use the [task index](llms.txt) to find the owning implementation, its consumers, and verification steps without installing dependencies. `pnpm harness context <scope>` shows the same index entry alongside the commands it runs.
[MIT License](LICENSE) · [Changelog](CHANGELOG.md) · [Report an issue](https://github.com/XiaoDaiGua-Ray/ray-template/issues) · [Contributor guidance](AGENTS.md)

View File

@ -1,54 +1,109 @@
# Ray Template · Vue 3 中后台管理模板
# Ray Template
[English](README.md) · **[在线演示](https://xiaodaigua-ray.github.io/ray-template/)** · **[在线文档](https://xiaodaigua-ray.github.io/ray-template/docs/)** · [快速开始](#快速开始)
**四种视觉风格,五种导航布局,把中后台做得顺手,也做得好看。**
Ray Template 是一套**开箱即用的中后台前端模板**,适合搭建管理后台、运营工作台和内部工具。克隆后即可体验带权限菜单和多标签页的工作台,也可以直接把 TablePro 列表页、布局和路由模块用在业务里。
[English](README.md) · **[在线演示](https://xiaodaigua-ray.github.io/ray-template/)** · **[在线文档](https://xiaodaigua-ray.github.io/ray-template/docs/)** · [快速开始](#快速开始) · [架构设计](#monorepo-架构)
**Ray Template 6.0.0 是新的主版本。** v6 以 Monorepo 组织 Ray Admin、官网文档和共享包。它不承诺兼容 v5 的内部导入、接口、部署配置或浏览器数据,也不提供原地升级。现有 v5 项目可以继续使用 [legacy/v5](https://github.com/XiaoDaiGua-Ray/ray-template/tree/legacy/v5)(最后的 v5 主线快照 `6f095b7`,清单版本 `5.2.5`),或使用已打标签的 [v5.2.4](https://github.com/XiaoDaiGua-Ray/ray-template/tree/v5.2.4)。
Ray Template 是基于 Vue 3、TypeScript / TSX 和 Naive UI 的开源中后台模板,适合管理后台、运营工作台和内部工具。完整应用、共享包和交互文档放在同一工作区,克隆即可运行,再按业务调整界面、页面和接口。
[版本分界与接入说明](apps/docs/migration.md) · [v6 架构指南](apps/docs/guide/architecture.md)
**4 种视觉风格 · 5 种导航布局 · 11 个 TablePro 示例 · 9 个共享包**
**技术栈**:Vue 3 · TypeScript / TSX · Naive UI · Vue Router · Pinia · Vue I18n · Vite / Rolldown · Axios · Vitest
[![默认 Modern 浅色风格的完整欢迎页,展示侧边导航和工作空间概览](docs/assets/readme/welcome-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/dashboard)
[![Ray Template 的 TablePro 人员列表,展示查询表单、分页、列设置及侧栏导航](docs/assets/tablepro-preview.jpg)](https://xiaodaigua-ray.github.io/ray-template/)
[![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/table-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/tables/auto-height)
用演示页预填的表单登录,在「表格 → 远端查询与分页」可以体验图中的列表,或打开「布局实验室」调整工作台。
_完整欢迎页 · 默认 Modern 风格 · 浅色主题。_
## 核心能力
## 风格与布局
### TablePro:从纯表格到业务列表
### 四种风格,覆盖整套界面
同一个 `RTablePro` 可以用 `bare` 只渲染表格,也可以接入搜索、分页和工具栏。列定义、行选择、排序和自定义单元格沿用 Naive UI DataTable 的写法。
| 风格 | 视觉特点 |
| ------------------- | ---------------------------------------------- |
| **Modern · 现代化** | 蓝色主调、适度留白与柔和圆角,作为默认工作台。 |
| **Naive UI · 原生** | 保留组件库的原生控件、比例与绿色主调。 |
| **Material** | 带色阶的面板、更大的圆角与胶囊按钮。 |
| **Plain · 朴素** | 中性色、小圆角与平面化界面。 |
- **查询和分页**:传入本地数据 `data`,或提供返回 `{ data, total }` 的 `request(params, signal)`。远端模式只接收最新请求的结果,失败时保留已有数据并提供重试。
- **长列表和列设置**:表格可填充工作区,配合虚拟滚动;用户可调整列的显示、顺序和固定位置,通过 `columnStateKey` 跨刷新记住隐藏列。
- **导出与打印**:默认导出和打印当前页的可见数据列。报表、单据等独立排版可指定自定义打印区域。
风格会应用到布局外壳、控件、表格与图表主题。每种风格都支持浅色和深色,可以手动选择或跟随系统;主题色可以自定义,偏好配置支持 JSON 导入与导出。
[TablePro 用法与数据契约](packages/ui/src/RTablePro/README.md)
![Modern 深色主题下的完整欢迎页,与浅色版本使用相同布局](docs/assets/readme/welcome-modern-dark.png)
### 应用外壳:适配不同的后台工作方式
[![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/table-modern-dark.png)](https://xiaodaigua-ray.github.io/ray-template/#/tables/auto-height)
侧栏、顶部、混合导航可切换,窄屏自动改用菜单抽屉。工作区支持定宽或铺满、顶栏与页脚固定、内容最大化;用户的布局偏好由 Pinia 保存。可以在布局实验室实时调试,也可以用具名插槽替换顶栏、侧栏、标签栏和页脚。
_相同的欢迎页与布局,切换至 Modern 深色主题。_
标签页可在多个页面之间切换,面包屑标示当前位置,用 `⌘/Ctrl + K` 可以查找菜单。全局提供明暗主题和中英文切换。
### 五种导航,适配不同工作方式
[布局实验室源码](apps/admin/src/views/demo/layout-demo.tsx) · [布局配置与插槽](apps/admin/src/layout/README.md)
**侧边导航 · 顶部导航 · 混合导航 · 右侧导航 · 通栏分组**
### 路由模块:把页面、菜单与权限放在同一处配置
菜单可以放在左侧、顶部或右侧,也可以将一级分组与子菜单分开。工作区支持流式铺满、定宽居中、间距调整和顶栏/页脚固定,窄屏自动使用菜单抽屉。
先在 `apps/admin/src/router/config/views.ts` 登记页面组件 ID,再由接口返回路由记录,模板据此生成菜单和面包屑。Mock 初始记录位于 `apps/admin/src/mocks/data/routes.json`。路由 `meta` 可以配置菜单文案与图标、角色、显示条件和 `keepAlive`。从列表进入详情时,可以保留当前菜单和标签页,只在面包屑中补充详情层级。角色配置同时用于菜单过滤和直接导航时的守卫。接入业务时,由后端校验会话与接口权限。
多标签页、KeepAlive、面包屑、`⌘/Ctrl + K` 全局搜索、内容最大化和页面动效均已接入,提供中英文切换。布局、外观和菜单偏好即时生效,并保存在当前浏览器。
[路由与菜单约定](apps/admin/src/router/README.md) · [多级菜单与缓存示例](apps/admin/src/mocks/data/routes.json)
[主题与样式变量](apps/docs/guide/appearance.md) · [布局实验室](apps/docs/guide/layout.md) · [外壳接入](apps/admin/src/layout/README.md)
### 组件、Hooks 与图标:从可运行的示例里复用
## TablePro:从展示数据到处理业务
- **组件**:`RForm` 和 `RModal` 用于表单和弹窗场景,`RChart` 封装 ECharts 实例的初始化、尺寸与主题同步;另有 LogicFlow 流程图、条形码和拖拽卡片示例。[组件入口与约定](apps/admin/src/components/README.md)
- **Hooks**:模板 Hooks 处理页面刷新、内容最大化、菜单标记和水印;Web Hooks 展示截图、打印和元素全屏。交互示例提供可展开的用法代码。[Hooks 示例](apps/admin/src/hooks/README.md)
- **SVG**:把文件放入 `packages/icons/src` 的对应分包即可生成类型提示和雪碧图。路由和 `RIcon` 使用同一套完整名称,例如 `navigation/dashboard`,图标库可按分包查找并复制 TSX 用法。[图标生成与使用](packages/icons/src/A_README.md)
同一个 `RTablePro`,可以用于纯表格、可查询的管理列表,也可以承载密集的运营页面。列定义与自定义单元格沿用 Naive UI DataTable 的方式。
- **搜索随业务扩展**:文本、数字、多选、日期、树选择、级联和自定义字段,支持校验、远程候选联动、手动提交与防抖自动提交。
- **本地与远端共用入口**:本地筛选、组件管理请求或页面控制分页;远端查询只采用最新结果,并透传取消信号。
- **充分利用工作区**:自适应高度、虚拟滚动、列显隐、顺序调整、固定和列偏好存储。
- **常用操作直接可用**:复制表格为 PNG、导出 CSV、打印表格或自定义区域,以及行菜单和工具栏扩展。
- **页面可以主动控制**:通过 `useTablePro` 操作搜索、分页,读取当前页数据与请求状态;行选择由页面维护受控的行键。
请求失败时清空失败结果并提示错误,可以重新查询或刷新。示例同时覆盖成功、取消和失败恢复过程。
[11 个在线示例](https://xiaodaigua-ray.github.io/ray-template/docs/reference/table-pro-examples.html)包含高级搜索、受控分页、列设置、打印和实例 Hooks,每个场景都附上实际运行的源码。
[TablePro API](apps/docs/reference/table-pro.md) · [组件契约](packages/ui/src/RTablePro/README.md) · [第一个业务页面](apps/docs/guide/first-page.md)
## 带着完整应用开始
| 能力 | 已有内容 |
| -------------- | ----------------------------------------------------------------------------- |
| **用户与组织** | 组织树、成员查询、新增/编辑/详情、账号状态、角色和权限控制的操作。 |
| **路由与权限** | 可视化和 JSON 路由编辑器、菜单生成、角色导航、直接访问守卫与页面缓存。 |
| **表单与弹窗** | `RForm`、`useForm`、`RModal`,配套校验、重置、加载状态与交互示例。 |
| **图表与交互** | ECharts 实例和主题管理、LogicFlow、拖拽卡片、右键菜单、截图、打印和全屏。 |
| **图标与工具** | 带类型提示的 SVG 名称与精灵图、二维码、条形码、精度运算、存储、Hooks 和指令。 |
| **交互文档** | 指南、API 参考和可运行示例,与后台应用使用同一工作区的组件。 |
开发环境和静态在线演示共用 **MSW HTTP Mock**,登录、用户、路由和示例数据都经过 API 层。接入后端时配置 `VITE_API_BASE_URL` 与 `VITE_API_MOCK=false`,共享 Schema 和自动生成的 **OpenAPI 3.1** 提供接口契约;真实会话与接口授权由业务后端负责。
[后端接入](apps/docs/guide/backend.md) · [路由与菜单](apps/admin/src/router/README.md) · [组件参考](apps/docs/reference/components.md) · [Hooks 参考](apps/docs/reference/hooks.md)
## Monorepo 架构
Ray Admin 与文档站采用 **pnpm Monorepo**。业务接入留在应用层,可复用能力通过共享包的明确入口提供。
```mermaid
flowchart TB
Admin["Ray Admin · apps/admin"]
Docs["交互文档 · apps/docs"]
Shared["9 个共享 workspace 包"]
UI["界面:ui · admin-shell"]
Interaction["交互:composables · directives · icons"]
Data["数据:http · api-contracts · routing · utils"]
Admin --> Shared
Docs --> Shared
Shared --> UI
Shared --> Interaction
Shared --> Data
```
- **[apps/admin](apps/admin)**:页面、会话、Pinia、路由注册、业务 API 和 Mock。
- **[apps/docs](apps/docs)**:运行共享组件,并嵌入同一次构建中的后台示例。
- **[packages](packages)**:通过公开 `exports` 提供入口,边界检查覆盖导入、依赖声明与循环依赖。目前作为工作区包使用,未单独发布到 npm。
主题使用语义化变量,让自定义页面跟随风格、明暗模式和主题色。布局外壳提供运行时尺寸变量,以及顶栏、侧栏、标签、页脚和内容插槽。
[架构地图](docs/architecture.md) · [接口契约包](packages/api-contracts/README.md) · [自定义样式约定](docs/ui-design.md#custom-css-contract)
## 快速开始
使用仓库固定的 **Node.js 26.13.0** 和 **pnpm 12.16.1**。以下以 nvm 为例:
使用仓库固定的 **Node.js 26.13.0** 和 **pnpm 12.16.1**。
```sh
git clone https://github.com/XiaoDaiGua-Ray/ray-template.git
@ -60,78 +115,35 @@ pnpm install --frozen-lockfile
pnpm dev
```
打开 [http://127.0.0.1:9527/ray-template/](http://127.0.0.1:9527/ray-template/),或使用 Vite 输出的地址。预填的演示账号可直接登录,本地开发无需先搭建业务后端。
打开 [http://127.0.0.1:9527/ray-template/](http://127.0.0.1:9527/ray-template/),点击 **使用演示账号进入**。登录页还提供管理者和只读账号,无需先搭建业务后端。
在同一个仓库运行 `pnpm docs:dev`,可维护[读者文档和页内交互示例](apps/docs/README.md)。
1. **先体验界面**:在「设置」中切换风格与布局,再查看用户管理和 TablePro。
2. **写第一个页面**:参考[现有示例](apps/admin/src/views/demo),登记页面组件 ID,添加路由及中英文菜单文案。
3. **接入业务接口**:保留页面契约,按[后端接入指南](apps/docs/guide/backend.md)连接自己的服务。
## 工程结构
## 开发与交付
```text
ray-template/
├── apps/
│ ├── admin/ # Ray Admin:业务页面、会话、权限、环境文件和 Mock
│ └── docs/ # VitePress:官网、API 参考和交互示例
├── packages/
│ ├── admin-shell/ # 布局、导航、标签、设置和路由过渡
│ ├── ui/ # TablePro、RBarcode、RChart 等共享组件
│ ├── composables/ # 独立的 Vue Hooks 和浏览器工具
│ ├── directives/ # Vue 指令
│ ├── icons/ # SVG 资源、名称类型和清单
│ ├── routing/ # 路由配置契约、校验和菜单处理
│ ├── http/ # 请求客户端、拦截器和请求取消
│ └── utils/ # 精度运算、对象和存储工具
├── harness/ # 回归检查与报告
└── pnpm-lock.yaml # 工作区共用锁文件
```
**Vue 3 · TypeScript / TSX · Naive UI · Vite / Rolldown · Pinia · Vue Router · Vue I18n · Axios · MSW · Vitest**
Ray Admin 在 `apps/admin/src/main.ts` 初始化应用,在 `App.tsx` 注入主题、翻译、图标和列偏好存储。共享包通过 `exports` 提供入口。文档从相同入口运行真实示例;例如 [TablePro](apps/docs/reference/table-pro.md) 用模拟数据展示请求取消与失败重试,[布局实验](apps/docs/guide/layout.md) 使用独立的内存路由。
| 命令 | 用途 |
| ------------------------------ | ---------------------------------------------------------------- |
| `pnpm dev` / `pnpm docs:dev` | 开发后台应用或文档站。 |
| `pnpm build` / `pnpm preview` | 构建或预览后台应用。 |
| `pnpm pages:build` | 将后台与文档组装到 `dist/pages`。 |
| `pnpm harness context <scope>` | 查找实现入口、契约与相关检查。 |
| `pnpm harness verify <scope>` | 执行对应任务域的检查并保存报告。 |
| `pnpm check` | 检查环境、契约、包边界、类型、Lint、格式、测试和两个站点的构建。 |
模块之间的调用关系见[架构地图](docs/architecture.md)。
CI 配置覆盖 **Linux、Windows 和 macOS**。[任务索引](llms.txt)与 [AI Harness](harness/README.md) 为维护者和编码智能体提供可导航的工程上下文。
## 从示例改出第一个业务页面
默认部署路径为后台 `/ray-template/`、文档 `/ray-template/docs/`。修改 base 前请阅读[部署约定](docs/architecture.md#deployment-and-search-discovery)。
下面是人员列表的最小接入。它使用仓库自带的 Mock 查询函数;换成订单或库存列表时,替换列定义、搜索字段与请求函数即可。
## 版本边界
```tsx
import { getPersonList } from '@/api/demo/mock/person'
import { RTablePro } from '@ray-template/ui/table-pro'
import { defineComponent } from 'vue'
**v6 启用 Monorepo 架构。** 不提供 v5 原地升级,也不保证兼容 v5 的内部导入、接口、部署配置或浏览器数据。
export default defineComponent({
setup() {
return () => (
<RTablePro
columns={[
{ title: '姓名', key: 'name' },
{ title: '邮箱', key: 'email' },
]}
request={getPersonList}
search={[{ key: 'name', label: '姓名' }]}
columnStateKey="demo:people"
/>
)
},
})
```
已有项目可以继续使用 [legacy/v5](https://github.com/XiaoDaiGua-Ray/ray-template/tree/legacy/v5)(最后的 v5 主线快照 `6f095b7`,清单版本 `5.2.5`),或使用 [v5.2.4 标签](https://github.com/XiaoDaiGua-Ray/ray-template/tree/v5.2.4)。采用 v6 前请先阅读[迁移说明](apps/docs/migration.md)。
1. **写页面**。在 `apps/admin/src/views` 新建页面,参考[远端查询示例](apps/admin/src/views/demo/tables/remote.tsx)加入排序、行选择和工具栏。
2. **接入导航**。登记页面组件 ID,在 Mock JSON 或后端响应中添加路由,给菜单配置中英文文案。页面需要缓存时,参考[路由约定](apps/admin/src/router/README.md)配置路由与组件名称。
3. **替换演示数据**。从 `apps/admin/src/api` 接入业务接口,通过 `apps/admin/src/axios` 统一处理拦截与取消,再接入实际登录和会话。开发和静态预览共用 HTTP Mock。[服务端契约](apps/docs/guide/backend.md) 提供会话、权限码、用户和路由接口及可下载的 OpenAPI。[请求层说明](apps/admin/src/axios/README.md)
---
## 检查、构建与部署
| 命令 | 用途 |
| ----------------------------- | ------------------------------------------------------------- |
| `pnpm test:run` | 运行 Vitest 测试 |
| `pnpm check` | 执行 CI 同款检查,包含类型、Lint、格式、测试和生产构建 |
| `pnpm harness context` | 按路由、UI、API 等任务域查找源码入口和验证命令 |
| `pnpm harness verify <scope>` | 执行定向检查并保存本地报告;集成风险或发布使用 `all` 全量检查 |
| `pnpm build` / `pnpm preview` | 输出到 `dist/production`,或在本机预览构建 |
`pnpm docs:build` 单独构建文档。`pnpm pages:build` 组装后台与文档到 `dist/pages`,分别服务于 `/ray-template/` 和 `/ray-template/docs/`。
二次开发可从[架构地图](docs/architecture.md)定位配置与模块。部署到域名根目录或子路径、为公开站点启用搜索元数据时,参考[部署指南](docs/architecture.md#deployment-and-search-discovery)。人工和 AI 协作共用 [AGENTS.md](AGENTS.md) 与 [AI Harness](harness/README.md)。
[MIT 许可证](LICENSE) · [更新日志](CHANGELOG.md) · [问题反馈](https://github.com/XiaoDaiGua-Ray/ray-template/issues)
从[任务索引](llms.txt)查找实现归属、调用方和验证方式,无需安装依赖。`pnpm harness context <scope>` 显示同一份索引及验证命令。
[MIT License](LICENSE) · [更新记录](CHANGELOG.md) · [反馈问题](https://github.com/XiaoDaiGua-Ray/ray-template/issues) · [贡献约定](AGENTS.md)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB