halo-admin/packages/shared
Ryan Wang 2ef02f2e80
refactor: refactor the page management and remove the function page (#816)
#### What type of PR is this?

/kind api-change
/kind improvement

#### What this PR does / why we need it:

1. 重构页面管理,移除功能页面的功能,改为由插件自行配置菜单。
2. 改进自定义页面的 UI 权限绑定,不会再出现没有勾选相关角色,但仍然显示左侧**页面**菜单的问题。

原由请看:https://github.com/halo-dev/halo/issues/3124

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3124

#### Screenshots:

<img width="1920" alt="image" src="https://user-images.githubusercontent.com/21301288/211480169-fd0490a6-bd1a-447c-bde4-155a16355734.png">

插件需要自己定义菜单配置,如:

<img width="1920" alt="image" src="https://user-images.githubusercontent.com/21301288/211480228-146e6b53-9da4-4a60-b691-dd183f0a45c7.png">

```diff
export default definePlugin({
-  name: "PluginLinks",
   components: {},
   routes: [
     {
       parentName: "Root",
       route: {
-        path: "/pages/functional/links",
+        path: "/links",
         name: "Links",
         component: LinkList,
         meta: {
           permissions: ["plugin:links:view"],
+          menu: {
+            name: "链接",
+            group: "content",
+            icon: markRaw(RiLinksLine),
+          },
         },
       },
     },
   ],
-  extensionPoints: {
-    "page:functional:create": () => {
-      return [
-        {
-          name: "链接",
-          url: "/links",
-          path: "/pages/functional/links",
-          permissions: ["plugin:links:view"],
-        },
-      ];
-    },
-  },
 });
```

#### Special notes for your reviewer:

测试方式:

1. 测试左侧菜单的页面入口是否正常。
2. 创建一个新的角色,不勾选页面的查看权限,登录后检查是否可以在左侧菜单看到页面选项。
3. 测试插件添加菜单是否正常,可测试插件:[plugin-links-1.0.0-SNAPSHOT-plain.jar.zip](https://github.com/halo-dev/console/files/10379709/plugin-links-1.0.0-SNAPSHOT-plain.jar.zip)


#### Does this PR introduce a user-facing change?

```release-note
重构页面管理,移除功能页面的功能。
```
2023-01-10 10:44:40 +00:00
..
src refactor: refactor the page management and remove the function page (#816) 2023-01-10 10:44:40 +00:00
.eslintrc.cjs feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
env.d.ts refactor: router and menu generation (#651) 2022-10-19 08:54:13 +00:00
package.json chore: release 2.1.0 (#811) 2022-12-30 02:32:33 +00:00
prettier.config.js feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
tsconfig.app.json feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
tsconfig.json feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
tsconfig.vite-config.json feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
tsconfig.vitest.json feat: create admin-shared package (#581) 2022-06-16 10:42:13 +00:00
vite.config.ts refactor: router and menu generation (#651) 2022-10-19 08:54:13 +00:00