export const login = async () => {
    console.log('login')
}

export const getMenuChildren = (data, _name: string) => {
    // const item = data.find((it) => it.menuCode === name)
    // return item.children ? item.children : []

    return data || []
}

export const filterRouters = (routes) => {
    routes?.forEach((route) => {
        if (!route.component) {
            route = null
            return
        }
        route.meta = {...route.meta, ...route?.meta?.extend}
        if (route?.children) {
            filterRouters(route?.children)
        }
    })
    return routes
}

export const getBtnAuth = (data) => {
    return data?.map((item) => {
        return {
            path: item.path,
            btns: item.buttons
        }
    })
}

//获取路上的参数
export const getQueryString = (name) => {
    const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`)
    const r = window.location.search.substr(1).match(reg)
    if (r != null) {
        return unescape(r[2])
    }
    return null
}
