All Projects → dobble11 → Epee React Admin Ts

dobble11 / Epee React Admin Ts

🗡简洁、高效、易扩展的 React 快速开发模板,基于布局设计,纯 Hooks 开发,提供全链路类型检查及工具

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Epee React Admin Ts

React Admin
基于[email protected]的react动态权限后台管理系统模板
Stars: ✭ 151 (+122.06%)
Mutual labels:  create-react-app, antd
hotlist
今日热榜(前端)
Stars: ✭ 51 (-25%)
Mutual labels:  create-react-app, antd
React Antd Admin
后台前端管理系统,基于react、typescript、antd、dva及一些特别优秀的开源库实现
Stars: ✭ 117 (+72.06%)
Mutual labels:  create-react-app, antd
wx-react-app
使用Create-React-App 和 Ant Design Pro 框架整合,演示地址:
Stars: ✭ 16 (-76.47%)
Mutual labels:  create-react-app, antd
nodejs-spider
No description or website provided.
Stars: ✭ 18 (-73.53%)
Mutual labels:  create-react-app, antd
Create React App Antd
Use antd in create-react-app without ejecting ✨
Stars: ✭ 494 (+626.47%)
Mutual labels:  create-react-app, antd
react-antd-admin
react-antd-admin 是一个后台集成解决方案,它基于 react 和 antd; 内置了动态路由,标签页缓存,权限验证、切换功能
Stars: ✭ 42 (-38.24%)
Mutual labels:  create-react-app, antd
public-ol-web-template
OrangeLoops Web Project Boilerplate
Stars: ✭ 28 (-58.82%)
Mutual labels:  create-react-app, antd
epee-react-admin
🗡简洁、高效、易扩展的 React 快速开发模板,基于布局设计,纯 Hooks 开发,包含中后台应用常用功能
Stars: ✭ 87 (+27.94%)
Mutual labels:  create-react-app, antd
React Modern Library Boilerplate
Boilerplate for publishing modern React modules with Rollup
Stars: ✭ 285 (+319.12%)
Mutual labels:  create-react-app, module
React Latest Framework
a client framework of React
Stars: ✭ 835 (+1127.94%)
Mutual labels:  create-react-app, antd
Headfon.es
a mini Spotify clone 🎧
Stars: ✭ 62 (-8.82%)
Mutual labels:  create-react-app
Npm Compare
Compare npm packages from your terminal
Stars: ✭ 55 (-19.12%)
Mutual labels:  module
Modules
Modules in R
Stars: ✭ 54 (-20.59%)
Mutual labels:  module
React Redux Example
React Redux Example
Stars: ✭ 54 (-20.59%)
Mutual labels:  create-react-app
Daggraph
Dagger dependency graph generator for Android Developers
Stars: ✭ 1,140 (+1576.47%)
Mutual labels:  module
Antd Admin
An excellent front-end solution for enterprise applications built upon Ant Design and UmiJS
Stars: ✭ 8,678 (+12661.76%)
Mutual labels:  antd
React Mobx Ts Antd
A simple empty project build with react、react-router、mobx、antd in typescript.
Stars: ✭ 53 (-22.06%)
Mutual labels:  antd
Docker Rails React Starter
A basic docker-compose, Rails and React / Webpack starter kit
Stars: ✭ 52 (-23.53%)
Mutual labels:  create-react-app
Antara Gaming Sdk
Komodo Gaming Software Development Kit
Stars: ✭ 51 (-25%)
Mutual labels:  module

💡 预览

水平布局 (master):https://epee.netlify.app/ hlayout

垂直布局 (dev-vertical-layout):https://vepee.netlify.app/ vlayout

🚀 特性

  • 零配置
  • 无模版代码
  • 使用 React Hooks 开发
  • 基于 easy-peasy 的状态管理
  • 完善的类型检查及 lint 规则,保证代码风格的一致及质量
  • docker 部署支持
  • 在线数据 mock

🏃 开始

yarn
yarn start

为了更好的开发体验,你还需要安装以下 VSCode 插件

  • Prettier - Code formatter
  • ESLint

推荐安装

  • Auto Close Tag
  • Auto Import
  • Auto Rename Tag
  • CSS Modules
  • Paste JSON as Code
  • Path Intellisense
  • ES7 React/Redux/GraphQL/React-Native snippets

🌳 目录结构

├── /.vscode/                    # vscode 配置目录,包含常用的代码片段、设置等
├── /@types/                     # 全局类型声明
├── /src/                        # 源码目录
│ ├── /assets/                   # 静态资源目录
│ ├── /components/               # 公共业务组件目录
│ ├── /constants/                # constant 目录
│ │ ├── _const.scss              # scss 常量
│ │ └── Api.ts                   # API 常量
│ │ └── store.ts                 # store
│ │ └── router.ts                # 路由树
│ ├── /hooks/                    # hook 目录
│ ├── /layouts/                  # 布局目录
│ ├── /models/                   # 模型目录
│ ├── /pages/                    # 页面组件目录
│ ├── /services/                 # 请求服务目录
│ ├── /style/                    # 全局样式
│ ├── /utils/                    # util 目录
│ │ ├── request.ts               # 基于 fetch 封装的 http 请求工具
│ │ ├── global.ts                # 公共方法库
│ └── index.tsx                  # 项目入口

⚒ 开发

新增页面

这里的『页面』指配置了路由,能够通过链接直接访问的模块

1. 新增 tsx、scss 文件

src
  models
  pages
+   NewPage.tsx
+   NewPage.module.scss

NewPage.tsx 部分代码如下:

export default function NewPage(props: NewPageProps) {
  return <div className={styles.wrap}>New Page</div>;
}

可以键入 tsrfc 快速生成模板代码,后面直接列出代码片段快捷键,不再说明

2. 将页面加入路由

修改 constants/router.ts 内容

export const router: RouteNode[] = [
  {
    path: '/dashboard',
    name: 'Dashboard',
    icon: DashboardOutlined,
    routes: [
      { path: '/dashboard/analysis', name: '分析页', component: Analysis },
    ],
  },
  ...
+  {
+    path: '/new',
+    name: '新页面',
+    icon: FileOutlined,
+    component: NewPage,
+  },
]

修改好之后运行,可以看到如下效果

preview

引入数据流

状态管理使用 easy-peasy,更多用法参考官方文档

下面演示表格组件开发流程

  1. 增加服务请求路径,修改 constants/Api.ts 文件
export const Api = {
+  POST_SERVICE_LIST: `${baseUrl}/service-list/pageSize/:pageSize/page/:page`,
};

按照约定,路径名以大写及请求类型开头命名

  1. 依据接口文档,编写请求服务,新建 services/table-list.service.ts 文件(快捷键:tsreq),部分代码如下:
import { Api } from 'src/constants/Api';
import request from 'src/utils/request';

export const getServiceList = (
  filter: Omit<ServiceFilter, keyof PageParams>,
  router: PageParams,
) =>
  request<ResponseBody<PageData<Service>>>(Api.POST_SERVICE_LIST, {
    method: 'post',
    router,
    body: JSON.stringify(filter),
  });
  1. 新建 models/table-list.model.ts 文件(快捷键:tsmodel),编写对应 state、action 处理数据变化,并定义对应类型用于类型检查,部分代码如下:
import { Action, action, ActionTypes, Thunk, thunk } from 'easy-peasy';
import { getServiceList } from 'src/services/table-list.service';

export interface TableListModel {
  data: PageData<Service>;
  filter: ServiceFilter;
  modifyFilter: Action<TableListModel, Partial<ServiceFilter>>;
  resetFilter: Action<TableListModel>;
  setData: Action<TableListModel, PageData<Service>>;
  fetchServiceList: Thunk<TableListModel>;
}

const initState: O.Filter<TableListModel, ActionTypes> = {
  data: {
    list: [],
    total: 0,
  },
  filter: {
    name: '',
    updateDate: '',
    page: 1,
    pageSize: 10,
  },
};

export const tableListModel: TableListModel = {
  ...initState,
  // 快捷键:act
  modifyFilter: action((state, payload) => {
    state.filter = { ...state.filter, ...payload };
  }),
  resetFilter: action(state => {
    state.filter = initState.filter;
  }),
  setData: action((state, payload) => {
    state.data = payload;
  }),
  // 快捷键:thunk
  fetchServiceList: thunk(async (actions, payload, { getState }) => {
    const { page, pageSize, ...otherFilter } = getState().filter;
    const res = await getServiceList(otherFilter, { page, pageSize });

    actions.setData(res.data);
  }),
};

引入 model,修改 models/index.ts 内容

+import { tableListModel, TableListModel } from './table-list.model';

export interface StoreModel {
+  tableListModel: TableListModel;
}

export const storeModel: StoreModel = {
+  tableListModel,
};
  1. 业务组件使用 demo
import { useStoreActions, useStoreState } from 'src/hooks';

const TableList: React.FC<TableListProps> = props => {
  // 快捷键:cus
  const {
    data: { total, list },
    filter,
  } = useStoreState(state => state.tableListModel);
  // 快捷键:cua
  const { setFilter, resetFilter, fetchServiceList } = useStoreActions(
    actions => actions.tableListModel,
  );
  const [state, fetch] = useAsyncFn(() => fetchServiceList());

  useEffect(() => {
    fetch();
  }, [fetch, filter]);

  return (
    <div className={styles.wrap}>
      <div className={styles.header}>
        <Button type="primary">查询</Button>
        <Button onClick={() => resetFilter()}>重置</Button>
      </div>
      <Table
        columns={columns}
        dataSource={list}
        loading={state.loading}
        pagination={{
          total,
          pageSize: filter.pageSize,
          current: filter.page,
          showSizeChanger: true,
          onChange(curr) {
            modifyFilter({ page: curr });
          },
          onShowSizeChange(curr, size) {
            modifyFilter({ page: 1, pageSize: size });
          },
        }}
      />
    </div>
  );
};

公共业务组件

对于一些可能被多处引用的功能模块,建议提炼成公共业务组件统一管理。这些组件一般有以下特征:

  • 只负责一块相对独立,稳定的功能
  • 没有单独的路由配置
  • 可能是纯静态的,也可能包含自己的 state,但不涉及 redux 的数据流,仅受父组件(通常是一个页面)传递的参数控制

如 echart

布局与路由

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].