Coder Social home page Coder Social logo

kuhami / react-ant Goto Github PK

View Code? Open in Web Editor NEW
283.0 9.0 54.0 2.11 MB

(基于pro 2.0)基于Ant Design Pro 的 (多标签页tabs、拖拽、富文本、拾色器、多功能table、多选Select)

Home Page: https://kuhami.github.io/react-ant/

License: MIT License

JavaScript 90.28% Dockerfile 0.02% CSS 9.61% HTML 0.08%
react-antd react tabs ant-design antd umi webpack

react-ant's People

Contributors

kuhami avatar polarpanda611 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

react-ant's Issues

多Tab的功能只考虑到点击左边Menu的情形,页面内跳转没考虑到

我看了你的多Tab的实现思路,结合我自己之前的实现过程,个人觉得你的实现中有几点可以优化下。

1、tabList放在model里面的state会更好, 并且在effects中实现add, remove, change, clear,back, forward等方法,其他页面中可以这些方法做打开新Tab等操作

2、 可以在add 新Tab页的时候做下容错处理,当想打开不存在页面的时候,返回404页面

3、Exception 几个页面的返回按钮最好删除,或者做其他的处理,不然点击的效果不是想要的

打包发布后搭配nginx后运行不正常

用npm run build打包后,根据官方文档配置nginx,发现只能访问首页,其余任何子页面都无法正确显示。对比测试antd-pro官网的代码,打包后配合nginx使用一切正常。
补充:API接口是重定向到同一个项目另一个运行实例的

点击浏览器的前进和后退时TAB页没有正确切换

我准备使用您的这个框架开发一个管理后台,感谢您的分享,谢谢!

我在测试过程中发现点击浏览器的前进和后退时TAB页没有正确切换,左侧导航菜单是有正确切换样式的,但TAB页没有自动切换到对应的页面,期待能够增加此功能。

tabPane

请教一下tabPane

tabPane里面如果不用react-router-dom.还可以用什么渲染?这里用react-router-dom会有问题,解决方案是最好不用,想请教还有什么可以渲染dom

首页数据加载

现在的首页是一个空的页面,把其他如分析页,工作台,个人信息等放到首页来,都会报错或则不能加载数据

多标签右键菜单

有没有考虑过添加多标签右键管理菜单,例如关闭当前,关闭其他,关闭所有,刷新一类的,有的时候打开的标签页多了,这个功能是很有必要的

实现多页签页的原理及思路

Ant Tabs(pro 2.0)

本文介绍Ant Tabs一些 新增的功能和原理及思路介绍及更新日志。

实现多页签的原理及思路

Ant Tabs 基于 Ant Design Pro 2.0 基础上修改的多标签Tabs,修改此多标签也是工作上的需求,原来后台项目也是基于 Antd Design 来开发的,在 github上demo也不是很多,基本上也不符合自己的需求,于是就本着自己动手,丰衣足食的**,自己在Antd Design的基础上修改了部分文件。

但是,中间也走了很多弯路,踩了很多坑,修改了多个版本最终才成了现在的需求,不过我觉得还可以,仅供大家参考。

引入 ant Tabs

主要修改文件 react-ant/src/layouts/BasicLayout.js 中引入Tabs 组件

代码解析

constructor(props) {
    super(props);
    const {routes} = props.route,routeKey = '/home/home'; // routeKey 为设置首页设置 试试 '/dashboard/analysis' 或其他key值
    const tabLists = this.updateTree(routes);
    let tabList=[];
    tabLists.map((v) => {
      if(v.key === routeKey){
        if(tabList.length === 0){
          v.closable = false
          tabList.push(v);
        }
      }
    });
    this.state = ({
        tabList:tabList,
        tabListKey:[routeKey],
        activeKey:routeKey,
        routeKey
    })

    this.getPageTitle = memoizeOne(this.getPageTitle);
    this.matchParamsPath = memoizeOne(this.matchParamsPath, isEqual);
  }
  • tabList: 用来存储打开的多标签
  • tabListKe:用来判断 tabList 是否重复保持tabList标签唯一性
  • activeKey:当前激活 tab 面板的 key
  • routeKey: 为设置首页设置 试试 '/dashboard/analysis' 或其他key值
updateTree = data => {
    const treeData = data;
    const treeList = [];
    // 递归获取树列表
    const getTreeList = data => {
      data.forEach(node => {
        if(!node.level){
          treeList.push({ tab: node.name, key: node.path,locale:node.locale,closable:true,content:node.component });
        }
        if (node.routes && node.routes.length > 0) { //!node.hideChildrenInMenu &&
          getTreeList(node.routes);
        }
      });
    };
    getTreeList(treeData);
    return treeList;
  };
  • updateTree函数:为递归 routes 多维数据变成一维数据
 <SiderMenu
            logo={logo}
            theme={navTheme}
            onCollapse={this.handleMenuCollapse}
            menuData={menuData}
            isMobile={isMobile}
            {...this.props}
            onHandlePage ={this.onHandlePage}
          />
  • onHandlePage: 点击左侧及页面内触发的函数
 {hidenAntTabs ?
              (<Authorized authority={routerConfig} noMatch={<Exception403 />}>
              {children}
                </Authorized>) :
              (this.state.tabList && this.state.tabList.length ? (
              <Tabs
                // className={styles.tabs}
                activeKey={activeKey}
                onChange={this.onChange}
                tabBarExtraContent={operations}
                tabBarStyle={{background:'#fff'}}
                tabPosition="top"
                tabBarGutter={-1}
                hideAdd
                type="editable-card"
                onEdit={this.onEdit}
              >
                {this.state.tabList.map(item => (
                  <TabPane tab={item.tab} key={item.key} closable={item.closable}>
                    <Authorized authority={routerConfig} noMatch={<Exception403 />}>
                      {/*{item.content}*/}
                      <Route key={item.key} path={item.path} component={item.content} exact={item.exact} />
                    </Authorized>
                  </TabPane>
                ))}
              </Tabs>
            ) : null)}
  • hidenAntTabs:添加这个字段为在抽屉屑中控制是否显示多标签

相关链接

更新日志

2019-04-23

  • 增加功能:增加了左侧点击出发的函数,及çonHandlePage ={this.onHandlePage}
  • 增加文档:主要解释了Ant Tabs的原理及功能

2019-04-18

  • 增加功能:AntTableFinder-多功能Table 深度封装 ant Table 表格

2019-04-10

  • 增加功能:Tabs-支持多标签功能
  • 增加功能:支持-关闭当前标签页、关闭其他标签页、关闭全部标签页
  • 增加功能:拖拽组件
  • 增加功能:富文本编译器
  • 增加功能:支持-是否 隐藏 Ant-Tabs 功能

反馈

如果你觉得有用,对你有些帮助,欢迎给个Star😊,如果你还为明白及文中有错误,请提交Issues😊

tabs多标签问题

目前遇到的问题如下
tabs

当点击table时,因为router配置的文件直接指向当前路由,不会出现任何问题,当点击分步表单时,路由会经过一次重定向,页面无法加载,并且控制台报错
image

想问一下大家有没有解决思路?

页面间跳转

在某个页面通过router.push()到另一个页面的时候,地址栏路径和左边菜单栏都发生了改变,但是内容区域没有改变,也没有打开一个新的tab。

关于多标签页的,有个问题想问一下

你实现的多标签页,是如何做到切换tab的时候,页面不会重新刷新的。

也就是切换的时候,Component不会销毁,是因为你的Component都是DynamicComponent吗?

如果是这样原因的话,那我如何把Component都变成DynamicComponent。

我用的也是umi,但我的路由不是配置路由

设置权限路由后,默认显示首页没生效

我用umi的patchRoutes 方法处理了一下routes,然后我 设置的默认打开的tab是工作台,现在的情况是工作台的 tab已经打开了 但右边内容区没有内容,左侧菜单也没有点击的样式。请问你有什么解决的思路吗?

多页签

能不能讲一下实现多页签的 思路吗, 感谢!

点击列表时多开页签怎么实现?

我现在也实现一个需求,就是点击列表时也要多开页签,就是一个列表每条数据都有编辑功能,点击条目a的编辑要打开一个页签,点击条目b的编辑也要打开一个页签。
WechatIMG357

请问该项目部署到nginx后无法正常打开tab

你好,感谢提供该模板,在学习使用中,build后部署到nginx上发现,点击左侧导航栏中,在打开的tab标签无法正常显示,一直在转圈圈,请问如何修复这个问题?在idea上调试时是没有这个问题的。

clone项目无法运行

报错:
./src/routes/List/Applications.js
Module build failed: TypeError: Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null
at Array.map ()

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.