Skip to content

Commit

Permalink
fix(router): 调整路由code生成代码 (#8)
Browse files Browse the repository at this point in the history
* fix: 调试多级路由

* fix: 添加依赖

* docs: 更新文档

* docs: 更新文档

* chore: update workflows config.

* refactor(router): 重构router初始化生成的文件

* feat:添加`babel`转换处理 `redirect`

* chore:update uiw

* fix:babel转换值

* fix:修复 String和Identifie判断取值问题

* chore(examples/config): update package

* feat(@kkt/plugin-pro-router): 新增权限控制

* refactor(access): access功能封装插件

* feat(access): 新增权限功能

* remove: 删除多余代码

* fix(entry): 新增默认样式 & 文档

* fix(routes): 兼容自动生成路由

* fix(route): 优化route插件生成代码

* fix(router): 调整路由code生成代码

---------

Co-authored-by: jaywcjlove <398188662@qq.com>
Co-authored-by: SunLxy <1011771396@qq.com>
  • Loading branch information
3 people authored Feb 28, 2023
1 parent 74fedab commit 66ecd47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ kktp ===> `kkt pro`
2. 自动生成入口[@kkt/plugin-pro-entry](https://github.com/kktjs/kkt-pro/tree/main/packages/plugin/entry)
3. 生成路由配置[@kkt/plugin-pro-router](https://github.com/kktjs/kkt-pro/tree/main/packages/plugin/router)
4. 状态管理[@kkt/plugin-pro-rematch](https://github.com/kktjs/kkt-pro/tree/main/packages/plugin/rematch)
5. 状态管理[@kkt/plugin-pro-access](https://github.com/kktjs/kkt-pro/tree/main/packages/plugin/access)
5. 权限管理[@kkt/plugin-pro-access](https://github.com/kktjs/kkt-pro/tree/main/packages/plugin/access)

## 配置加载

Expand Down
8 changes: 6 additions & 2 deletions examples/config/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const Home = () => {
const Home = (props: any) => {
const { navigate } = props;
const click = () => {
navigate('/ceshi');
};
return (
<div>
<button>add route</button>
<button onClick={click}>add route</button>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/router/src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const getDataType = (data) => {
};
export const loopRoutes = (routes) => {
const navigate = useNavigate();
return routes.map(item => {
const newItem = { ...item };
if (item.children && item.children.length > 0) {
Expand All @@ -128,7 +129,6 @@ export const loopRoutes = (routes) => {
if (getDataType(item.element) === '[object Function]') {
const roles = item.roles;
const Element = React.lazy(item.element);
const navigate = useNavigate();
const element = (
<React.Suspense>
<Element roles={roles} navigate={navigate} />
Expand Down

0 comments on commit 66ecd47

Please sign in to comment.