ice icon indicating copy to clipboard operation
ice copied to clipboard

route 切换跳转 如果有 ice.config.mts 内配置的路由 切换菜单的时候会有问题

Open HowCanLove opened this issue 1 year ago • 1 comments

Describe the bug

/// 设置多个菜单,直至出现滚动条。 切换 关于我们1/关于我们2 时,menu会回到顶部,无法显示当前选中的菜单, /// 按照正常情况,切换菜单不会菜单,菜单不会滚回到顶部的

const asideMenuConfig: MenuDataItem[] = [ { name: '工作台', path: '/', }, { name: '表单', path: '/form', }, { name: '列表', path: '/list', }, { name: '结果&异常', children: [ { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, { name: '成功', path: '/success', }, { name: '404', path: '/404', }, ], }, { name: '关于', children: [ { name: '关于我们1', // 这里是使用 ice.config.mts 中 routes 配置的, // routes: { // defineRoutes: (route) => { // route('/', 'layout.tsx', () => { // route('/about-me', 'custom-about-me/index.tsx'); // }); // }, // }, path: '/about-me', }, { name: '关于我们2', path: '/about', }, ], }, ];

Expected behavior

https://github.com/user-attachments/assets/eebfc05f-1b72-43b0-abdd-dc6ffefbe99d

如果使用文件夹生成的路由 切换的时候就没问题,但项目中需要这样子使用

{ name: '关于我们', children: [ { name: '关于我们', path: '/custom-about-me', }, { name: '关于我们', path: '/about', }, ], },

Actual behavior

No response

Version of ice.js

3.4.0

Content of build.json or ice.config.mts

No response

Additional context

No response

HowCanLove avatar Jul 26 '24 06:07 HowCanLove

可以对比下 .ice 目前下 routes.ts 的结构,通过 defineRoutes 默认是追加路由,存在先后匹配规则影响

ClarkXia avatar Aug 27 '24 08:08 ClarkXia