diff --git a/apps/backend-mock/src/modules/menu/menu.controller.ts b/apps/backend-mock/src/modules/menu/menu.controller.ts index 48456579..a8155365 100644 --- a/apps/backend-mock/src/modules/menu/menu.controller.ts +++ b/apps/backend-mock/src/modules/menu/menu.controller.ts @@ -96,7 +96,7 @@ export class MenuController { path: 'access', meta: { icon: 'mdi:cloud-key-outline', - title: 'page.demos.access.backendControl', + title: 'page.demos.access.backendPermissions', }, redirect: '/demos/access/page-control', children: [ diff --git a/apps/web-antd/src/forward/access.ts b/apps/web-antd/src/forward/access.ts index 2f8016b6..661b79c2 100644 --- a/apps/web-antd/src/forward/access.ts +++ b/apps/web-antd/src/forward/access.ts @@ -1,7 +1,9 @@ -import type { GeneratorMenuAndRoutesOptions } from '@vben/access'; -import type { ComponentRecordType } from '@vben/types'; +import type { + ComponentRecordType, + GenerateMenuAndRoutesOptions, +} from '@vben/types'; -import { generateMenusAndRoutes } from '@vben/access'; +import { generateAccessible } from '@vben/access'; import { preferences } from '@vben-core/preferences'; import { message } from 'ant-design-vue'; @@ -13,7 +15,7 @@ import { $t } from '#/locales'; const forbiddenComponent = () => import('#/views/_essential/fallback/forbidden.vue'); -async function generateAccess(options: GeneratorMenuAndRoutesOptions) { +async function generateAccess(options: GenerateMenuAndRoutesOptions) { const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue'); const layoutMap: ComponentRecordType = { @@ -21,7 +23,7 @@ async function generateAccess(options: GeneratorMenuAndRoutesOptions) { IFrameView, }; - return await generateMenusAndRoutes(preferences.app.accessMode, { + return await generateAccessible(preferences.app.accessMode, { ...options, fetchMenuListAsync: async () => { message.loading({ diff --git a/apps/web-antd/src/locales/langs/en-US.json b/apps/web-antd/src/locales/langs/en-US.json index 4b2a5fe5..d04c4323 100644 --- a/apps/web-antd/src/locales/langs/en-US.json +++ b/apps/web-antd/src/locales/langs/en-US.json @@ -3,8 +3,8 @@ "demos": { "title": "Demos", "access": { - "frontendControl": "Frontend Control", - "backendControl": "Backend Control", + "frontendPermissions": "Frontend Permissions", + "backendPermissions": "Backend Permissions", "pageAccess": "Page Access", "buttonControl": "Button Control", "menuVisible403": "Menu Visible(403)", diff --git a/apps/web-antd/src/locales/langs/zh-CN.json b/apps/web-antd/src/locales/langs/zh-CN.json index 1d4016c0..040d467d 100644 --- a/apps/web-antd/src/locales/langs/zh-CN.json +++ b/apps/web-antd/src/locales/langs/zh-CN.json @@ -3,8 +3,8 @@ "demos": { "title": "演示", "access": { - "frontendControl": "前端控制", - "backendControl": "后端控制", + "frontendPermissions": "前端权限", + "backendPermissions": "后端权限", "pageAccess": "页面访问", "buttonControl": "按钮控制", "menuVisible403": "菜单可见(403)", diff --git a/apps/web-antd/src/router/routes/modules/demos.ts b/apps/web-antd/src/router/routes/modules/demos.ts index 4d8c0e81..22409893 100644 --- a/apps/web-antd/src/router/routes/modules/demos.ts +++ b/apps/web-antd/src/router/routes/modules/demos.ts @@ -19,7 +19,7 @@ const routes: RouteRecordRaw[] = [ { meta: { icon: 'mdi:shield-key-outline', - title: $t('page.demos.access.frontendControl'), + title: $t('page.demos.access.frontendPermissions'), }, name: 'Access', path: 'access', diff --git a/apps/web-antd/src/views/dashboard/analytics/index.vue b/apps/web-antd/src/views/dashboard/analytics/index.vue index b088219d..72025254 100644 --- a/apps/web-antd/src/views/dashboard/analytics/index.vue +++ b/apps/web-antd/src/views/dashboard/analytics/index.vue @@ -1,5 +1,5 @@ + + diff --git a/packages/business/access/src/code-access.vue b/packages/business/access/src/code-access.vue deleted file mode 100644 index 1163a42a..00000000 --- a/packages/business/access/src/code-access.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - - diff --git a/packages/business/access/src/generate-menu-and-routes/index.ts b/packages/business/access/src/generate-accessible.ts similarity index 50% rename from packages/business/access/src/generate-menu-and-routes/index.ts rename to packages/business/access/src/generate-accessible.ts index bc27734f..4dc83bb3 100644 --- a/packages/business/access/src/generate-menu-and-routes/index.ts +++ b/packages/business/access/src/generate-accessible.ts @@ -1,17 +1,18 @@ -import type { AccessModeType } from '@vben-core/preferences'; -import type { RouteRecordRaw } from 'vue-router'; - -import type { GeneratorMenuAndRoutesOptions } from '../types'; +import type { + AccessModeType, + GenerateMenuAndRoutesOptions, +} from '@vben-core/typings'; +import { + generateMenus, + generateRoutesByBackend, + generateRoutesByFrontend, +} from '@vben-core/helpers'; import { cloneDepp } from '@vben-core/toolkit'; -import { generateMenus } from './generate-menus'; -import { generateRoutesByBackend } from './generate-routes-backend'; -import { generateRoutesByFrontend } from './generate-routes-frontend'; - -async function generateMenusAndRoutes( +async function generateAccessible( mode: AccessModeType, - options: GeneratorMenuAndRoutesOptions, + options: GenerateMenuAndRoutesOptions, ) { const { router } = options; @@ -25,7 +26,7 @@ async function generateMenusAndRoutes( }); // 生成菜单 - const accessibleMenus = await generateMenus1(mode, accessibleRoutes, options); + const accessibleMenus = await generateMenus(accessibleRoutes, options.router); return { accessibleMenus, accessibleRoutes }; } @@ -36,7 +37,7 @@ async function generateMenusAndRoutes( */ async function generateRoutes( mode: AccessModeType, - options: GeneratorMenuAndRoutesOptions, + options: GenerateMenuAndRoutesOptions, ) { const { forbiddenComponent, roles, routes } = options; @@ -61,22 +62,4 @@ async function generateRoutes( } } -async function generateMenus1( - mode: AccessModeType, - routes: RouteRecordRaw[], - options: GeneratorMenuAndRoutesOptions, -) { - const { router } = options; - switch (mode) { - case 'allow-all': - case 'frontend': - case 'backend': { - return await generateMenus(routes, router); - } - default: { - return []; - } - } -} - -export { generateMenusAndRoutes }; +export { generateAccessible }; diff --git a/packages/business/access/src/index.ts b/packages/business/access/src/index.ts index 7301aeb5..1f857fc9 100644 --- a/packages/business/access/src/index.ts +++ b/packages/business/access/src/index.ts @@ -1,5 +1,3 @@ -export { default as CodeAccess } from './code-access.vue'; -export * from './generate-menu-and-routes'; -export { default as RoleAccess } from './role-access.vue'; -export type * from './types'; +export { default as AccessControl } from './access-control.vue'; +export * from './generate-accessible'; export * from './use-access'; diff --git a/packages/business/access/src/role-access.vue b/packages/business/access/src/role-access.vue deleted file mode 100644 index 4b833242..00000000 --- a/packages/business/access/src/role-access.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - - diff --git a/packages/business/access/src/types.ts b/packages/business/access/src/types.ts deleted file mode 100644 index 9030910c..00000000 --- a/packages/business/access/src/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { - ComponentRecordType, - RouteRecordStringComponent, -} from '@vben/types'; -import type { RouteRecordRaw, Router } from 'vue-router'; - -interface GeneratorMenuAndRoutesOptions { - fetchMenuListAsync?: () => Promise; - forbiddenComponent?: RouteRecordRaw['component']; - layoutMap?: ComponentRecordType; - pageMap?: ComponentRecordType; - roles?: string[]; - router: Router; - routes: RouteRecordRaw[]; -} - -export type { GeneratorMenuAndRoutesOptions }; diff --git a/packages/business/access/tsconfig.json b/packages/business/access/tsconfig.json index b5f44daf..ce1a891f 100644 --- a/packages/business/access/tsconfig.json +++ b/packages/business/access/tsconfig.json @@ -1,9 +1,6 @@ { "$schema": "https://json.schemastore.org/tsconfig", "extends": "@vben/tsconfig/web.json", - "compilerOptions": { - "types": ["@vben/types/global"] - }, "include": ["src"], "exclude": ["node_modules"] } diff --git a/packages/business/layouts/package.json b/packages/business/layouts/package.json index 1d8eb241..ddae48d8 100644 --- a/packages/business/layouts/package.json +++ b/packages/business/layouts/package.json @@ -37,7 +37,6 @@ } }, "dependencies": { - "@vben-core/colorful": "workspace:*", "@vben-core/helpers": "workspace:*", "@vben-core/iconify": "workspace:*", "@vben-core/layout-ui": "workspace:*", @@ -48,12 +47,9 @@ "@vben-core/stores": "workspace:*", "@vben-core/tabs-ui": "workspace:*", "@vben-core/toolkit": "workspace:*", + "@vben-core/typings": "workspace:*", "@vueuse/core": "^10.11.0", "vue": "^3.4.31", "vue-router": "^4.4.0" - }, - "devDependencies": { - "@vben-core/typings": "workspace:*", - "@vben/types": "workspace:*" } } diff --git a/packages/business/layouts/src/basic/tabbar/use-tabs.ts b/packages/business/layouts/src/basic/tabbar/use-tabs.ts index 4823e26f..2948349f 100644 --- a/packages/business/layouts/src/basic/tabbar/use-tabs.ts +++ b/packages/business/layouts/src/basic/tabbar/use-tabs.ts @@ -126,6 +126,19 @@ function useTabs() { disabled || !isCurrentTab || tabs.length - affixTabs.length <= 1; const menus: IContextMenuItem[] = [ + { + handler: async () => { + if (!contentIsMaximize.value) { + await router.push(tab.fullPath); + } + updateContentScreen(!contentIsMaximize.value); + }, + icon: contentIsMaximize.value ? IcRoundFitScreen : IcTwotoneFitScreen, + key: contentIsMaximize.value ? 'restore-maximize' : 'maximize', + text: contentIsMaximize.value + ? $t('preferences.tabbar.contextMenu.restoreMaximize') + : $t('preferences.tabbar.contextMenu.maximize'), + }, { disabled: !isCurrentTab, handler: async () => { @@ -166,22 +179,10 @@ function useTabs() { }, icon: IcRoundTableView, key: 'open-in-new-window', + separator: true, text: $t('preferences.tabbar.contextMenu.openInNewWindow'), }, - { - handler: async () => { - if (!contentIsMaximize.value) { - await router.push(tab.fullPath); - } - updateContentScreen(!contentIsMaximize.value); - }, - icon: contentIsMaximize.value ? IcRoundFitScreen : IcTwotoneFitScreen, - key: contentIsMaximize.value ? 'restore-maximize' : 'maximize', - separator: true, - text: contentIsMaximize.value - ? $t('preferences.tabbar.contextMenu.restoreMaximize') - : $t('preferences.tabbar.contextMenu.maximize'), - }, + { disabled: closeLeftDisabled, handler: async () => { diff --git a/packages/business/layouts/src/widgets/breadcrumb.vue b/packages/business/layouts/src/widgets/breadcrumb.vue index 2d570afa..62f78ce0 100644 --- a/packages/business/layouts/src/widgets/breadcrumb.vue +++ b/packages/business/layouts/src/widgets/breadcrumb.vue @@ -1,6 +1,6 @@