fix chart
This commit is contained in:
+79
-50
@@ -3,6 +3,7 @@
|
||||
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 { cloneDeep } from 'lodash'
|
||||
//const _router = useRouter()
|
||||
//import { cloneDeep } from 'lodash'
|
||||
@@ -45,38 +46,84 @@ function filterRoutesByApp(routes: RouteRecordRaw, appName: string | null) {
|
||||
routes.children.forEach((child) => filterRoutesByApp(child, appName))
|
||||
}
|
||||
|
||||
/** بعد از تغییر is_store — منو را از روتهای تازه (clone) دوباره میسازد */
|
||||
export function refreshAppModeMenu() {
|
||||
const routerStore = useRouterStore()
|
||||
/** زیرمنوی تنظیمات پیشرفته — فقط برای ادمین دیپلoyi */
|
||||
function filterDeployAdminRoutes(route: RouteRecordRaw, mobile?: string | number | null) {
|
||||
if (!route.children?.length) return
|
||||
|
||||
route.children = route.children.filter((child) => {
|
||||
if (!child.meta?.deployAdminOnly) return true
|
||||
return isDeployAdmin(mobile)
|
||||
})
|
||||
|
||||
route.children.forEach((child) => filterDeployAdminRoutes(child, mobile))
|
||||
}
|
||||
|
||||
const notFoundRoute: RouteRecordRaw = {
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'notFound',
|
||||
component: () => import('@/core/pages/404.vue'),
|
||||
meta: {
|
||||
hideMenu: true
|
||||
}
|
||||
}
|
||||
|
||||
function basePreservedRoutes(): RouteRecordRaw[] {
|
||||
return [
|
||||
{
|
||||
name: 'factor',
|
||||
path: '/withdraw/factor/:id',
|
||||
component: () => import('@/pages/menuPages/withdraw/factor/index.vue'),
|
||||
meta: {
|
||||
permissionsKey: 'factor',
|
||||
hideMenu: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
/** notFound باید آخر لیست باشد وگرنه /dashboard و بقیه مسیرها 404 میشوند */
|
||||
function composeRoutes(dynamicRoutes: RouteRecordRaw[]): RouteRecordRaw[] {
|
||||
return [...basePreservedRoutes(), ...dynamicRoutes, notFoundRoute]
|
||||
}
|
||||
|
||||
function prepareRoute(route: RouteRecordRaw, appName: string | null, mobile?: string | number | null) {
|
||||
applyAppModeMeta(route, appName)
|
||||
filterRoutesByApp(route, appName)
|
||||
filterDeployAdminRoutes(route, mobile)
|
||||
}
|
||||
|
||||
function loadDynamicRoutes(appName: string | null, mobile?: string | number | null): RouteRecordRaw[] {
|
||||
const modules = import.meta.glob<any>('./routes/*.ts', { eager: true })
|
||||
const appName = getConfigApp('name')
|
||||
|
||||
const preserved = routerStore.routes.filter(
|
||||
(route) => route.name === 'notFound' || route.name === 'factor'
|
||||
)
|
||||
|
||||
const dynamicRoutes: RouteRecordRaw[] = []
|
||||
|
||||
for (const modulesKey in modules) {
|
||||
const sourceRoute: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
||||
if (!sourceRoute) continue
|
||||
if (sourceRoute.meta?.deployAdminOnly) continue
|
||||
|
||||
const route = cloneDeep(sourceRoute)
|
||||
applyAppModeMeta(route, appName)
|
||||
filterRoutesByApp(route, appName)
|
||||
prepareRoute(route, appName, mobile)
|
||||
dynamicRoutes.push(route)
|
||||
}
|
||||
|
||||
routerStore.routes = [...preserved, ...dynamicRoutes]
|
||||
return dynamicRoutes
|
||||
}
|
||||
|
||||
export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
//console.log('this is permission', permissionsKeys)
|
||||
//console.log('this is use router', _router)
|
||||
console.log('salammm')
|
||||
/** بعد از تغییر is_store — منو را از روتهای تازه (clone) دوباره میسازد */
|
||||
export function refreshAppModeMenu(mobile?: string | number | null) {
|
||||
const routerStore = useRouterStore()
|
||||
const modules = import.meta.glob<any>('./routes/*.ts', { eager: true })
|
||||
console.log(modules)
|
||||
const appName = getConfigApp('name')
|
||||
routerStore.routes = composeRoutes(loadDynamicRoutes(appName, mobile))
|
||||
}
|
||||
|
||||
export function setupRoutes(
|
||||
permissionsKeys: string[],
|
||||
router?: Router,
|
||||
userMobile?: string | number | null
|
||||
) {
|
||||
const routerStore = useRouterStore()
|
||||
const appName = getConfigApp('name')
|
||||
const modules = import.meta.glob<any>('./routes/*.ts', { eager: true })
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw) {
|
||||
if (!routes.children) return
|
||||
@@ -88,54 +135,36 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||
for (const route of routes.children) {
|
||||
walkInRoutes(route)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
routerStore.routes = [
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'notFound',
|
||||
component: () => import('@/core/pages/404.vue'),
|
||||
meta: {
|
||||
hideMenu: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'factor',
|
||||
path: '/withdraw/factor/:id',
|
||||
component: () => import('@/pages/menuPages/withdraw/factor/index.vue'),
|
||||
meta: {
|
||||
permissionsKey: 'factor',
|
||||
hideMenu: true
|
||||
}
|
||||
},
|
||||
]
|
||||
const dynamicRoutes: RouteRecordRaw[] = []
|
||||
for (const modulesKey in modules) {
|
||||
const sourceRoute: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
||||
if (!sourceRoute) continue
|
||||
if (sourceRoute.meta?.deployAdminOnly) continue
|
||||
|
||||
const route = cloneDeep(sourceRoute)
|
||||
|
||||
if (permissionsKeys.length && permissionsKeys[0] == '*') {
|
||||
applyAppModeMeta(route, appName)
|
||||
filterRoutesByApp(route, appName)
|
||||
routerStore.routes.push(route)
|
||||
if (router) {
|
||||
router.addRoute(route)
|
||||
}
|
||||
prepareRoute(route, appName, userMobile)
|
||||
dynamicRoutes.push(route)
|
||||
} else {
|
||||
if (
|
||||
!route?.meta?.permissionsKey ||
|
||||
(route.meta.permissionsKey && permissionsKeys.includes(route.meta.permissionsKey))
|
||||
) {
|
||||
walkInRoutes(route)
|
||||
applyAppModeMeta(route, appName)
|
||||
filterRoutesByApp(route, appName)
|
||||
routerStore.routes.push(route)
|
||||
if (router) {
|
||||
router.addRoute(route)
|
||||
}
|
||||
prepareRoute(route, appName, userMobile)
|
||||
dynamicRoutes.push(route)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
routerStore.routes = composeRoutes(dynamicRoutes)
|
||||
if (router) {
|
||||
for (const route of dynamicRoutes) {
|
||||
router.addRoute(route)
|
||||
}
|
||||
router.addRoute(notFoundRoute)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
|
||||
const Setting: RouteRecordRaw = {
|
||||
name: 'settings',
|
||||
path: '/settings',
|
||||
@@ -26,9 +29,46 @@ const Setting: RouteRecordRaw = {
|
||||
title: 'پیکربندی',
|
||||
disabled: false,
|
||||
hideMenu: true
|
||||
//hideChildren: false
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'configuration',
|
||||
path: 'configuration',
|
||||
component: () => import('@/pages/menuPages/configuration/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:setting-2',
|
||||
title: 'تنظیمات',
|
||||
order: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'advancedConfiguration',
|
||||
path: 'advanced-configuration',
|
||||
component: () => import('@/pages/menuPages/configuration/index.vue'),
|
||||
props: { mode: 'system' },
|
||||
meta: {
|
||||
deployAdminOnly: true,
|
||||
icon: 'vuesax-linear:code-circle',
|
||||
title: 'تنظیمات پیشرفته',
|
||||
order: 2
|
||||
},
|
||||
beforeEnter() {
|
||||
const userStore = useUserStore()
|
||||
if (!isDeployAdmin(userStore.userInfo?.mobile)) {
|
||||
return { name: 'configuration' }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'banners',
|
||||
path: 'banners',
|
||||
component: () => import('@/pages/menuPages/banners/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:image',
|
||||
title: 'بنرها',
|
||||
order: 3
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'settingMain_limitedOrder',
|
||||
path: 'limitedOrder',
|
||||
@@ -36,19 +76,8 @@ const Setting: RouteRecordRaw = {
|
||||
meta: {
|
||||
permissionsKey: 'config.limitedOrder',
|
||||
icon: 'vuesax-linear:document-text',
|
||||
title: '' +
|
||||
'' +
|
||||
'محدودیت سفارش'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'usersMain',
|
||||
path: 'admins',
|
||||
component: () => import('@/pages/menuPages/users/index.vue'),
|
||||
meta: {
|
||||
permissionsKey: 'user',
|
||||
icon: 'vuesax-linear:profile',
|
||||
title: 'لیست مدیران'
|
||||
title: 'محدودیت سفارش',
|
||||
order: 4
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -58,7 +87,8 @@ const Setting: RouteRecordRaw = {
|
||||
meta: {
|
||||
permissionsKey: 'priceTriggers',
|
||||
icon: 'vuesax-linear:notification-bing',
|
||||
title: 'هشدار قیمت'
|
||||
title: 'هشدار قیمت',
|
||||
order: 5
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -68,7 +98,8 @@ const Setting: RouteRecordRaw = {
|
||||
meta: {
|
||||
permissionsKey: 'sms',
|
||||
icon: 'vuesax-linear:sms',
|
||||
title: 'پیامکها'
|
||||
title: 'پیامکها',
|
||||
order: 6
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -79,7 +110,8 @@ const Setting: RouteRecordRaw = {
|
||||
permissionsKey: 'project',
|
||||
icon: 'vuesax-linear:gift',
|
||||
title: 'کارت هدیه',
|
||||
hideMenu: true
|
||||
hideMenu: true,
|
||||
order: 7
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -90,28 +122,21 @@ const Setting: RouteRecordRaw = {
|
||||
permissionsKey: 'discounts',
|
||||
icon: 'vuesax-linear:discount-shape',
|
||||
title: 'تخفیفات',
|
||||
hideMenu: true
|
||||
hideMenu: true,
|
||||
order: 8
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'configuration',
|
||||
path: 'configuration',
|
||||
component: () => import('@/pages/menuPages/configuration/index.vue'),
|
||||
name: 'usersMain',
|
||||
path: 'admins',
|
||||
component: () => import('@/pages/menuPages/users/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:setting-2',
|
||||
title: 'تنظیمات'
|
||||
//hideChildren: false
|
||||
permissionsKey: 'user',
|
||||
icon: 'vuesax-linear:profile',
|
||||
title: 'مدیران',
|
||||
order: 9
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'banners',
|
||||
path: 'banners',
|
||||
component: () => import('@/pages/menuPages/banners/index.vue'),
|
||||
meta: {
|
||||
icon: 'vuesax-linear:image',
|
||||
title: 'بنرها'
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user