From bc98ab3805ca89fa1bcdc3c3e4ecc3b265e1df5f Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Sat, 3 Aug 2024 18:33:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20vue=E6=96=B0=E5=A2=9E=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nestJs/src/role/dto/delete-role.dto.ts | 6 - .../pro/template/tinyvue/src/api/menu.ts | 19 + .../pro/template/tinyvue/src/api/role.ts | 18 +- .../tinyvue/src/components/menu/index.vue | 17 +- .../pro/template/tinyvue/src/locale/en-US.ts | 5 + .../pro/template/tinyvue/src/locale/zh-CN.ts | 5 + .../tinyvue/src/router/routes/modules/role.ts | 29 + .../permission/info/components/info-tab.vue | 3 +- .../template/tinyvue/src/views/role/index.vue | 5 + .../views/role/info/components/info-tab.vue | 497 ++++++++++++++++++ .../tinyvue/src/views/role/info/index.vue | 61 +++ .../src/views/role/info/locale/en-US.ts | 18 + .../src/views/role/info/locale/zh-CN.ts | 18 + .../src/views/userManager/setting/index.vue | 4 +- .../src/views/userManager/useradd/index.vue | 4 +- 15 files changed, 690 insertions(+), 19 deletions(-) delete mode 100644 packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts create mode 100644 packages/toolkits/pro/template/tinyvue/src/api/menu.ts create mode 100644 packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/index.vue create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/components/info-tab.vue create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/index.vue create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/locale/en-US.ts create mode 100644 packages/toolkits/pro/template/tinyvue/src/views/role/info/locale/zh-CN.ts diff --git a/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts b/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts deleted file mode 100644 index a53480b0..00000000 --- a/packages/toolkits/pro/template/server/nestJs/src/role/dto/delete-role.dto.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IsNotEmpty } from 'class-validator'; - -export class DeleteRoleDto { - @IsNotEmpty() - name: string; -} diff --git a/packages/toolkits/pro/template/tinyvue/src/api/menu.ts b/packages/toolkits/pro/template/tinyvue/src/api/menu.ts new file mode 100644 index 00000000..cc79c924 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/api/menu.ts @@ -0,0 +1,19 @@ +import axios from "axios"; + + + +export function getAllMenu() { + return axios.get('/api/menu'); +} + +export function updateMenu(data: any) { + return axios.patch(`/api/menu`, data); +} + +export function deleteMenu(id: number) { + return axios.delete(`/api/menu/${id}`); +} + +export function createMenu(data: any) { + return axios.post(`/api/menu`, data); +} diff --git a/packages/toolkits/pro/template/tinyvue/src/api/role.ts b/packages/toolkits/pro/template/tinyvue/src/api/role.ts index 089039c5..6e57f754 100644 --- a/packages/toolkits/pro/template/tinyvue/src/api/role.ts +++ b/packages/toolkits/pro/template/tinyvue/src/api/role.ts @@ -2,6 +2,22 @@ import axios from "axios"; -export function getRoles() { +export function getAllRole() { return axios.get('/api/role'); } + +export function getAllRoleDetail() { + return axios.get('/api/role/detail'); +} + +export function updateRole(data: any) { + return axios.patch(`/api/role`, data); +} + +export function deleteRole(id: number) { + return axios.delete(`/api/role/${id}`); +} + +export function createRole(data: any) { + return axios.post(`/api/role`, data); +} diff --git a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue index b53081d4..a1597c6b 100644 --- a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue +++ b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue @@ -35,6 +35,7 @@ IconApplication, IconGroup, IconFolderOpened, + IconActivation, } from '@opentiny/vue-icon'; import { TreeMenu as tinyTreeMenu } from '@opentiny/vue'; import router from '@/router'; @@ -52,6 +53,7 @@ const iconApplication = IconApplication(); const iconFolderOpened = IconFolderOpened(); const iconGroup = IconGroup(); + const iconActivation = IconActivation(); const tree = ref(); const expandeArr = ref(); const routerTitle = [ @@ -230,17 +232,18 @@ bold: 'title', }, { - value: 'PermissionSetting', - name: 'menu.permission.setting', - icon: null, - bold: 'title', + value: 'Role', + name: 'menu.role', + icon: iconActivation, + bold: 'main-title', }, { - value: 'PermissionAdd', - name: 'menu.permission.permissionAdd', + value: 'AllRole', + name: 'menu.role.info', icon: null, bold: 'title', }, + ]; // 获取路由数据 @@ -311,6 +314,8 @@ 'User', 'Cloud', 'UserManager', + 'Permission', + 'Role' ]; if (filter.indexOf(data.id) === -1) { router.push({ name: data.id }); diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts index 750d6e04..addd305d 100644 --- a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts +++ b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts @@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/en-US'; import localePermission from '@/views/permission/info/locale/en-US'; +import localeRole from '@/views/role/info/locale/en-US'; + import localeSettings from './en-US/settings'; import localeHttpError from './en-US/httpError'; @@ -56,6 +58,8 @@ export default { 'menu.permission.info':'All Permission Info', 'menu.permission.setting':'Permission Setting', 'menu.permission.permissionAdd':'Add Permission', + 'menu.role': 'Role Manager', + 'menu.role.info':'All Role Info', 'navbar.docs': 'Docs', 'navbar.action.locale': 'Switch to English', 'messageBox.switchRoles': 'Switch Roles', @@ -86,4 +90,5 @@ export default { ...localeUserManagerSetting, ...localeUserManagerUserAdd, ...localePermission, + ...localeRole, }; diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts index 09ae2408..c00ab8cc 100644 --- a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts +++ b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts @@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/zh-CN'; import localePermission from '@/views/permission/info/locale/zh-CN'; +import localeRole from '@/views/role/info/locale/zh-CN'; + import localeSettings from './zh-CN/settings'; import localeHttpError from './zh-CN/httpError'; @@ -57,6 +59,8 @@ export default { 'menu.permission.info':'查看权限', 'menu.permission.setting':'修改权限', 'menu.permission.permissionAdd':'添加权限', + 'menu.role': '角色管理', + 'menu.role.info':'查看角色', 'navbar.docs': '文档中心', 'navbar.action.locale': '切换为中文', 'messageBox.switchRoles': '切换角色', @@ -87,4 +91,5 @@ export default { ...localeUserManagerSetting, ...localeUserManagerUserAdd, ...localePermission, + ...localeRole, }; diff --git a/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts new file mode 100644 index 00000000..d6e1f749 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/role.ts @@ -0,0 +1,29 @@ +import { RoleType } from '@/types/roleType'; + +export default { + path: 'role', + name: 'Role', + id: 'Role', + label: 'Role', + component: () => import('@/views/role/index.vue'), + meta: { + locale: 'menu.role', + requiresAuth: true, + order: 9, + roles: [RoleType.admin], + }, + children: [ + { + path: 'allRole', + name: 'AllRole', + id: 'AllRole', + label: 'AllRole', + component: () => import('@/views/role/info/index.vue'), + meta: { + locale: 'menu.role.info', + requiresAuth: true, + roles: [RoleType.admin], + }, + }, + ], +}; diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue index 88f53dfb..0f4ee9df 100644 --- a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue @@ -2,7 +2,7 @@