Files
admin-govern/src/views/auth/menu/index.vue

39 lines
1.0 KiB
Vue
Raw Normal View History

2023-12-22 16:19:33 +08:00
<template>
2024-01-18 18:19:59 +08:00
<div class='default-main' style='display: flex' v-loading='loading'>
<Menu style='width: 500px' @init='init' @select='select' :menu-data='menuData' />
<Api style='width: calc(100% - 500px)' @init='init' :id='selectedId' />
2023-12-27 15:06:57 +08:00
</div>
2023-12-22 16:19:33 +08:00
</template>
2024-01-18 18:19:59 +08:00
<script setup lang='ts'>
import { functionTree } from '@/api/user-boot/function'
import Menu from './menu.vue'
import Api from './api.vue'
import { provide, reactive, ref } from 'vue'
2023-12-26 16:17:30 +08:00
2023-12-22 16:19:33 +08:00
defineOptions({
name: 'auth/menu'
})
2024-01-18 18:19:59 +08:00
const menuData = ref<any[]>([])
const selectedId = ref('')
const loading = ref(true)
const select = (id: string) => {
selectedId.value = id
}
const filterData = (arr: any[]) => {
return arr.filter((item: any) => {
if (item.children.length) {
item.children = filterData(item.children)
2024-01-05 16:28:23 +08:00
}
2024-01-18 18:19:59 +08:00
return item.type === 0
})
}
const init = () => {
loading.value = true
functionTree().then(res => {
menuData.value = filterData(res.data)
loading.value = false
})
2023-12-27 10:39:40 +08:00
}
2024-01-18 18:19:59 +08:00
init()
2023-12-22 16:19:33 +08:00
</script>