mirror of https://github.com/halo-dev/halo-admin
main
dependabot/npm_and_yarn/word-wrap-1.2.4
release-2.3
release-2.1
release-2.2
release-2.0
release-1.5
release-1.6
master
release-1.4
v1.0.0-beta.1
v1.0.1
v1.0.2
v1.0.2-beta.1
v1.0.3
v1.1.0
v1.1.0-beta.1
v1.1.0-beta.2
v1.1.0-beta.3
v1.1.1
v1.1.2
v1.1.3-beta.1
v1.1.3-beta.2
v1.2.0
v1.2.0-beta.1
v1.2.0-beta.2
v1.2.0-beta.3
v1.2.0-beta.4
v1.3.0
v1.3.0-beta.1
v1.3.0-beta.2
v1.3.0-beta.3
v1.3.0-beta.4
v1.3.1
v1.3.2
v1.4.0
v1.4.0-beta.1
v1.4.0-beta.2
v1.4.0-beta.3
v1.4.1
v1.4.10
v1.4.11
v1.4.12
v1.4.13
v1.4.14
v1.4.15
v1.4.16
v1.4.17
v1.4.2
v1.4.3
v1.4.4
v1.4.5
v1.4.6
v1.4.7
v1.4.7-beta.1
v1.4.8
v1.4.9
v1.5.0
v1.5.0-alpha.1
v1.5.0-alpha.2
v1.5.0-alpha.3
v1.5.0-beta.1
v1.5.1
v1.5.2
v1.5.3
v1.5.4
v1.5.5
v1.5.6
v1.6.0
v1.6.1
v2.0.0
v2.0.0-alpha.3
v2.0.0-alpha.4
v2.0.0-beta.1
v2.0.0-beta.2
v2.0.0-rc.1
v2.0.0-rc.2
v2.0.1
v2.0.2
v2.0.3
v2.1.0
v2.1.0-rc.1
v2.2.0
v2.2.1
v2.3.0
v2.3.0-rc.1
v2.3.1
v2.3.2
${ noResults }
1 Commits (8f6d543f4dcbe2611c3b4b64cf0ed2dfca51ea22)
Author | SHA1 | Message | Date |
---|---|---|---|
Ryan Wang |
54755c5842
|
refactor: router and menu generation (#651)
#### What type of PR is this? /kind api-change /kind improvement /milestone 2.0 #### What this PR does / why we need it: Ref https://github.com/halo-dev/halo/issues/2595 重构路由和侧边菜单生成的逻辑,**注意,此 PR 对插件的 Console 入口文件中的路由和菜单定义包含破坏性更新。** 1. 移除 `definePlugin` 方法的 `menus` 字段,改为在 route 的 meta 中定义。 2. 将 `RoutesMenu` 组件从 `@halo-dev/components` 包中移出。 3. 将 `BasicLayout` 组件从 `@halo-dev/console-shared` 包中移出。 定义路由的方式: ```ts import { definePlugin } from "@halo-dev/console-shared"; import BasicLayout from "@/layouts/BasicLayout.vue"; import AttachmentList from "./AttachmentList.vue"; import AttachmentSelectorModal from "./components/AttachmentSelectorModal.vue"; import { IconFolder } from "@halo-dev/components"; import { markRaw } from "vue"; export default definePlugin({ name: "attachmentModule", components: [AttachmentSelectorModal], routes: [ { path: "/attachments", component: BasicLayout, children: [ { path: "", name: "Attachments", component: AttachmentList, meta: { title: "附件", permissions: ["system:attachments:view"], menu: { name: "附件", group: "内容", icon: markRaw(IconFolder), priority: 4, mobile: true, }, }, }, ], }, ], }); ``` menu 字段类型: ```ts interface RouteMeta { title?: string; searchable?: boolean; permissions?: string[]; menu?: { name: string; group?: string; icon?: Component; priority: number; mobile?: true; }; } ``` 插件适配需要做的改动: 1. 移除 `definePlugin` 中的 menus 字段。 2. 在需要添加到菜单的 route 中提供 `meta.menu` 对象,可参考上方的 menu 字段类型。 详细文档可查阅:https://github.com/ruibaby/halo-console/tree/refactor/route-map-setting/docs/routes-generation todolist: - [x] 完善预设的菜单分组定义。 - [x] 绑定权限,根据权限决定是否需要将路由添加到菜单。 - [x] 优化菜单排序的定义方式。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2595 #### Special notes for your reviewer: /cc @halo-dev/sig-halo-console 测试方式: 1. 需要 `pnpm build:packages` 2. 测试后台的菜单及路由是否有异常。 3. 新建角色测试路由和菜单对权限的绑定。 4. 按照 https://github.com/ruibaby/halo-console/tree/refactor/route-map-setting/docs/routes-generation 文档,创建插件,测试插件添加路由和菜单是否正常。 #### Does this PR introduce a user-facing change? ```release-note 重构路由和侧边菜单生成的逻辑。 ``` |
2 years ago |