From 8d3756566bb2a2558c93d0cea837f52a38f94077 Mon Sep 17 00:00:00 2001 From: pycook Date: Fri, 21 Feb 2020 22:44:10 +0800 Subject: [PATCH] The resource view is made into a two-level menu --- cmdb-ui/src/config/router.config.js | 33 ++++++++++++-------- cmdb-ui/src/locales/lang/en-US.js | 47 +++++++++++++++-------------- cmdb-ui/src/locales/lang/zh-CN.js | 1 + 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/cmdb-ui/src/config/router.config.js b/cmdb-ui/src/config/router.config.js index ee9efad..6ee743e 100644 --- a/cmdb-ui/src/config/router.config.js +++ b/cmdb-ui/src/config/router.config.js @@ -5,12 +5,13 @@ import { UserLayout, BasicLayout, RouteView } from '@/layouts' import { getPreference } from '@/api/cmdb/preference' const cmdbRouter = [ - // preference + // resource views { - path: '/preference', - component: () => import('@/views/cmdb/preference'), - name: 'cmdb_preference', - meta: { title: 'menu.preference', icon: 'book', keepAlive: true } + path: '/resource_views', + component: RouteView, + name: 'cmdb_resource_views', + meta: { title: 'menu.resourceViews', icon: 'hdd', keepAlive: true }, + children: [] }, // relation views { @@ -44,6 +45,13 @@ const cmdbRouter = [ hidden: true }] }, + // preference + { + path: '/preference', + component: () => import('@/views/cmdb/preference'), + name: 'cmdb_preference', + meta: { title: 'menu.preference', icon: 'star', keepAlive: true } + }, // batch { path: '/batch', @@ -52,7 +60,7 @@ const cmdbRouter = [ meta: { 'title': 'menu.batch', icon: 'upload', keepAlive: true } }, { - path: '/config//ci_types', + path: '/config/ci_types', name: 'cmdb_ci_type', component: RouteView, redirect: '/ci_types', @@ -147,20 +155,21 @@ function copyArray (arr) { export const generatorDynamicRouter = () => { return new Promise((resolve, reject) => { - // cmdb 订阅的模型 + // sub menu of the resource view getPreference().then(res => { const routers = copyArray(asyncRouterMap) routers[0].children = copyArray(cmdbRouter) - for (let i = 0; i < res.length; i++) { - const item = res[i] - routers[0].children.unshift({ + let resourceMenus = [] + res.forEach(item => { + resourceMenus.push({ path: `/instances/types/${item.id}`, component: () => import(`@/views/cmdb/ci/index`), name: `cmdb_${item.id}`, meta: { title: item.alias, icon: 'table', keepAlive: true, typeId: item.id }, hideChildrenInMenu: true }) - } + }); + routers[0].children[0].children = resourceMenus resolve(routers) }) @@ -183,7 +192,7 @@ const asyncRouterMap = [ ] /** - * 基础路由 + * basic route * @type { *[] } */ export const constantRouterMap = [ diff --git a/cmdb-ui/src/locales/lang/en-US.js b/cmdb-ui/src/locales/lang/en-US.js index ed6300c..331e309 100644 --- a/cmdb-ui/src/locales/lang/en-US.js +++ b/cmdb-ui/src/locales/lang/en-US.js @@ -4,15 +4,16 @@ export default { antLocale: enUS, menu: { preference: 'Preference', - relationViews: 'Relation Views', - treeViews: 'Tree Views', - batch: 'Batch Import', + resourceViews: 'Resource views', + relationViews: 'Relation views', + treeViews: 'Tree views', + batch: 'Batch import', ciType: 'Modeling', acl: 'Authorization', ciModelManager: 'CI Type', ciPropertyRep: 'Attributes', ciRelationType: 'Relation Type', - ciRelationViewDefine: 'Relation View Define', + ciRelationViewDefine: 'Relation view define', aclUsersManager: 'Users', aclRolesManager: 'Roles', aclResourceManager: 'Resources', @@ -35,7 +36,7 @@ export default { upload: 'Upload', download: 'Download', batchUpdate: 'Batch update', - displayFields: 'Display Fields' + displayFields: 'Display fields' }, tip: { sourceCode: 'view on', @@ -51,9 +52,9 @@ export default { create: 'Create', clear: 'Clear', modify: 'Modify', - unselectedAttribute: 'Unselect Attributes', - selectedAttribute: 'Selected Attributes', - noData: 'No Data', + unselectedAttribute: 'Unselect attributes', + selectedAttribute: 'Selected attributes', + noData: 'No data', addSuccess: 'Add successfully', updateSuccess: 'Update successfully', saveSuccess: 'Save successfully', @@ -66,11 +67,11 @@ export default { error: 'Error', other: 'Other', requestFailed: 'Request error, please try again later', - pleaseSelect: 'please select', + pleaseSelect: 'Please select', selectAll: 'Select all' }, ci: { - batchOperate: 'Batch Operation', + batchOperate: 'Batch operation', confirmBatchUpdate: 'Confirm batch modification?', batchUpdate: 'Batch update', batchUpdateSuccess: 'Batch update successfully', @@ -81,7 +82,7 @@ export default { time: 'Time', user: 'User', batchUpdateTip: 'Just fill in the fields that need to be modified!', - selectLevel: '- - directory level selection - -', + selectLevel: '- - Directory level selection - -', displayFieldDefine: 'Display Fields Define' }, table: { @@ -91,8 +92,8 @@ export default { preference: { cancelSubscribeConfirm: 'Really want to unsubscribe ?', subscribeSuccess: 'Subscribe successfully', - subscribeModel: 'Subscribe Model', - resourceView: 'Resource View', + subscribeModel: 'Subscribe model', + resourceView: 'Resource view', subFormTip: 'You can either define a tree view or subscribe to a resource view, which will be presented separately in sidebar' }, batch: { @@ -110,12 +111,12 @@ export default { }, ciType: { add: 'Add', - addAttribute: 'Add Attribute', - addAttribute1: 'Add Attribute', - moreAttribute: 'More Attributes', - bindAttribute: 'Bind Attribute', - editModel: 'Edit Model', - modelName: 'Model Name', + addAttribute: 'Add attribute', + addAttribute1: 'Add attribute', + moreAttribute: 'More attributes', + bindAttribute: 'Bind attribute', + editModel: 'Edit model', + modelName: 'Model name', name: 'Name', alias: 'Alias', type: 'Type', @@ -140,12 +141,12 @@ export default { requiredCheck: 'Required check', defaultShowAttribute: 'Default display attributes', attributeGroup: 'Attribute grouping & sorting', - addGroup: 'Add Group', - deleteGroup: 'Delete Group', + addGroup: 'Add group', + deleteGroup: 'Delete group', up: 'Up', down: 'Down', moveSuccess: 'Move successfully', - moveFailed: 'Move Failed', + moveFailed: 'Move failed', groupNameExisted: 'The group name already exists', moreAttributeCannotSort: 'More attributes cannot be sorted. If you need to sort, add them to other groups!', newCIType: 'New CI Type', @@ -172,7 +173,7 @@ export default { associatedChildRole: 'Associated child role', associatedSuccess: 'Associated with success', name: 'Name', - roleName: 'Role Name', + roleName: 'Role name', description: 'Desciption', resourceNameRequired: 'Please enter the resource name', descriptionTip: 'Please enter description...', diff --git a/cmdb-ui/src/locales/lang/zh-CN.js b/cmdb-ui/src/locales/lang/zh-CN.js index 95952dc..aa42bef 100644 --- a/cmdb-ui/src/locales/lang/zh-CN.js +++ b/cmdb-ui/src/locales/lang/zh-CN.js @@ -4,6 +4,7 @@ export default { antLocale: zhCN, menu: { preference: '我的订阅', + resourceViews: '资源视图', relationViews: '关系视图', treeViews: '树状视图', batch: '批量导入',