baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.35k stars 2.52k forks source link

nav联动增删改查,nav选择后没有高亮 #7771

Closed coffin03 closed 1 year ago

coffin03 commented 1 year ago

描述问题:

在react、app多页应用环境中,使用nav联动增删改查,点击后没有高亮效果

截图或视频:

fe46c895745edeb5dfaab585dd001cf 562756260cae24994edcf3886203d9c

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的? 1、react 中集成amis App多页应用 2、history使用 BrowserHistory模式

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在 3.3.0

  3. 粘贴有问题的完整 amis schema 代码:

    https://aisuda.bce.baidu.com/amis/examples/crud/aside2?cat=1
    官方示例代码
coffin03 commented 1 year ago

isCurrentUrl判断逻辑有误,已解决

lawbc commented 4 months ago

isCurrentUrl

请问你是怎么解决的,isCurrentUrl要怎么改

coffin03 commented 2 months ago

isCurrentUrl

请问你是怎么解决的,isCurrentUrl要怎么改

isCurrentUrl: (to: string, ctx?: any) => {
    if (!to) {
        return false;
    }
    const link = normalizeLink(to);
    const location = window.location;
    let pathname = link;
    let search = '';
    const idx = link.indexOf('?');
    if (~idx) {
        pathname = link.substring(0, idx);
        search = link.substring(idx);
    }

    if (search) {
        if (pathname !== location.pathname || !location.search) {
            return false;
        }

        const query = qs.parse(search.substring(1));
        const currentQuery = qs.parse(location.search.substring(1));

        return Object.keys(query).every(
            key => query[key] === currentQuery[key]
        );
    } else if (pathname === location.pathname) {
        return true;
    } else if (!~pathname.indexOf('http') && ~pathname.indexOf(':')) {
        return match(link, {
            decode: decodeURIComponent,
            strict: ctx?.strict ?? true
        })(location.pathname);
    }

    return false;
},