edit SMSpanel
This commit is contained in:
@@ -4,6 +4,8 @@ import { useRouterStore } from '@core/stores/router'
|
||||
import type { Router, RouteRecordRaw } from 'vue-router'
|
||||
import { getConfigApp, isStoreApp } from '@/utils/config'
|
||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { cloneDeep } from 'lodash'
|
||||
//const _router = useRouter()
|
||||
//import { cloneDeep } from 'lodash'
|
||||
@@ -46,6 +48,20 @@ function filterRoutesByApp(routes: RouteRecordRaw, appName: string | null) {
|
||||
routes.children.forEach((child) => filterRoutesByApp(child, appName))
|
||||
}
|
||||
|
||||
/** زیرمنوی پنل پیامک — فقط deploy admin و وقتی billing فعال است */
|
||||
function filterSmsPanelRoutes(route: RouteRecordRaw) {
|
||||
const user = useUserStore().userInfo
|
||||
|
||||
if (!route.children?.length) return
|
||||
|
||||
route.children = route.children.filter((child) => {
|
||||
if (!child.meta?.requiresSmsPanelAccess) return true
|
||||
return isSmsBillingEnabled(user) && hasSmsPanelAccess(user)
|
||||
})
|
||||
|
||||
route.children.forEach((child) => filterSmsPanelRoutes(child))
|
||||
}
|
||||
|
||||
/** زیرمنوی تنظیمات پیشرفته — فقط برای ادمین دیپلoyi */
|
||||
function filterDeployAdminRoutes(route: RouteRecordRaw, mobile?: string | number | null) {
|
||||
if (!route.children?.length) return
|
||||
@@ -90,6 +106,7 @@ function prepareRoute(route: RouteRecordRaw, appName: string | null, mobile?: st
|
||||
applyAppModeMeta(route, appName)
|
||||
filterRoutesByApp(route, appName)
|
||||
filterDeployAdminRoutes(route, mobile)
|
||||
filterSmsPanelRoutes(route)
|
||||
}
|
||||
|
||||
function loadDynamicRoutes(appName: string | null, mobile?: string | number | null): RouteRecordRaw[] {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||
import { hasSmsPanelAccess } from '@/utils/smsPanelAccess'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { bannerEnabledSetting } from '@/utils/config'
|
||||
|
||||
@@ -71,6 +72,23 @@ const Setting: RouteRecordRaw = {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'smsPanelMain',
|
||||
path: 'sms-panel',
|
||||
component: () => import('@/pages/menuPages/smsPanel/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:wallet-3',
|
||||
title: 'پنل پیامک',
|
||||
order: 3.5,
|
||||
requiresSmsPanelAccess: true
|
||||
},
|
||||
beforeEnter() {
|
||||
const userStore = useUserStore()
|
||||
if (!hasSmsPanelAccess(userStore.userInfo)) {
|
||||
return { name: 'configuration' }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'banners',
|
||||
path: 'banners',
|
||||
|
||||
Reference in New Issue
Block a user