|
@@ -1,75 +1,73 @@
|
|
|
<script setup lang="tsx">
|
|
|
-import { defineComponent, h, Component } from 'vue'
|
|
|
-import { NIcon, useMessage, NMenu, MenuProps } from 'naive-ui'
|
|
|
-
|
|
|
-import type { MenuOption } from 'naive-ui'
|
|
|
+import { h } from 'vue'
|
|
|
+import { NMenu } from 'naive-ui'
|
|
|
import { RouterLink } from 'vue-router'
|
|
|
import SvgIcon from '@/components/SvgIcon/index.vue'
|
|
|
|
|
|
-import CommunityIcon from '@/components/icons/IconCommunity.vue'
|
|
|
-
|
|
|
-type MenuThemeOverrides = NonNullable<MenuProps['themeOverrides']>
|
|
|
|
|
|
-const menuThemeOverrides: MenuThemeOverrides = {
|
|
|
- // fontSize: '13px'
|
|
|
+function renderIcon(props: {name: string, size?: number, class?: string[], color?: string}) {
|
|
|
+ return () => h(SvgIcon, { ...props })
|
|
|
}
|
|
|
|
|
|
-function renderIcon (name: string, size = 30, color = '#fff') {
|
|
|
- return () => h(SvgIcon, { name, size, color })
|
|
|
+function renderChildrenIcon({ name, size = 20 }:{ name:string, size?: number }) {
|
|
|
+ return () => (
|
|
|
+ <div class="flex items-center justify-center">
|
|
|
+ { renderIcon({ name, size, class: ['icon-default'] })() }
|
|
|
+ { renderIcon({ name: name + '-active', size, class: ['icon-active', 'hidden'] })() }
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-function renderLabel (val) {
|
|
|
- return <span class="pl-1 test">{val}</span>
|
|
|
+function renderLabel (val: string) {
|
|
|
+ return (<span class="pl-1 test">{ val }</span>);
|
|
|
}
|
|
|
|
|
|
const menuOptions: MenuOption[] = [
|
|
|
{
|
|
|
label: () => renderLabel('智慧总控'),
|
|
|
- icon: renderIcon("menu-control"),
|
|
|
+ icon: renderIcon({name: 'menu-control'}),
|
|
|
key: '/'
|
|
|
},
|
|
|
{
|
|
|
label: () => renderLabel('专家问答'),
|
|
|
- icon: renderIcon("menu-answers"),
|
|
|
+ icon: renderIcon({name: 'menu-answers'}),
|
|
|
key: '/'
|
|
|
},
|
|
|
{
|
|
|
label: () => renderLabel('智能分析'),
|
|
|
- icon: renderIcon("menu-analyse"),
|
|
|
+ icon: renderIcon({ name: 'menu-analyse' }),
|
|
|
key: '/',
|
|
|
- expandIcon: () => h('span', 123),
|
|
|
children: [
|
|
|
{
|
|
|
label:() => renderLabel('水质报警'),
|
|
|
- key: 'rat',
|
|
|
- icon: renderIcon("menu-analyse-water", 20, '#1A2029'),
|
|
|
+ icon: renderChildrenIcon({ name: 'menu-analyse-water' }),
|
|
|
+ key: 'key1',
|
|
|
},
|
|
|
{
|
|
|
label: '生化报警',
|
|
|
- key: 'rat',
|
|
|
- icon: renderIcon("menu-analyse-pymol", 20, '#1A2029'),
|
|
|
+ icon: renderChildrenIcon({ name: 'menu-analyse-pymol' }),
|
|
|
+ key: 'key2',
|
|
|
},
|
|
|
{
|
|
|
label: '预测报警',
|
|
|
- key: 'rat',
|
|
|
- icon: renderIcon("menu-analyse-notice", 20, '#1A2029'),
|
|
|
+ icon: renderChildrenIcon({ name: 'menu-analyse-notice' }),
|
|
|
+ key: 'key3',
|
|
|
},
|
|
|
{
|
|
|
label: '智能工单',
|
|
|
- key: 'rat',
|
|
|
- icon: renderIcon("menu-analyse-order", 20, '#1A2029'),
|
|
|
+ icon: renderChildrenIcon({ name: 'menu-analyse-order' }),
|
|
|
+ key: 'key4',
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
label: () => renderLabel('智能助手'),
|
|
|
- icon: renderIcon("menu-user"),
|
|
|
+ icon: renderIcon({ name: 'menu-user' }),
|
|
|
key: '/'
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
label: () => renderLabel('用户中心'),
|
|
|
- icon: renderIcon("menu-help"),
|
|
|
+ icon: renderIcon({ name: 'menu-help' }),
|
|
|
key: '/'
|
|
|
},
|
|
|
]
|
|
@@ -83,9 +81,7 @@ const handleUpdateValue = () => {
|
|
|
<template>
|
|
|
<n-menu
|
|
|
:options="menuOptions"
|
|
|
- :theme-overrides="menuThemeOverrides"
|
|
|
:icon-size="30"
|
|
|
- inverted
|
|
|
@update:value="handleUpdateValue"
|
|
|
>
|
|
|
</n-menu>
|
|
@@ -96,12 +92,49 @@ const handleUpdateValue = () => {
|
|
|
</style>
|
|
|
|
|
|
<style lang="scss">
|
|
|
+
|
|
|
+@mixin sub-menu-active {
|
|
|
+ .n-menu-item-content__icon {
|
|
|
+ .icon-default {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ .icon-active {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .n-menu-item-content-header {
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
.n-menu .n-menu-item-content:not(.n-menu-item-content--disabled):hover::before {
|
|
|
border: 1px solid #fff;
|
|
|
background: #FCFDFE;
|
|
|
}
|
|
|
+
|
|
|
+// 子菜单hover
|
|
|
+.n-submenu-children {
|
|
|
+ .n-menu-item-content:hover {
|
|
|
+ @include sub-menu-active();
|
|
|
+ }
|
|
|
+}
|
|
|
+// reset - 选中状态
|
|
|
+.n-menu-item-content--selected {
|
|
|
+ @include sub-menu-active();
|
|
|
+ &:not(.n-menu-item-content--disabled)::before {
|
|
|
+ border: 1px solid #fff;
|
|
|
+ background: #FCFDFE;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// reset - 选中状态
|
|
|
+// .n-menu-item-content--selected {
|
|
|
+// font-weight: bold;
|
|
|
+// }
|
|
|
// .n-base-icon {
|
|
|
-// background: url('@/assets/svgs/menu-arrow-bottom.svg') center center no-repeat;
|
|
|
+// background: url('@/assets/svgs/menu/arrow.svg') center center no-repeat;
|
|
|
// svg {
|
|
|
// display: none;
|
|
|
// }
|