admin_main:基于 Ant Design Pro 的后台管理项目

主应用

Branch1Tags0

首页配置

/pages/PageEditor/modules/MidContent.tsx文件中
线上环境
iframe组件src 一般为 '/h5-edit/pages/PageEditorPreview/index'
本地环境
iframe组件src 一般为 'http://localhost:5173/pages/PageEditorPreview/index'

页面发布后更新提醒

新增 usePageUpdate 在需要的地方使用即可

页面崩溃 ErrorBoundary

  在app.tsx
  return 的对象中添加:
  ErrorBoundary: MyErrorBoundary,

  onPageChange中添加:
  EmitListener.update('locationChange'); // 页面跳转后ErrorBoundary重置

Ant Design Pro

打包

yarn build 默认打包为正式环境 yarn build:test 打包为测试环境灰度环境和正式环境一致,nginx 后端接口的区别在 nginx 配置上做处理

主题色

主题色可以 less 文件中用 @primary-color 获取到其他地方可以用

process.env.primaryColor 获取到

表格

ProTable 中的 search 需要使用 useTableSearchReset hook 导出的 tableSearchReset 去重置 ProTable 的 search 默认值来保证表格搜索表现的一致

request 中使用 封装好的 tableRequest 工具函数 转换返回值

const { tableSearchReset } = useTableSearchReset();
<ProTable<TableListItem>
  columns={columns}
  actionRef={ref}
  scroll={{ x: 1000 }}
  search={tableSearchReset}
  request={(params) => TableRequest(params, getPage)}
/>;

表格操作项

Link 和 TableActionContainer 组件结合使用固定在表格操作项中的样式

import Link from '@/components/LInk/Link';
import TableActionContainer from '@/components/BasicTable/components/TableActionContainer';

获取页面参数

const params = new URLSearchParams(location.search);
params.get('xxx');

This project is initialized with Ant Design Pro. Follow is the quick guide for how to use.

Environment Prepare

Install node_modules:

npm install

or

yarn

Provided Scripts

Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test.

Scripts provided in package.json. It's safe to modify or add additional script:

Start project

npm start

Build project

npm run build

Check code style

npm run lint

You can also use script to auto fix some lint error:

npm run lint:fix

Test code

npm test

More

You can view full document on our official website. And welcome any feedback in our github.

Introduction

主应用

Customize your domain