feat(admin): 新增转码设置页面
This commit is contained in:
1 parent
723d056fc7
commit
218196ee9f
16 files changed
+1014
-3
No files matched your search
@@ -120,6 +120,15 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
|
||||
meta: {
|
||||
title: '类型管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'media-transcode',
|
||||
name: 'media-transcode',
|
||||
component: () => import('@/views/systemManagement/TranscodeSettingsView.vue'),
|
||||
meta: {
|
||||
title: 'router.transcodeSettings',
|
||||
permission: ['episode:upload']
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
const TRANSCODE_PERMISSION = 'episode:upload'
|
||||
const CONTENT_ROUTE_PATH = '/content'
|
||||
const CONTENT_ROUTE_NAME = 'Content'
|
||||
const TRANSCODE_ROUTE_NAME = 'media-transcode'
|
||||
const TRANSCODE_ROUTE_PATH = 'media-transcode'
|
||||
const TRANSCODE_COMPONENT = 'views/systemManagement/TranscodeSettingsView'
|
||||
const TRANSCODE_TITLE_KEY = 'router.transcodeSettings'
|
||||
|
||||
const findRouteByName = (
|
||||
routes: AppCustomRouteRecordRaw[],
|
||||
name: string
|
||||
): AppCustomRouteRecordRaw | undefined => {
|
||||
for (const route of routes) {
|
||||
if (route.name === name) return route
|
||||
const child = findRouteByName(route.children || [], name)
|
||||
if (child) return child
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端动态菜单未落库时,给具备内容上传权限的账号补充受控的本地转码菜单。
|
||||
*/
|
||||
export const supplementLocalAdminRoutes = (
|
||||
routes: AppCustomRouteRecordRaw[],
|
||||
permissions: string[]
|
||||
): AppCustomRouteRecordRaw[] => {
|
||||
if (!permissions.includes(TRANSCODE_PERMISSION)) {
|
||||
return routes
|
||||
}
|
||||
const nextRoutes = cloneDeep(routes)
|
||||
const existing = findRouteByName(nextRoutes, TRANSCODE_ROUTE_NAME)
|
||||
if (existing) {
|
||||
existing.meta = { ...existing.meta, title: TRANSCODE_TITLE_KEY }
|
||||
return nextRoutes
|
||||
}
|
||||
const contentRoute = nextRoutes.find(
|
||||
(route) => route.path === CONTENT_ROUTE_PATH || route.name === CONTENT_ROUTE_NAME
|
||||
)
|
||||
if (!contentRoute) {
|
||||
return routes
|
||||
}
|
||||
contentRoute.children = contentRoute.children || []
|
||||
contentRoute.children.push({
|
||||
path: TRANSCODE_ROUTE_PATH,
|
||||
name: TRANSCODE_ROUTE_NAME,
|
||||
component: TRANSCODE_COMPONENT,
|
||||
redirect: '',
|
||||
meta: {
|
||||
title: TRANSCODE_TITLE_KEY,
|
||||
permission: [TRANSCODE_PERMISSION]
|
||||
}
|
||||
})
|
||||
return nextRoutes
|
||||
}
|
||||
Reference in new issue
Block a user