2025-11-07 17:27:41 +08:00
|
|
|
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,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-07 18:13:40 +08:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await getMenuList();
|
|
|
|
|
const firstMenuItem = menuList.value[0]?.children?.[0];
|
|
|
|
|
if (firstMenuItem) {
|
|
|
|
|
handleMenuClick(firstMenuItem);
|
|
|
|
|
}
|
2025-11-07 17:27:41 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
menuList,
|
|
|
|
|
handleMenuClick,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|