52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
|
|
import { h, ref, onMounted, reactive, watch, toRaw, nextTick } from "vue";
|
||
|
|
import { request } from "@/utils/request";
|
||
|
|
import { Search } from "@element-plus/icons-vue";
|
||
|
|
import { useRoute, useRouter } from 'vue-router'
|
||
|
|
|
||
|
|
const menuList = ref([])
|
||
|
|
|
||
|
|
// 获取菜单列表
|
||
|
|
const getMenuList = async () => {
|
||
|
|
try {
|
||
|
|
const res = await request({
|
||
|
|
url: '/snow-ops-platform/menu/getMenus',
|
||
|
|
method: 'GET'
|
||
|
|
})
|
||
|
|
if (res.code === '00000') {
|
||
|
|
menuList.value = res.data
|
||
|
|
} else {
|
||
|
|
throw new Error(res.message)
|
||
|
|
}
|
||
|
|
} catch (error) {
|
||
|
|
ElMessage.error(error.message);
|
||
|
|
console.log(error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
export default () => {
|
||
|
|
|
||
|
|
// 点击菜单处理
|
||
|
|
const router = useRouter();
|
||
|
|
const handleMenuClick = (menu) => {
|
||
|
|
console.log('menu', menu)
|
||
|
|
if (menu.path) {
|
||
|
|
router.push({
|
||
|
|
path: menu.path,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
onMounted(() => {
|
||
|
|
getMenuList()
|
||
|
|
})
|
||
|
|
|
||
|
|
return {
|
||
|
|
menuList,
|
||
|
|
handleMenuClick,
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
};
|