2022-05-30 11:54:43 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-14 07:56:55 +00:00
|
|
|
import {
|
|
|
|
IconMore,
|
|
|
|
IconSearch,
|
|
|
|
IconUserSettings,
|
2023-11-16 07:51:19 +00:00
|
|
|
IconLogoutCircleRLine,
|
2022-06-14 07:56:55 +00:00
|
|
|
VTag,
|
2022-09-10 17:26:26 +00:00
|
|
|
VAvatar,
|
2022-10-18 01:58:09 +00:00
|
|
|
Dialog,
|
2023-11-16 07:51:19 +00:00
|
|
|
IconAccountCircleLine,
|
2022-06-14 07:56:55 +00:00
|
|
|
} from "@halo-dev/components";
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
import { RoutesMenu } from "@/components/menu/RoutesMenu";
|
2022-10-26 03:10:14 +00:00
|
|
|
import IconLogo from "~icons/core/logo?width=5rem&height=2rem";
|
2023-11-16 07:51:19 +00:00
|
|
|
import { RouterView, useRoute, useRouter } from "vue-router";
|
2023-11-13 08:56:08 +00:00
|
|
|
import { onMounted, reactive, ref } from "vue";
|
2022-10-11 09:00:14 +00:00
|
|
|
import axios from "axios";
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
import GlobalSearchModal from "@/components/global-search/GlobalSearchModal.vue";
|
2022-11-28 14:30:19 +00:00
|
|
|
import LoginModal from "@/components/login/LoginModal.vue";
|
2023-11-16 07:51:19 +00:00
|
|
|
import { coreMenuGroups } from "@console/router/constant";
|
2022-11-23 08:39:29 +00:00
|
|
|
import { useUserStore } from "@/stores/user";
|
2023-02-15 05:58:12 +00:00
|
|
|
import { rbacAnnotations } from "@/constants/annotations";
|
2023-02-24 06:06:14 +00:00
|
|
|
import { defineStore, storeToRefs } from "pinia";
|
2023-03-23 08:54:33 +00:00
|
|
|
import { useI18n } from "vue-i18n";
|
2023-03-27 09:20:22 +00:00
|
|
|
import {
|
|
|
|
useOverlayScrollbars,
|
|
|
|
type UseOverlayScrollbarsParams,
|
|
|
|
} from "overlayscrollbars-vue";
|
2023-09-01 02:30:12 +00:00
|
|
|
import { isMac } from "@/utils/device";
|
2023-11-13 08:56:08 +00:00
|
|
|
import { useEventListener } from "@vueuse/core";
|
2023-11-16 07:51:19 +00:00
|
|
|
import { useRouteMenuGenerator } from "@/composables/use-route-menu-generator";
|
2022-05-30 11:54:43 +00:00
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
const router = useRouter();
|
2023-03-23 08:54:33 +00:00
|
|
|
const { t } = useI18n();
|
2022-05-30 11:54:43 +00:00
|
|
|
|
|
|
|
const moreMenuVisible = ref(false);
|
|
|
|
const moreMenuRootVisible = ref(false);
|
|
|
|
|
2022-11-23 08:39:29 +00:00
|
|
|
const userStore = useUserStore();
|
2022-07-18 03:52:13 +00:00
|
|
|
|
2023-02-24 06:06:14 +00:00
|
|
|
const { currentRoles, currentUser } = storeToRefs(userStore);
|
|
|
|
|
2022-10-11 09:00:14 +00:00
|
|
|
const handleLogout = () => {
|
2022-10-18 01:58:09 +00:00
|
|
|
Dialog.warning({
|
2023-03-23 08:54:33 +00:00
|
|
|
title: t("core.sidebar.operations.logout.title"),
|
|
|
|
confirmText: t("core.common.buttons.confirm"),
|
|
|
|
cancelText: t("core.common.buttons.cancel"),
|
2022-10-11 09:00:14 +00:00
|
|
|
onConfirm: async () => {
|
|
|
|
try {
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
await axios.post(`${import.meta.env.VITE_API_URL}/logout`, undefined, {
|
2022-10-11 09:00:14 +00:00
|
|
|
withCredentials: true,
|
|
|
|
});
|
2022-11-23 08:39:29 +00:00
|
|
|
|
|
|
|
await userStore.fetchCurrentUser();
|
|
|
|
|
2022-10-11 09:00:14 +00:00
|
|
|
router.replace({ name: "Login" });
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Failed to logout", error);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
// Global Search
|
|
|
|
const globalSearchVisible = ref(false);
|
2023-11-13 08:56:08 +00:00
|
|
|
useEventListener(document, "keydown", (e: KeyboardEvent) => {
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
const { key, ctrlKey, metaKey } = e;
|
|
|
|
if (key === "k" && ((ctrlKey && !isMac) || metaKey)) {
|
|
|
|
globalSearchVisible.value = true;
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-11-16 07:51:19 +00:00
|
|
|
const { menus, minimenus } = useRouteMenuGenerator(coreMenuGroups);
|
2023-02-21 03:56:10 +00:00
|
|
|
|
2023-03-30 03:02:14 +00:00
|
|
|
// aside scroll
|
2023-02-21 03:56:10 +00:00
|
|
|
const navbarScroller = ref();
|
|
|
|
|
|
|
|
const useNavbarScrollStore = defineStore("navbar", {
|
|
|
|
state: () => ({
|
|
|
|
y: 0,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
const navbarScrollStore = useNavbarScrollStore();
|
|
|
|
|
2023-03-27 09:20:22 +00:00
|
|
|
const reactiveParams = reactive<UseOverlayScrollbarsParams>({
|
|
|
|
options: {
|
|
|
|
scrollbars: {
|
|
|
|
autoHide: "scroll",
|
|
|
|
autoHideDelay: 600,
|
|
|
|
},
|
|
|
|
},
|
2023-03-30 03:02:14 +00:00
|
|
|
events: {
|
|
|
|
scroll: (_, onScrollArgs) => {
|
|
|
|
const target = onScrollArgs.target as HTMLElement;
|
|
|
|
navbarScrollStore.y = target.scrollTop;
|
|
|
|
},
|
|
|
|
updated: (instance) => {
|
|
|
|
const { viewport } = instance.elements();
|
|
|
|
if (!viewport) return;
|
|
|
|
viewport.scrollTo({ top: navbarScrollStore.y });
|
|
|
|
},
|
|
|
|
},
|
2023-03-27 09:20:22 +00:00
|
|
|
});
|
|
|
|
const [initialize] = useOverlayScrollbars(reactiveParams);
|
|
|
|
onMounted(() => {
|
|
|
|
if (navbarScroller.value) {
|
|
|
|
initialize({ target: navbarScroller.value });
|
|
|
|
}
|
|
|
|
});
|
2022-05-30 11:54:43 +00:00
|
|
|
</script>
|
|
|
|
|
2022-04-15 08:17:02 +00:00
|
|
|
<template>
|
2024-04-16 09:32:07 +00:00
|
|
|
<div class="flex min-h-screen">
|
2023-02-10 04:26:15 +00:00
|
|
|
<aside
|
|
|
|
class="navbar fixed hidden h-full overflow-y-auto md:flex md:flex-col"
|
|
|
|
>
|
2023-11-13 08:56:08 +00:00
|
|
|
<div class="logo flex justify-center pb-5 pt-5">
|
2023-03-23 08:54:33 +00:00
|
|
|
<a
|
|
|
|
href="/"
|
|
|
|
target="_blank"
|
|
|
|
:title="$t('core.sidebar.operations.visit_homepage.title')"
|
|
|
|
>
|
2023-01-16 03:26:13 +00:00
|
|
|
<IconLogo
|
|
|
|
class="cursor-pointer select-none transition-all hover:brightness-125"
|
|
|
|
/>
|
|
|
|
</a>
|
2022-04-15 08:17:02 +00:00
|
|
|
</div>
|
2023-03-27 09:20:22 +00:00
|
|
|
<div ref="navbarScroller" class="flex-1 overflow-y-hidden">
|
2023-02-10 04:26:15 +00:00
|
|
|
<div class="px-3">
|
|
|
|
<div
|
|
|
|
class="flex cursor-pointer items-center rounded bg-gray-100 p-2 text-gray-400 transition-all hover:text-gray-900"
|
|
|
|
@click="globalSearchVisible = true"
|
|
|
|
>
|
|
|
|
<span class="mr-3">
|
|
|
|
<IconSearch />
|
|
|
|
</span>
|
2023-03-23 08:54:33 +00:00
|
|
|
<span class="flex-1 select-none text-base font-normal">
|
|
|
|
{{ $t("core.sidebar.search.placeholder") }}
|
|
|
|
</span>
|
2023-02-10 04:26:15 +00:00
|
|
|
<div class="text-sm">
|
|
|
|
{{ `${isMac ? "⌘" : "Ctrl"}+K` }}
|
|
|
|
</div>
|
2022-09-28 06:50:16 +00:00
|
|
|
</div>
|
2022-05-29 07:13:01 +00:00
|
|
|
</div>
|
2023-02-10 04:26:15 +00:00
|
|
|
<RoutesMenu :menus="menus" />
|
2022-05-29 07:13:01 +00:00
|
|
|
</div>
|
2023-02-10 04:26:15 +00:00
|
|
|
<div class="profile-placeholder">
|
|
|
|
<div class="current-profile">
|
2023-02-24 06:06:14 +00:00
|
|
|
<div v-if="currentUser?.spec.avatar" class="profile-avatar">
|
2023-02-10 04:26:15 +00:00
|
|
|
<VAvatar
|
2023-02-24 06:06:14 +00:00
|
|
|
:src="currentUser?.spec.avatar"
|
|
|
|
:alt="currentUser?.spec.displayName"
|
2023-11-16 07:51:19 +00:00
|
|
|
size="sm"
|
2023-02-10 04:26:15 +00:00
|
|
|
circle
|
|
|
|
></VAvatar>
|
2022-07-04 04:33:00 +00:00
|
|
|
</div>
|
2023-02-10 04:26:15 +00:00
|
|
|
<div class="profile-name">
|
2023-11-16 07:51:19 +00:00
|
|
|
<div
|
|
|
|
class="flex text-sm font-medium"
|
|
|
|
:title="currentUser?.spec.displayName"
|
|
|
|
>
|
2023-02-24 06:06:14 +00:00
|
|
|
{{ currentUser?.spec.displayName }}
|
2023-02-10 04:26:15 +00:00
|
|
|
</div>
|
2023-02-24 06:06:14 +00:00
|
|
|
<div v-if="currentRoles?.[0]" class="flex">
|
2023-02-10 04:26:15 +00:00
|
|
|
<VTag>
|
|
|
|
<template #leftIcon>
|
|
|
|
<IconUserSettings />
|
|
|
|
</template>
|
2023-02-24 06:06:14 +00:00
|
|
|
{{
|
|
|
|
currentRoles[0].metadata.annotations?.[
|
|
|
|
rbacAnnotations.DISPLAY_NAME
|
|
|
|
] || currentRoles[0].metadata.name
|
|
|
|
}}
|
2023-02-10 04:26:15 +00:00
|
|
|
</VTag>
|
|
|
|
</div>
|
2022-04-25 07:15:46 +00:00
|
|
|
</div>
|
2023-11-16 07:51:19 +00:00
|
|
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
<a
|
2023-11-30 10:56:10 +00:00
|
|
|
v-tooltip="$t('core.sidebar.operations.profile.tooltip')"
|
2023-11-16 07:51:19 +00:00
|
|
|
class="group inline-block cursor-pointer rounded-full p-1.5 transition-all hover:bg-gray-100"
|
|
|
|
href="/uc"
|
|
|
|
>
|
|
|
|
<IconAccountCircleLine
|
|
|
|
class="h-5 w-5 text-gray-600 group-hover:text-gray-900"
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
<div
|
2023-11-30 10:56:10 +00:00
|
|
|
v-tooltip="$t('core.sidebar.operations.logout.tooltip')"
|
2023-11-16 07:51:19 +00:00
|
|
|
class="group inline-block cursor-pointer rounded-full p-1.5 transition-all hover:bg-gray-100"
|
|
|
|
@click="handleLogout"
|
|
|
|
>
|
|
|
|
<IconLogoutCircleRLine
|
|
|
|
class="h-5 w-5 text-gray-600 group-hover:text-gray-900"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-25 07:15:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-15 08:17:02 +00:00
|
|
|
</aside>
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
|
2023-11-30 04:01:45 +00:00
|
|
|
<main class="content w-full pb-12 mb-safe md:w-[calc(100%-16rem)] md:pb-0">
|
2022-05-13 07:36:02 +00:00
|
|
|
<slot v-if="$slots.default" />
|
|
|
|
<RouterView v-else />
|
2024-01-08 15:06:41 +00:00
|
|
|
<footer
|
|
|
|
v-if="!route.meta.hideFooter"
|
|
|
|
class="mt-auto p-4 text-center text-sm"
|
|
|
|
>
|
|
|
|
<span class="text-gray-600">Powered by </span>
|
2024-03-15 15:30:11 +00:00
|
|
|
<RouterLink to="/overview" class="hover:text-gray-600">
|
2024-01-08 15:06:41 +00:00
|
|
|
Halo
|
|
|
|
</RouterLink>
|
|
|
|
</footer>
|
2022-04-15 08:17:02 +00:00
|
|
|
</main>
|
2022-05-07 09:35:10 +00:00
|
|
|
|
|
|
|
<!--bottom nav bar-->
|
|
|
|
<div
|
2022-08-04 01:44:13 +00:00
|
|
|
v-if="minimenus"
|
2023-03-29 13:44:14 +00:00
|
|
|
class="bottom-nav-bar fixed bottom-0 left-0 right-0 grid grid-cols-6 border-t-2 border-black bg-secondary drop-shadow-2xl mt-safe pb-safe md:hidden"
|
2022-05-07 09:35:10 +00:00
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="(menu, index) in minimenus"
|
|
|
|
:key="index"
|
2022-08-04 01:44:13 +00:00
|
|
|
:class="{ 'bg-black': route.path === menu?.path }"
|
2022-05-07 09:35:10 +00:00
|
|
|
class="nav-item"
|
2022-08-04 01:44:13 +00:00
|
|
|
@click="router.push(menu?.path)"
|
2022-05-07 09:35:10 +00:00
|
|
|
>
|
|
|
|
<div
|
2022-05-29 15:55:06 +00:00
|
|
|
class="flex w-full cursor-pointer items-center justify-center p-1 text-white"
|
2022-05-07 09:35:10 +00:00
|
|
|
>
|
2023-03-27 07:50:15 +00:00
|
|
|
<div class="flex h-10 w-10 flex-col items-center justify-center">
|
2022-05-07 09:35:10 +00:00
|
|
|
<div class="text-base">
|
2022-08-04 01:44:13 +00:00
|
|
|
<Component :is="menu?.icon" />
|
2022-05-07 09:35:10 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="nav-item" @click="moreMenuVisible = true">
|
|
|
|
<div
|
2022-05-29 15:55:06 +00:00
|
|
|
class="flex w-full cursor-pointer items-center justify-center p-1 text-white"
|
2022-05-07 09:35:10 +00:00
|
|
|
>
|
2023-03-27 07:50:15 +00:00
|
|
|
<div class="flex h-10 w-10 flex-col items-center justify-center">
|
2022-05-07 09:35:10 +00:00
|
|
|
<div class="text-base">
|
|
|
|
<IconMore />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-16 06:30:21 +00:00
|
|
|
|
|
|
|
<Teleport to="body">
|
|
|
|
<div
|
|
|
|
v-show="moreMenuRootVisible"
|
2023-03-29 13:44:14 +00:00
|
|
|
class="drawer-wrapper fixed left-0 top-0 z-[99999] flex h-full w-full flex-row items-end justify-center"
|
2022-05-16 06:30:21 +00:00
|
|
|
>
|
|
|
|
<transition
|
|
|
|
enter-active-class="ease-out duration-200"
|
|
|
|
enter-from-class="opacity-0"
|
|
|
|
enter-to-class="opacity-100"
|
|
|
|
leave-active-class="ease-in duration-100"
|
|
|
|
leave-from-class="opacity-100"
|
|
|
|
leave-to-class="opacity-0"
|
|
|
|
@before-enter="moreMenuRootVisible = true"
|
|
|
|
@after-leave="moreMenuRootVisible = false"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-show="moreMenuVisible"
|
2023-03-29 13:44:14 +00:00
|
|
|
class="drawer-layer absolute left-0 top-0 h-full w-full flex-none bg-gray-500 bg-opacity-75 transition-opacity"
|
2022-05-16 06:30:21 +00:00
|
|
|
@click="moreMenuVisible = false"
|
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
<transition
|
|
|
|
enter-active-class="transform transition ease-in-out duration-500 sm:duration-700"
|
|
|
|
enter-from-class="translate-y-full"
|
|
|
|
enter-to-class="translate-y-0"
|
|
|
|
leave-active-class="transform transition ease-in-out duration-500 sm:duration-700"
|
|
|
|
leave-from-class="translate-y-0"
|
|
|
|
leave-to-class="translate-y-full"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-show="moreMenuVisible"
|
2022-05-29 15:55:06 +00:00
|
|
|
class="drawer-content relative flex h-3/4 w-screen flex-col items-stretch overflow-y-auto rounded-t-md bg-white shadow-xl"
|
2022-05-16 06:30:21 +00:00
|
|
|
>
|
|
|
|
<div class="drawer-body">
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
<RoutesMenu
|
2022-05-16 06:30:21 +00:00
|
|
|
:menus="menus"
|
|
|
|
class="p-0"
|
|
|
|
@select="moreMenuVisible = false"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</Teleport>
|
2022-05-07 09:35:10 +00:00
|
|
|
</div>
|
2022-04-15 08:17:02 +00:00
|
|
|
</div>
|
refactor: router and menu generation (halo-dev/console#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
重构路由和侧边菜单生成的逻辑。
```
2022-10-19 08:54:13 +00:00
|
|
|
<GlobalSearchModal v-model:visible="globalSearchVisible" />
|
2022-11-28 14:30:19 +00:00
|
|
|
<LoginModal />
|
2022-05-30 11:54:43 +00:00
|
|
|
</template>
|
2022-04-15 08:17:02 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.navbar {
|
2022-05-07 09:35:10 +00:00
|
|
|
@apply w-64;
|
2022-06-23 06:28:29 +00:00
|
|
|
@apply bg-white;
|
2023-03-30 07:34:14 +00:00
|
|
|
@apply shadow;
|
2022-04-25 03:04:00 +00:00
|
|
|
z-index: 999;
|
2022-04-25 07:15:46 +00:00
|
|
|
|
2023-02-10 04:26:15 +00:00
|
|
|
.profile-placeholder {
|
2022-04-25 07:15:46 +00:00
|
|
|
height: 70px;
|
|
|
|
|
2023-02-10 04:26:15 +00:00
|
|
|
.current-profile {
|
|
|
|
height: 70px;
|
|
|
|
@apply fixed
|
|
|
|
bottom-0
|
2023-03-29 13:44:14 +00:00
|
|
|
left-0
|
2023-02-10 04:26:15 +00:00
|
|
|
flex
|
|
|
|
w-64
|
|
|
|
gap-3
|
|
|
|
bg-white
|
|
|
|
p-3;
|
2022-04-25 07:15:46 +00:00
|
|
|
|
2023-02-10 04:26:15 +00:00
|
|
|
.profile-avatar {
|
|
|
|
@apply flex
|
|
|
|
items-center
|
|
|
|
self-center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.profile-name {
|
|
|
|
@apply flex-1
|
2023-11-16 07:51:19 +00:00
|
|
|
self-center
|
|
|
|
overflow-hidden;
|
2023-02-10 04:26:15 +00:00
|
|
|
}
|
2022-04-25 07:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-24 06:33:46 +00:00
|
|
|
}
|
2022-04-25 07:15:46 +00:00
|
|
|
|
2022-04-24 06:33:46 +00:00
|
|
|
.content {
|
2022-07-20 06:28:33 +00:00
|
|
|
@apply ml-0
|
|
|
|
flex
|
|
|
|
flex-auto
|
|
|
|
flex-col
|
|
|
|
md:ml-64;
|
2022-04-15 08:17:02 +00:00
|
|
|
}
|
|
|
|
</style>
|