Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.localhost
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_ENV=development
VITE_APP_ENV=localhost
# 本地开发如果要修改环境,在此修改
VITE_API_HOST='/api'
VITE_API_HOST='/api'
# VITE_BASENAME='/subpath'
3 changes: 2 additions & 1 deletion .env.prod
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_ENV=prod
VITE_API_HOST='/api'
VITE_API_HOST='/api'
# VITE_BASENAME='/subpath'
2 changes: 2 additions & 0 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[🔗Live Preview](https://template.react-antd-console.site) | [📒Documentation](https://doc.react-antd-console.site) | [中文](./README.md) | English

Now supports **React 19**!
Now supports **KeepAlive** (experimental)!

<p align="center">
<img width="100%" src="https://static.react-antd-console.site/template.png?g=1">
Expand Down Expand Up @@ -41,6 +42,7 @@ This project minimally encapsulates essential features like login, authenticatio
- **💾 Data Management**: Layered (data and view) architecture design. The data management solution theoretically supports any UI rendering library/framework (including but not limited to React/Vue/Angular)
- **🎨 Theme Customization**: Supports arbitrary color switching in dark/light modes
- **🏷️ Multi-Tabs**: Draggable multi-tabs with persistence, right-click menus, etc.
- **✨ Keep alive**: Supports page state caching, retaining the page state before switching when returning to the page.
- **🎬 Elegant Animations**: Supports route transition animations, tab, menu, and button animations
- **🧩 Other Features**: `Responsive design`, `internationalization`, `Mock`, `environment configuration`, `engineering standards`, etc.

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
[🔗在线预览](https://template.react-antd-console.site) | [📒文档](https://doc.react-antd-console.site) | 中文 | [English](./README-en.md)

已支持**React 19**!
已支持**KeepAlive**(实验性)!

<p align="center">
<img width="100%" src="https://static.react-antd-console.site/template.png?g=1">
<img width="100%" src="https://static.react-antd-console.site/template.png?b=1">
</p>

## 介绍
Expand Down Expand Up @@ -39,6 +40,7 @@ react-antd-console 是一个后台管理系统的前端解决方案,封装了
- **💾 数据管理**: `分层`(数据和视图)架构设计,数据管理方案理论上支持接入任意UI渲染库/框架(包括不限于React/Vue/Angular)
- **🎨 颜色换肤**: 支持深/浅肤色模式下的任意颜色切换
- **🏷️ 多标签页**: 可拖拽的多标签页,支持持久化、右键菜单等
- **✨ 页面缓存**: 支持页面状态缓存,切换回页面后,保留切换前的页面状态
- **🎬 优雅动画**: 支持路由切换动画,标签页、菜单、功能按钮动画等
- **🧩 其他功能**: 如`响应式设计`、`国际化`、`Mock`、`环境配置`、`工程化规范`等

Expand Down
2,223 changes: 2,223 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { withMermaid } from 'vitepress-plugin-mermaid'
export default withMermaid({
title: "react-antd-console",
description: "后台管理系统前端解决方案",
sitemap: {
hostname: 'https://doc.react-antd-console.site',
},
head: [
['link', { rel: 'shortcut icon', type: 'image/x-icon', href: '/favicon.ico' }],
],
Expand Down Expand Up @@ -43,6 +46,8 @@ export default withMermaid({
{ text: 'Icon', link: '/development/icon' },
{ text: '国际化', link: '/development/i18n' },
{ text: '搜索列表', link: '/development/search-list' },
{ text: 'KeepAlive', link: '/development/keep-alive' },
{ text: '常见问题', link: '/development/qa' },
]
}
],
Expand Down
60 changes: 60 additions & 0 deletions docs/development/keep-alive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# KeepAlive

`keepAlive` 功能,类似 `vue` 的 `KeepAlive` 功能,用于在组件间进行切换时,缓存被移除的组件实例

## 启用

使用 `KeepAlive` 能力需要安装 `react` 和 `react-dom` 的 `experimental` 版本:

```shell
npm i react@experimental react-dom@experimental -S --legacy-peer-deps
```

在 `ConsoleLayout` 组件中引入并使用 `KeepAliveOutlet` 代替 `react-router` 的 `Outlet`:

::: code-group

```tsx [src/layouts/ConsoleLayout/index.tsx]
import { Outlet } from 'react-router'; // [!code --]
import KeepAliveOutlet from '@/components/KeepAliveOutlet'; // [!code ++]
import { motion } from 'framer-motion'; // [!code --]
import { Animations } from './animations'; // [!code --]

return (
<div>
<div className="console-layout__right-side">
{/* [!code --] */}
<div className="console-layout__right-side-main-wrap">
{refreshing ? null : ( // [!code --]
<motion.div // [!code --]
className={ClassName__ConsoleLayout_RightSideMain} // [!code --]
key={location.pathname} // [!code --]
variants={Animations['fadeIn']} // [!code --]
initial="initial" // [!code --]
animate="in" // [!code --]
transition={{ type: 'tween', duration: 0.15, ease: 'easeIn' }} // [!code --]
{/* [!code --] */}
>
{/* [!code --] */}
<Outlet />
</motion.div> // [!code --]
{/* [!code --] */}
)}
{/* [!code --] */}
</div>
{/* [!code ++] */}
<div className={`console-layout__right-side-main-wrap ${ClassName__ConsoleLayout_RightSideMain}`}>
{/* [!code ++] */}
{refreshing ? null : <KeepAliveOutlet />}
{/* [!code ++] */}
</div>
</div>
</div>
);
```

:::

## 查看效果

在 [示例页](https://template.react-antd-console.site/home/alive) 输入框输入一个数字,切换到其他页面,再切换回来,看看数字是否仍然在
59 changes: 59 additions & 0 deletions docs/development/qa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 常见问题

## 子路径作为基础路径时,怎么支持?

想实现例如链接以`/subpath`开头的效果,只需要在 `.env.localhost` 和 `.env.prod` 两个文件中设置 `VITE_BASENAME` 值即可。例如 `'/subpath'`

`VITE_BASENAME` 会体现在:

::: code-group

```tsx [vite.config.ts]
const config: UserConfigExport = {
base: env.VITE_BASENAME, // [!code ++]
}
```

```tsx [src/main.tsx]
const basename = import.meta.env.VITE_BASENAME;

async function enableMocking() {
return worker.start({
serviceWorker: {
url: `${basename ?? ''}/mockServiceWorker.js` // [!code ++]
}
});
}

enableMocking().then(async() => {
root.render(
<HistoryRouter
history={history}
basename={basename} // [!code ++]
>
<AntdProvider>
<App />
</AntdProvider>
</HistoryRouter>,
);
});
```

```tsx [src/router/index.ts]
const basename = import.meta.env.VITE_BASENAME;

const router = new Router(routesConfig, {
basename, // [!code ++]
});
```

```nginx
server {
listen 80;
location /subpath {
alias /your/path/to/dist;
index index.html;
try_files $uri /subpath/index.html;
}
}
```
1 change: 1 addition & 0 deletions docs/guide/what.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ react-antd-console 是一个后台管理系统的前端解决方案,封装了
- **💾 数据管理**: `分层`(数据和视图)架构设计,数据管理方案理论上支持接入任意UI渲染库/框架(包括不限于React/Vue/Angular)
- **🎨 颜色换肤**: 支持深/浅肤色模式下的任意颜色切换
- **🏷️ 多标签页**: 可拖拽的多标签页,支持持久化、右键菜单等
- **✨ 页面缓存**: 支持页面状态缓存,切换回页面后,保留切换前的页面状态
- **🎬 优雅动画**: 支持路由切换动画,标签页、菜单、功能按钮动画等
- **🧩 其他功能**: 如`响应式设计`、`国际化`、`Mock`、`环境配置`、`工程化规范`等

Expand Down
35 changes: 18 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,46 @@
"@dnd-kit/utilities": "^3.2.2",
"@zhangsai/model": "^0.0.3",
"admin-search-list": "^1.0.5",
"antd": "^5.24.7",
"axios": "^1.8.4",
"antd": "^5.25.0",
"axios": "^1.9.0",
"classnames": "^2.5.1",
"dayjs": "^1.11.13",
"echarts": "^5.6.0",
"framer-motion": "^12.7.2",
"i18next": "^24.2.3",
"framer-motion": "^12.10.4",
"i18next": "^25.1.2",
"immer": "^10.1.1",
"nprogress": "^0.2.0",
"react": "^19.1.0",
"react-contexify": "^6.0.0",
"react-dom": "^19.1.0",
"react-i18next": "^15.4.1",
"react-router": "^7.5.0",
"react-router-toolset": "^0.0.7",
"react-i18next": "^15.5.1",
"react-router": "^7.6.0",
"react-router-toolset": "^0.0.9",
"react-use": "^17.6.0",
"store2": "^2.14.4"
},
"devDependencies": {
"@types/node": "^22.14.1",
"@types/node": "^22.15.17",
"@types/nprogress": "^0.2.3",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"@vitejs/plugin-react": "^4.3.4",
"@types/react": "^19.1.3",
"@types/react-dom": "^19.1.3",
"@typescript-eslint/eslint-plugin": "^8.32.0",
"@typescript-eslint/parser": "^8.32.0",
"@vitejs/plugin-react": "^4.4.1",
"autoprefixer": "^10.4.21",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"eslint-plugin-react-refresh": "^0.4.20",
"husky": "^9.1.7",
"less": "^4.3.0",
"lint-staged": "^15.5.1",
"lint-staged": "^15.5.2",
"mermaid": "^11.6.0",
"msw": "^2.7.4",
"msw": "^2.8.0",
"typescript": "^5.8.3",
"vite": "^6.2.6",
"vite": "^6.3.5",
"vite-bundle-visualizer": "^1.2.1",
"vite-plugin-sitemap": "^0.7.1",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-svgr": "^4.3.0",
"vitepress": "^1.6.3",
Expand Down
Loading