-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat:对于 widget-sdk 复用 datasheet 的前端组件的经验分享 #1522
Comments
Welcome to propose a code change. |
|
In my opinion , it's a good solution, ReduxStore should be roughly the same between in main thread and workers |
It looks like there hasn't been a reply in 3 weeks, so I'm closing this issue. |
感谢vika团队开源了这么棒的项目,在我开发widget的时候发现,很多在datasheet存在的组件,在widget中无法使用,因为在widget-sdk中不存在,widget-sdk中有个ui目录,放了很少的组件,无法满足业务需求,例如我再datasheet中增加了对自定义字段的filter支撑,如果改造widget-sdk中的filter组件需要copy很多代码进去,工作量很大,后来我使用了另一种讨巧的方式。
以FilterModal 这么组件为例,我现在是这么操作的:
4、现在就可以在widget中使用这个组件了,和使用其他组件没有区别。
这样的好处是不需要大面积修改代码,即可实现一个组件的服用。
不过需要测试下,组件最好是无状态的,需要状态时从外部传入,尤其是避免组件产生副作用,因为 datasheet 和 widget 下的ReduxStore是不同的实例。
虽然不是太优雅(例如需要把datasheet中的props interface复制到widget-sdk中),但是能解决我的问题。
如果有更好的方案建议,感谢留言。
另外不知道出于什么考虑,widget-sdk 中的 IFilterInfo,FieldType 和 core中的不一样,导致我在widget中使用datasheet的组件时
需要重复的转换,其实建议如果在 core 已经存在定义,在 widget-sdk 直接 export 即可(单纯从我使用便利性出发,可能vika有其他的考虑)。
The text was updated successfully, but these errors were encountered: