GithubHelp home page GithubHelp logo

pansyjs / react-admin Goto Github PK

View Code? Open in Web Editor NEW
194.0 12.0 28.0 8.15 MB

🎉 A magical react admin

Home Page: https://react-admin-site.vercel.app

TypeScript 89.69% Less 10.27% Shell 0.04%
typescript react admin-template admin less umi single-page-app ant-design

react-admin's Introduction

React Admin Template

开箱即用的中台前端/设计解决方案。

✨ 特性

  • 🛡 TypeScript: 应用程序级 JavaScript 的语言
  • 💎 优雅美观:基于 Ant Design 体系精心设计
  • 🚀 最新技术栈:使用 React/umi/antd 等前端前沿技术开发
  • 🌐 国际化:内建业界通用的国际化方案
  • 🔢 Mock 数据:实用的本地数据调试方案
  • ⚙️ 最佳实践:良好的工程实践助您持续产出高质量代码
  • 🔐 优秀的权限设计:目前能找到的最好的权限实现方案

🎉 推荐

📜 目录

├── config                     # umi 相关配置
├── docker                     # docker 相关配置
├── mock                       # 本地模拟数据
├── public                     # 静态资源
├── src                        # 源代码
│   ├── assets                 # 本地静态资源
│   ├── common                 # 类型定义、常量
│   ├── components             # 全局公用组件
│   ├── config                 # 全局配置
│   ├── layouts                # 布局文件
│   ├── locales                # 国际化资源
│   ├── models                 # 路由
│   ├── pages                  # 业务页面入口和常用模板
│   ├── services               # 所有请求
│   ├── utils                  # 全局公用方法
│   ├── app.tsx                # 运行时配置文件
│   ├── authority.ts           # 权限定义文件
│   ├── global.less            # 全局样式
│   └── typings.d.ts           # 补充类型定义
├── package.json               # package.json
└── tsconfig.json              # tsconfig.json

🔐 关于权限

基于 umi-plugin-authority 提供权限功能,暴露 useAuthority hooks 和 Authority 组件实现权限控制的能力

使用示例如下

import React from 'react';
import { useAuthority, Authority } from 'umi';

const PageA = props => {
  const { foo } = props;
  const { combinationVerify } = useAuthority();
 
  // 使用 hooks 提供的能力  
  if (combinationVerify('module1/action1')) {
    // 存在 module1/action1 权限,则...
  }
  
  return (
    <div>
      {/** 指定需要验证的权限 */}
      <Authority
        access="module1/action1"
        fallback={<div>Can not read foo content.</div>}
      >
        Foo content.
      </Authority>
      {/** 直接指定权限 */}
      <Authority
        accessible={combinationVerify('module1/action1')}
        fallback={<div>Can not update foo.</div>}
      >
        Update foo.
      </Access>
      {/** 复杂的校验 */}
      <Authority
        accessible={combinationVerify('(module1/action1 || module1/action2) && module1/action3')}
        fallback={<div>Can not update foo.</div>}
      >
        Update foo.
      </Access>
      {/** children 为function */}
      <Authority
        accessible={combinationVerify('module3/action1')}
        fallback={<div>Can not delete foo.</div>}
      >
        {(isMatch) => <span>权限校验结果: {isMatch}</span>}
      </Authority>
    </div>
  );
};

⌨️ 本地开发

# 克隆项目到本地
git clone [email protected]:ts-react/react-admin-template.git

# 切换到项目目录
cd ./react-admin-template

# 安装依赖
yarn

# 启动服务
npm run start

🖥 支持环境

现代浏览器及 IE11。

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

👥 社区互助

Github Issue 钉钉群 微信群
issues

react-admin's People

Contributors

dependabot[bot] avatar hongjinquan avatar renovate-bot avatar wangxingkang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-admin's Issues

v0.1.0开发计划

全局组件

  • AvatarList 用户头像列表
  • Chart组件
  • CountDown 倒计时
  • DescriptionList 描述列表
  • Exception 异常
  • FooterToolbar 底部工具栏
  • GlobalFooter 全局页脚
  • GlobalHeader 全局页头
  • HeaderSearch
  • NoticeIcon
  • Ellipsis 文本自动省略号
  • NumberInfo 数据文本
  • PageHeader
  • SendCode
  • SelectLang
  • SiderMenu
  • Authorized 权限

布局相关

  • Header
  • Footer
  • BasicLayout
  • UserLayout

权限相关

具体请查看#49

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency @ant-design/pro-card to v2
  • fix(deps): update dependency @ant-design/pro-layout to v7
  • fix(deps): update dependency @ant-design/pro-table to v3
  • fix(deps): update dependency @pansy/react-hooks to v2
  • fix(deps): update dependency antd to v5
  • fix(deps): update dependency react-helmet-async to v2
  • fix(deps): update dependency styled-components to v6
  • fix(deps): update dependency umi to v4
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @alitajs/antd-plus ^2.5.0
  • @ant-design/icons ^4.7.0
  • @ant-design/pro-card ^1.18.30
  • @ant-design/pro-layout ^6.32.12
  • @ant-design/pro-table ^2.63.4
  • @formily/antd ^2.0.10
  • @formily/antd-components ^1.3.17
  • @formily/core ^2.0.10
  • @formily/react ^2.0.10
  • @pansy/policy ^0.5.0
  • @pansy/react-amap 2.12.3
  • @pansy/react-charts ^1.0.0
  • @pansy/react-hooks ^0.9.2
  • @pansy/react-watermark ^3.1.8
  • antd ^4.18.6
  • classnames ^2.3.1
  • moment ^2.29.1
  • numeral ^2.0.6
  • react ^17.0.2
  • react-dom ^17.0.2
  • react-helmet-async ^1.2.2
  • styled-components ^5.3.3
  • umi ^3.5.20
  • umi-request ^1.4.0
  • use-merge-value ^1.0.2
  • @alitajs/umi-plugin-antd-plus 0.2.0
  • @alitajs/umi-plugin-console-version 0.4.0
  • @alitajs/umi-preset-react 0.3.0
  • @types/classnames 2.3.1
  • @types/numeral 2.0.2
  • @types/react 17.0.39
  • @types/react-dom 17.0.11
  • @types/styled-components 5.1.22
  • @walrus/cli 1.3.4
  • @walrus/plugin-release 1.14.3
  • @walrus/preset-lint 1.1.8
  • better-mock 0.3.2
  • cross-env 7.0.3
  • husky 5.2.0
  • typescript 4.5.5

  • Check this box to trigger a request for Renovate to run again on this repository

Tab Page实现思路

项目定位为后台管理系统开发模板

所有的页面(除user相关页面外)都应使用basic-layout布局,所以在basic-layout布局组件里添加tab page 实现。

为尽量保证tab page 可插拔,独立封装TabPages组件以及tabs model

实现思路如下

1、使用localStorage存储打开tabs需要使用的数据
2、在basic-layout布局组件中监听地址栏变化,执行相关tab数据存储动作

数据结构如下

export interface ITab {
  id?: string;
  location?: H.Location,
  menuData?: IMenu
}

ITab[]

具体实现请查看相关文件

tab-pages
tabs model
basic-layout

一些细节尚未完善,如果好的意见,请回复,

能否启动

你好,在readme里面没看到编译和启动的脚本信息,我想跑起来但不知道怎么执行

关于css module

项目现在是直接关闭了 css module ,umi 还没实现根据文件去决定是否开启 css module

  • 等待umi相关特性的实现
  • 修改项目, 排除components目录开启 css module ,其他目录 使用 css module

缘由: 现在的样式 在模块过多是 命名 prefixCls 过于繁琐 不好维护

关于权限管理

权限设计

参考阿里云权限设计

前后端遵循一套权限语法module:action

1、module 表示项目模块
2、action 表示具体权限
* 表示该模块下所有权限皆可以访问

权限实现通过 权限 + 策略 + 用户组(用户)实现

1、权限

表示具体权限

例如user/create 表示用户创建权限,user/* 表示拥有用户模块所有权限

2、策略

权限集合,可组成特定的操作权限,可设置为 允许 或者 禁止

策略数据结构如下:

{
  // 策略版本
  version: number,
  statement: [
     {
       // 权限效力
       // allow: 允许; deny: '禁止'
       effect: 'allow' | 'deny',
       // 权限集合
       action: string[]
     },
     ...
  ]
}

3、用户组

拥有相同策略的用户集合

4、用户

系统用户

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.