<template>
	<v-header />
	<v-sidebar />
	<div class="content-box" :class="{ 'content-collapse': sidebar.collapse }">
		<v-tabs></v-tabs>
		<div class="content">
			<router-view v-slot="{ Component }">
				<transition name="move" mode="out-in">
					<keep-alive :include="tabs.nameList">
						<component :is="Component"></component>
					</keep-alive>
				</transition>
			</router-view>
		</div>
	</div>
</template>
<script setup lang="ts">
import { useSidebarStore } from '@/store/sidebar';
import { useTabsStore } from '@/store/tabs';
import {getUserUIconfigInfoService} from '@/api/user';
import {UserUISettings} from '@/types/user';
import vHeader from '@/components/header.vue';
import vSidebar from '@/components/sidebar.vue';
import vTabs from '@/components/tabs.vue';

const getUserUIconfigInfo = async () => {
	let req = {
		token: localStorage.getItem('token'),
	}
	let res = await getUserUIconfigInfoService(req);
	if (res['code'] === 0){
		let settings: UserUISettings = res['data'];
		localStorage.setItem('userUIconfigInfo', JSON.stringify(settings));
	} else {
		localStorage.removeItem('userUIconfigInfo');
	}
}

getUserUIconfigInfo();
const sidebar = useSidebarStore();
const tabs = useTabsStore();
</script>

<style>
.content-box {
	position: absolute;
	left: 250px;
	right: 0;
	top: 70px;
	bottom: 0;
	padding-bottom: 30px;
	-webkit-transition: left 0.3s ease-in-out;
	transition: left 0.3s ease-in-out;
	background: #eef0fc;
}

.content {
	width: auto;
	height: 100%;
	padding: 20px;
	overflow-y: scroll;
	box-sizing: border-box;
}

.content::-webkit-scrollbar {
	width: 0;
}

.content-collapse {
	left: 65px;
}
</style>