added chat 2
This commit is contained in:
+36
-6
@@ -6,10 +6,30 @@ 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'
|
||||
import { cloneDeep, get } from 'lodash'
|
||||
import { isSettingFlagOn } from '@/utils/settingFlags'
|
||||
//const _router = useRouter()
|
||||
//import { cloneDeep } from 'lodash'
|
||||
|
||||
function supportChatIsEnabled(): boolean {
|
||||
try {
|
||||
const userStore = useUserStore()
|
||||
const settings: any[] = get(userStore.userInfo, 'settings', [])
|
||||
if (!Array.isArray(settings)) return false
|
||||
const chatFlag = settings.find((s: any) => s?.key === 'show_to_users_chat')
|
||||
const hasChat = settings.find((s: any) => s?.key === 'has_chat')
|
||||
const chatApi = settings.find((s: any) => s?.key === 'chat_api')
|
||||
const flagOk = isSettingFlagOn(chatFlag?.value)
|
||||
const hasChatOk = isSettingFlagOn(hasChat?.value)
|
||||
const apiOk =
|
||||
Boolean(String(chatApi?.value ?? '').trim()) &&
|
||||
String(chatApi?.value).toLowerCase() !== 'null'
|
||||
return flagOk && hasChatOk && apiOk
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
||||
const store = isStoreApp()
|
||||
|
||||
@@ -144,11 +164,11 @@ export function setupRoutes(
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw) {
|
||||
if (!routes.children) return
|
||||
routes.children = routes?.children?.filter(
|
||||
(item) =>
|
||||
!item.meta?.permissionsKey ||
|
||||
(item.meta?.permissionsKey && permissionsKeys.includes(item.meta?.permissionsKey))
|
||||
)
|
||||
routes.children = routes?.children?.filter((item) => {
|
||||
const key = item.meta?.permissionsKey
|
||||
if (key === 'support') return supportChatIsEnabled()
|
||||
return !key || permissionsKeys.includes(key)
|
||||
})
|
||||
for (const route of routes.children) {
|
||||
walkInRoutes(route)
|
||||
}
|
||||
@@ -162,11 +182,21 @@ export function setupRoutes(
|
||||
|
||||
const route = cloneDeep(sourceRoute)
|
||||
|
||||
if (route.meta?.permissionsKey === 'support' && !supportChatIsEnabled()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (permissionsKeys.length && permissionsKeys[0] == '*') {
|
||||
prepareRoute(route, appName, userMobile)
|
||||
dynamicRoutes.push(route)
|
||||
} else {
|
||||
if (
|
||||
route.meta?.permissionsKey === 'support' && supportChatIsEnabled()
|
||||
) {
|
||||
walkInRoutes(route)
|
||||
prepareRoute(route, appName, userMobile)
|
||||
dynamicRoutes.push(route)
|
||||
} else if (
|
||||
!route?.meta?.permissionsKey ||
|
||||
(route.meta.permissionsKey && permissionsKeys.includes(route.meta.permissionsKey))
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user