|
|
@@ -1,16 +1,23 @@
|
|
|
<template>
|
|
|
<div class="side-wp">
|
|
|
- <lay-menu class="menu-wp" v-model:selected-key="selectedKey" theme="light" v-model:openKeys="openKeys" :tree="true">
|
|
|
+ <div class="menu_switch_wp" @click="handeCwitchCollapse()">
|
|
|
+ <lay-icon size="12px" :type="collapse ? 'layui-icon-right' : 'layui-icon-left'" />
|
|
|
+ </div>
|
|
|
+ <lay-menu class="menu-wp" :selected-key="selectedKey" theme="light" v-model:openKeys="openKeys" :collapse="collapse" :tree="true">
|
|
|
<template v-for="item in list">
|
|
|
<lay-menu-item :id="item.path" v-if="item.childMenu.length == 0" @click="jumpPage(item)">
|
|
|
- <template #title>
|
|
|
+ <template #icon>
|
|
|
<lay-icon :type="item.icon" />
|
|
|
+ </template>
|
|
|
+ <template #title>
|
|
|
{{ item.name }}
|
|
|
</template>
|
|
|
</lay-menu-item>
|
|
|
<lay-sub-menu :id="item.path" v-else>
|
|
|
- <template #title>
|
|
|
+ <template #icon>
|
|
|
<lay-icon :type="item.icon" />
|
|
|
+ </template>
|
|
|
+ <template #title>
|
|
|
{{ item.name }}
|
|
|
</template>
|
|
|
<lay-menu-item :id="items.path" v-for="items in item.childMenu" @click="jumpPage(items)">
|
|
|
@@ -23,9 +30,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, defineProps, watchEffect } from "vue";
|
|
|
+import { ref, defineProps, defineExpose, watchEffect, defineEmits } from "vue";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
|
+const emit = defineEmits(["collapse"]);
|
|
|
+
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
|
|
|
@@ -41,6 +50,7 @@ interface MenuList {
|
|
|
|
|
|
const openKeys = ref<Array<string>>([]);
|
|
|
const selectedKey = ref();
|
|
|
+const collapse = ref<boolean>(JSON.parse(window.sessionStorage.getItem("_4L_MENU_COLLAPSE") || "false"));
|
|
|
|
|
|
defineProps({
|
|
|
list: Array<MenuList>,
|
|
|
@@ -51,8 +61,10 @@ watchEffect(() => {
|
|
|
openKeys.value = [`/${route.fullPath.split("/")[1]}`];
|
|
|
});
|
|
|
|
|
|
-const jumpPage = (menu: any) => {
|
|
|
- router.push({ path: menu.path, query: menu.query });
|
|
|
+const handeCwitchCollapse = () => {
|
|
|
+ collapse.value = !collapse.value;
|
|
|
+ window.sessionStorage.setItem("_4L_MENU_COLLAPSE", JSON.stringify(collapse.value));
|
|
|
+ emit("collapse", collapse.value);
|
|
|
};
|
|
|
|
|
|
const setSelectedKey = () => {
|
|
|
@@ -68,15 +80,40 @@ const setSelectedKey = () => {
|
|
|
jumpPage(defaultMenu);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+const jumpPage = (menu: any) => {
|
|
|
+ router.push({ path: menu.path, query: menu.query });
|
|
|
+};
|
|
|
+
|
|
|
setSelectedKey();
|
|
|
+
|
|
|
+defineExpose({ collapse });
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.side-wp {
|
|
|
+ position: relative;
|
|
|
box-sizing: border-box;
|
|
|
- overflow: hidden;
|
|
|
height: 100%;
|
|
|
width: 100%;
|
|
|
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
|
+ .menu_switch_wp {
|
|
|
+ position: absolute;
|
|
|
+ right: -12px;
|
|
|
+ top: 40px;
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ font-size: 0;
|
|
|
+ line-height: 24px;
|
|
|
+ background: #ffffff;
|
|
|
+ color: rgba(51, 51, 51, 0.25);
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 50%;
|
|
|
+ z-index: 2;
|
|
|
+ box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.05), 0 1px 4px -1px rgba(25, 15, 15, 0.07), 0 0 1px 0 rgba(0, 0, 0, 0.08);
|
|
|
+ &:hover {
|
|
|
+ color: rgba(51, 51, 51, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
.menu-wp {
|
|
|
box-sizing: border-box;
|
|
|
padding: 0;
|