<template>
	<div>
		<!-- <component :is="compName"></component> -->
		<component :is="currentComponent"></component>
	</div>
</template>

<script setup>
	import {
		ref,
		onMounted,
		getCurrentInstance,
		defineAsyncComponent
	} from 'vue'
	const {
		proxy
	} = getCurrentInstance()


	onMounted(() => {
		getDeptPost()
		getCabin()
	})

	const compName = ref('')

	const getDeptPost = () => {
		var url = 'framework/SysDepartment/queryDeptPostByUserId'
		var param = {}
		proxy.$axios.get(url, param).then(response => {
			if (response.data.code == 0) {
				// this.$store.commit('setPost', response.data.data.post)
				// this.$store.commit('setDept', response.data.data.dept)
				localStorage.setItem('post', JSON.stringify(response.data.data.post))
				localStorage.setItem('dept', JSON.stringify(response.data.data.dept))
				localStorage.setItem('deptTree', JSON.stringify(response.data.data.deptTree))
			} else {
				localStorage.setItem('post', JSON.stringify([]))
				localStorage.setItem('dept', JSON.stringify([]))
				localStorage.setItem('deptTree', JSON.stringify([]))
			}

		})
	}
	const currentComponent = ref('')
	const getCabin = () => {
		// var userType = localStorage.getItem('userType')
		var userType = '0'
		var path = ''
		switch (userType) {
			case '1':
				path = '/frame/test'
				break
			case '2':
				path = ''
				break
			case '3':
				path = ''
				break
			case '4':
				path = ''
				break
			default:
				path = '/frame/cabin'
				break
		}

		currentComponent.value = defineAsyncComponent(() =>
			import(`..${path}.vue`)
		)

	}
</script>
<style>
</style>