About router/menu config
See original GitHub issue目前,脚手架中路由和导航 Menu 的生成,以及不同层级组件的渲染都是依靠 nav.js 中的配置信息,这样主要存在两个问题:
- 理论上路由应该和组件渲染没有直接关系,路由 path 并不一定代表 ui 层级,比如:
/user/info
并不一定需要在/user
对应的 layout/组件 中渲染,两个路由在ui上并不是 parent 和 children 的关系,但目前这两个绑在了一起。 - 路由和 Menu 并不一定是一一对应的,Menu 很容易出现个性化的需求,比如某个层级不展示,或者需要在不同地方分别展示不同导航层级,当需求稍微复杂一点时,共用一份配置信息有诸多限制。
- 目前的方式不太符合 react-router@4 的风格,也在一定程度上限制了它的灵活性。
所以在 1.0 发布前,考虑这部分是否可以进行重构,大致的构想是:
-
配置信息只会用来生成路由,且不再是树状,而是打平的,类似下面这样(不完整):
{ "/": { "name": "首页", "component": Home, }, "/user": { "name": "用户", "component": UserLayout, }, "/user/userlist": { "name": "用户列表", "component": UserList, "model": ["user", "loading"], "auth": ["admin"], }, "/user/userlist/:id": { "name": "用户详情", "component": UserDetail, "model": ["user", "loading"], "auth": ["admin"], }, }
-
具体 ui 渲染层级由具体组件代码决定,和配置信息无关。可以提供相应的工具函数方便从配置信息中获取相关参数,如
UserLayout.js
中可以这样写:<div class="content"> {getRoute('/user/userlist')} {getRoute('/user/userlist/:id')} </div>
会生成带上相关配置信息的 Route
-
Menu 导航不再根据配置信息生成,可以自己手动构建,或另外维护一份 Menu 信息用来生成导航。
大家看下是否可行~
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:46 (21 by maintainers)
Top Results From Across the Web
How to Access and Change Your Wi-Fi Router's Settings
Find Your Router's IP Address. Find router's IP address at command prompt ; Enter Your Login Credentials. Enter username and password ; Change...
Read more >Change Wireless Router Settings - MetaGeek
This guide will give you a general idea of the process of accessing your router configuration to change the channel, security type, and...
Read more >Basic Router Configuration - Cisco
This module provides basic configuration procedures for the Cisco 800M Series ISR and contains the following sections. Configuring Global ...
Read more >How To Setup a Network Router
We provide guides for setting up a router on your home network. Our screenshots help you find what you are looking for in...
Read more >Introduction to the Router Menu in the Web GUI Featuring ...
WAN Configuration. Some NetVanta series products can be equipped with a Network Interface Module (NIM) to provide WAN connectivity.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
我最新的项目已经自使用Pro了,谈一下个人看法: In my opinion: 导航还是中心配置化的好一些,面包屑跟着理由走比较合适。 路由和导航如果分开配置,需要增加导航和路由关系配置,不方便我调整路由; 面包屑的显示随着路由变化,比如详情页面在导航是没有对应的,如果按照菜单又该显示哪一个菜单呢。。。 期望增加: 路由是否和导航对应的参数配置。
脑子里有个雏形 我应该做成独立的组件,方便升级. 代码分割估计麻烦了