点击菜单显示路由中的菜单(隐藏)

master
贾肃 5 months ago
parent f105bc4a99
commit 27ad3c1c7a
  1. 48
      src/components/Hamburger/index.vue
  2. 1
      src/utils/ruoyi.js

@ -1,16 +1,16 @@
<template> <template>
<div style="padding: 0 15px;"> <div style="padding: 0 15px;">
<i-menu-unfold-one @contextmenu.prevent.stop="toggleClick" @click="showDrawer = !showDrawer" class="hamburger" <i-menu-unfold-one @contextmenu.prevent.stop="toggleClick" @click="showDrawer = !showDrawer" class="hamburger"
:class="{'is-active':isActive}" theme="outline" size="22" fill="#FFFFFF"/> :class="{'is-active':isActive}" theme="outline" size="22" :fill="fill"/>
<div> <div>
<el-drawer v-model="showDrawer" direction="ltr" append-to-body style="top: 50px" :z-index="165" <el-drawer v-model="showDrawer" direction="ltr" append-to-body style="top: 50px;height: calc(100% - 50px)" :z-index="165"
:with-header="false"> :with-header="false">
<div> <div>
<div class="classify" style="margin-top: 0;"> <div class="classify" style="margin-top: 0;">
<i-system theme="outline" size="24" fill="#333"/> <i-system theme="outline" size="24" fill="#333"/>
<el-link style="color: #000000 !important;font-size: 16px" @click="openRouter('/index')"></el-link> <el-link style="color: #000000 !important;font-size: 16px" @click="openRouter('/index')"></el-link>
</div> </div>
<div v-for="item in menuList" :key="item.label"> <div v-if="true" v-for="item in menuList" :key="item.label">
<div class="classify"> <div class="classify">
<i-system theme="outline" size="24" fill="#333"/> <i-system theme="outline" size="24" fill="#333"/>
{{ item.label }} {{ item.label }}
@ -25,6 +25,23 @@
</el-row> </el-row>
</div> </div>
</div> </div>
<div v-else v-for="item in sidebarRouters" :key="item.path">
<div v-if="!item.hidden && item.redirect !== '/index'">
<div class="classify">
<i-system theme="outline" size="24" fill="#333"/>
{{ item.meta?.title }}
</div>
<div class="children">
<el-row v-if="item.children" :gutter="20">
<el-col v-for="child in item.children" :key="child.path" :span="8">
<div class="children-item">
<el-link @click="openRouter(`${item.path}/${child.path}`)">{{ child.meta?.title }}</el-link>
</div>
</el-col>
</el-row>
</div>
</div>
</div>
</div> </div>
</el-drawer> </el-drawer>
@ -33,15 +50,24 @@
</template> </template>
<script setup> <script setup>
import usePermissionStore from "@/store/modules/permission.js";
import {isExternal} from "@/utils/validate.js";
defineProps({ defineProps({
isActive: { isActive: {
type: Boolean, type: Boolean,
default: false default: false
} },
fill:{
type: String,
default: '#FFF'
}
}) })
const emit = defineEmits(['toggleClick']) const emit = defineEmits(['toggleClick'])
const showDrawer = ref(false) const showDrawer = ref(false)
const permissionStore = usePermissionStore()
const sidebarRouters = computed(() => permissionStore.sidebarRouters);
const menuList = ref([ const menuList = ref([
{ {
label: '基础数据管理', children: [ label: '基础数据管理', children: [
@ -74,9 +100,15 @@ const menuList = ref([
]) ])
const router = useRouter(); const router = useRouter();
const openRouter = (href) => { const openRouter = (href) => {
if (href){ console.log(href);
router.push(href) if (href){
showDrawer.value = false if (isExternal(href)) {
window.open(href)
}else {
router.push(href)
showDrawer.value = false
}
} }
} }
const toggleClick = () => { const toggleClick = () => {

@ -268,7 +268,6 @@ export function resBgColor(rgbArr) {
* @param colorValue * @param colorValue
*/ */
export function findTextColor(colorValue) { export function findTextColor(colorValue) {
console.log(colorValue);
// #123456或者rgb(12,34,56)转为rgb数组[12,34,56] // #123456或者rgb(12,34,56)转为rgb数组[12,34,56]
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
var that = colorValue; var that = colorValue;

Loading…
Cancel
Save