add banners
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
//import router from '@/core/router/index'
|
||||
import { useRouterStore } from '@core/stores/router'
|
||||
import type { Router, RouteRecordRaw } from 'vue-router'
|
||||
import { getConfigApp } from '@/utils/config'
|
||||
//const _router = useRouter()
|
||||
//import { cloneDeep } from 'lodash'
|
||||
|
||||
@@ -12,6 +13,8 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
const routerStore = useRouterStore()
|
||||
const modules = import.meta.glob<any>('./routes/*.ts', { eager: true })
|
||||
console.log(modules)
|
||||
const appName = getConfigApp('name')
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw) {
|
||||
if (!routes.children) return
|
||||
routes.children = routes?.children?.filter(
|
||||
@@ -40,6 +43,17 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
function filterRoutesByApp(routes: RouteRecordRaw) {
|
||||
if (!routes.children) return
|
||||
routes.children = routes.children.filter((item) => {
|
||||
if (item.name === 'discounts' && appName !== 'goldsun') return false
|
||||
if (item.name === 'banners' && appName !== 'garoosi') return false
|
||||
return true
|
||||
})
|
||||
routes.children.forEach((child) => filterRoutesByApp(child))
|
||||
}
|
||||
|
||||
routerStore.routes = [
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
@@ -64,6 +78,7 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
const route: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
||||
if (route) {
|
||||
if (permissionsKeys.length && permissionsKeys[0] == '*') {
|
||||
filterRoutesByApp(route)
|
||||
routerStore.routes.push(route)
|
||||
if (router) {
|
||||
router.addRoute(route)
|
||||
@@ -74,6 +89,7 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
(route.meta.permissionsKey && permissionsKeys.includes(route.meta.permissionsKey))
|
||||
) {
|
||||
walkInRoutes(route)
|
||||
filterRoutesByApp(route)
|
||||
routerStore.routes.push(route)
|
||||
if (router) {
|
||||
router.addRoute(route)
|
||||
|
||||
Reference in New Issue
Block a user