-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature request] Transform Ant Design Pro pages to umi blocks #2809
Comments
我这有一个简单的想法,可以开发一个代码转换为 umi block 的工具
|
同步下方案: 对于 umi 来说,为了能够支撑更丰富,功能更完整的区块,同时也是为了 umi 能够更好的支持能够按照页面更好的组织代码,umi 的插件将会做一个扩展,使得 mock locale 这样的功能能够被直接包含在页面的文件夹下,在这种情况下一个 pro 的区块将会变成如下的结构:
这样的一系列区块,将由 pro 的一个工具基于现有 pro 的代码(可能会做一些细微的调整)做自动化的生成。另外对于有的项目(比如 bigfish 的项目),可能习惯将 mock model locale 组织在外层,那么 umi 的 block 提供相应的插件接口供开发使用,使得在分发区块相关内容时可以决定最终的位置。 |
准备写一个工具 umi-block-convertor 来做这件事,https://github.com/umijs/umi-block-convertor 这个工具应该不仅仅能用在 pro 上面,其他项目也应该能够用。当前一个基本的想法是: 通过 对于 mock.js 这样的资源需要手动配置(或者更简单的方案是自己去做 copy)。比如把 mock/xxx.js copy 到区块下的 _mock.js |
要不要加一个配置表,我现在都在https://github.com/xiaohuoni/umi-antd-pro 这个项目里面做方案测试 |
应用源码还是都放 src 吧,不然 src 的语义就变得很模糊了。 |
@xiaohuoni 不太明白,配置表是什么意思?和在那个仓库有什么关系? |
@afc163 是说去掉 |
我意思是 umi 目录结构下 ,src 是不是应该包括所有前端运行时的代码? |
@afc163 现在就是这样的,src 外面只有 mock test config 这些。这里的 src 是区块的 src。 |
👌 我以为是 pro 的 src。 |
和“是否考虑添加一个生成纯的脚手架命令”有关系,就是是否需要一个文件,如antd-pro.config.js
|
https://github.com/umijs/umi-block-convertor 这个工具可以用了,转换出来的 pro 的区块如下: 分析页: 卡片列表页: 感觉生成去区块代码很不优雅,另外这种方式也不便于后续的升级。有一个想法是:pro 就以区块的方式来开发,新建一个 核心的想法就是从一个完整的项目要抽离出区块的复杂度是比把多个区块合并为一个项目要难。 |
牛逼👍 |
在 umi 里面先 fork 了一份代码 https://github.com/umijs/ant-design-pro 只包含 layout,另外页面抽取出来到了 https://github.com/umijs/umi-blocks/tree/master/ant-design-pro 这里。 现在 https://github.com/umijs/umi-blocks/tree/master/ant-design-pro 这里面的 block 是通过脚本转换过去的,都勉强能够跑起来。但是离真正可以用的区块还差得远,另外因为 model 名称重复的原因这些区块是暂时不能在 https://github.com/umijs/umi-blocks/tree/master/ant-design-pro 这里面用的(会报 dva 的 namespace 重复)。 所以之前想要通过脚本自动化把项目代码转成区块的想法针对是太天真了,后面需要针对性的做优化,要让区块和外层的布局更好的解耦,要对 https://github.com/umijs/umi-blocks/tree/master/ant-design-pro 进行重构,https://github.com/umijs/umi-blocks/tree/master/ant-design-pro 这个也需要大量的修改。 需要修改的内容大概有:
有人要一起搞的吗?后面或许就会合到 ant-design-pro 变成 3.0 了。pro 未来的页面都以区块的形式存在,本身只包含外层的 layout 相关内容,另外 |
https://github.com/umijs/umi-blocks/tree/master/ant-design-pro/Analysis 这个区块修改了一波,现在在 这几个了,感觉可以放到 |
为了能够让后续 Ant Design Pro 的区块更好维护,当前在 umi 仓库中 fork 的 Ant Design Pro 版本将会回到 Ant Design Pro 自己的仓库中,作为 v4 版本的开始。 为了让后续能够更好的保持 pro 的更新和项目的完整性,Ant Design Pro 的项目结构将改为如下的结构:
为了能够让开发更好的使用 pro,应该提供 ci 工具让开发可以更好的初始化项目代码,ci 工具需要做到的是:
ci 工具会按照用户的选择去初始化好项目,并且去掉一些项目中没有意义的内容。项目初始化好之后用户也能够通过 umi 的 block 命令方便的添加新的区块到项目中。为了支持直接把 pro 的某一个页面文件夹作为区块,还需要 umi 进行改进,具体参考 ISSUE:umijs/umi#1637 。 |
umi 2.3.0 发布,支持区块,Ant Design Pro 如何使用区块参考 https://www.yuque.com/ant-design/ant-design-pro/lmgc46 |
umi block is coming... umijs/umi#1350
需要讨论下如何将 pro 的页面转成 umi 的 block,这样可以让用户使用一个只有 layout 的 pro 脚手架,然后通过 umi block 来选择性的使用 pro 的页面。
The text was updated successfully, but these errors were encountered: