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)
|
||||
|
||||
@@ -67,9 +67,9 @@ const Setting: RouteRecordRaw = {
|
||||
component: () => import('@/pages/menuPages/discount/index.vue'),
|
||||
meta: {
|
||||
permissionsKey: 'discounts',
|
||||
icon: 'vuesax-linear:notification-bing',
|
||||
icon: 'vuesax-linear:discount-shape',
|
||||
title: 'تخفیفات',
|
||||
hideMenu: getConfigApp.name !== "goldsun"
|
||||
hideMenu: getConfigApp('name') !== "goldsun"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -82,6 +82,16 @@ const Setting: RouteRecordRaw = {
|
||||
//hideChildren: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'banners',
|
||||
path: 'banners',
|
||||
component: () => import('@/pages/menuPages/banners/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:image',
|
||||
title: 'بنرها',
|
||||
hideMenu: getConfigApp('name') !== "garoosi"
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user