|
@@ -1,25 +1,47 @@
|
|
|
<script setup>
|
|
|
import { ref } from 'vue'
|
|
|
import { useRouter,useRoute } from 'vue-router'
|
|
|
+import { usePermissionMenu } from '@/hooks/usePermissionMenu'
|
|
|
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
|
|
|
+const { getPermissionMenu } = usePermissionMenu()
|
|
|
+
|
|
|
const emit = defineEmits(['change'])
|
|
|
|
|
|
const menu = [
|
|
|
{
|
|
|
title: 'ETA图库',
|
|
|
path: '/etaChart/favorite',
|
|
|
- icon:'chart'
|
|
|
+ icon:'chart',
|
|
|
+ menu_map: '/etaChart/index'
|
|
|
},
|
|
|
{
|
|
|
title: 'ETA研报',
|
|
|
path: '/etaReport/favorite',
|
|
|
- icon:'report'
|
|
|
+ icon:'report',
|
|
|
+ menu_map: '/etaReport/index'
|
|
|
},
|
|
|
]
|
|
|
const activeMenu = ref(route.path)
|
|
|
+watch(() => route.path,
|
|
|
+ (newpath) => {
|
|
|
+ activeMenu.value = newpath
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+const permissionMenu = ref([])
|
|
|
+async function init() {
|
|
|
+ const res = await getPermissionMenu()
|
|
|
+ const arr = res || [];
|
|
|
+ if(arr.length) {
|
|
|
+ let pathArr = arr.map(_ => _.path);
|
|
|
+ permissionMenu.value = menu.filter(_=>pathArr.includes(_.menu_map));
|
|
|
+ router.replace(permissionMenu.value[0].path)
|
|
|
+ }
|
|
|
+}
|
|
|
+init()
|
|
|
|
|
|
function handleClickItem(value) {
|
|
|
router.push(value)
|
|
@@ -28,7 +50,7 @@ function handleClickItem(value) {
|
|
|
<template>
|
|
|
<div class="left-aslide">
|
|
|
<t-menu v-model="activeMenu" theme="light" @change="handleClickItem" width="200px">
|
|
|
- <t-menu-item :value="item.path" v-for="item in menu" :key="item.path">
|
|
|
+ <t-menu-item :value="item.path" v-for="item in permissionMenu" :key="item.path">
|
|
|
<svg-icon
|
|
|
:name="item.icon"
|
|
|
style="font-size:20px;margin-right:10px;"
|