chore(merge): 合并转码设置菜单去重修复
This commit is contained in:
commit
d7d43fed44
1 file changed
+11
-13
+11
-13
@@ -10,16 +10,15 @@ const TRANSCODE_ROUTE_PATH = 'media-transcode'
|
|||||||
const TRANSCODE_COMPONENT = 'views/systemManagement/TranscodeSettingsView'
|
const TRANSCODE_COMPONENT = 'views/systemManagement/TranscodeSettingsView'
|
||||||
const TRANSCODE_TITLE_KEY = 'router.transcodeSettings'
|
const TRANSCODE_TITLE_KEY = 'router.transcodeSettings'
|
||||||
|
|
||||||
const findRouteByName = (
|
/** 服务端菜单可能用别的路由名指向同一个组件,这里按路由名或组件路径判定是否已存在 */
|
||||||
routes: AppCustomRouteRecordRaw[],
|
const hasTranscodeRoute = (routes: AppCustomRouteRecordRaw[]): boolean => {
|
||||||
name: string
|
|
||||||
): AppCustomRouteRecordRaw | undefined => {
|
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
if (route.name === name) return route
|
if (route.name === TRANSCODE_ROUTE_NAME || route.component === TRANSCODE_COMPONENT) {
|
||||||
const child = findRouteByName(route.children || [], name)
|
return true
|
||||||
if (child) return child
|
}
|
||||||
|
if (hasTranscodeRoute(route.children || [])) return true
|
||||||
}
|
}
|
||||||
return undefined
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,12 +31,11 @@ export const supplementLocalAdminRoutes = (
|
|||||||
if (!permissions.includes(TRANSCODE_PERMISSION)) {
|
if (!permissions.includes(TRANSCODE_PERMISSION)) {
|
||||||
return routes
|
return routes
|
||||||
}
|
}
|
||||||
const nextRoutes = cloneDeep(routes)
|
// 服务端菜单里已经有转码设置时不再补,否则侧边栏会出现两条
|
||||||
const existing = findRouteByName(nextRoutes, TRANSCODE_ROUTE_NAME)
|
if (hasTranscodeRoute(routes)) {
|
||||||
if (existing) {
|
return routes
|
||||||
existing.meta = { ...existing.meta, title: TRANSCODE_TITLE_KEY }
|
|
||||||
return nextRoutes
|
|
||||||
}
|
}
|
||||||
|
const nextRoutes = cloneDeep(routes)
|
||||||
const contentRoute = nextRoutes.find(
|
const contentRoute = nextRoutes.find(
|
||||||
(route) => route.path === CONTENT_ROUTE_PATH || route.name === CONTENT_ROUTE_NAME
|
(route) => route.path === CONTENT_ROUTE_PATH || route.name === CONTENT_ROUTE_NAME
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user