<template>
	<div id="app">
		<el-container class="wrapper">
			<el-header>
				<nav class="navbar">
					<div class="nav-brand">
						<div class="brand-icon">
							<img src="@/assets/icons/header-logo.png" alt="" />
						</div>
						<div class="brand-text" @click="handleToHome">
							<div class="text-ch">某方向风险监测预警系统</div>
						</div>
					</div>
					<div class="user-info">
						<div class="email">
							<img src="@/assets/icons/header-icon.png" alt="" />
						</div>
						<div class="avator">
							<img src="@/assets/icons/header-avator.png" alt="" />
						</div>
						<span class="user">管理员</span>
					</div>
				</nav>
			</el-header>

			<el-main class="main-container">
				<router-view />
			</el-main>
				<div class="ai-btn" @click="openAiBox">
					<div class="icon">
						<img src="@/assets/icons/ai-icon.png" alt="" />
					</div>
					<div class="text">智能问答</div>
				</div>

			<div class="ai-dialog" v-if="isShowAiBox">
				<AiBox @close="closeAiBox" />
			</div>
		</el-container>
	</div>
</template>

<script setup>
import { ref, computed, onMounted } from "vue";
import { Monitor, House, User, Location, Document, Bell, Message, ArrowDown } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import Breadcrumb from "@/components/BreadCrumb/index.vue";
import AiBox from "./components/AiBox.vue";
import {getPersonType} from '@/api/common/index'
// import { useDraggable } from "@vueuse/core";

const router = useRouter();

// const target = ref(null);

// const { x, y, isDragging } = useDraggable(target, {
// 	initialValue: { x: 1770, y: 800 },
// 	onStart: () => console.log("开始拖动"),
// 	onEnd: () => console.log("结束拖动")
// });

// const style = computed(() => ({
// 	position: "absolute",
// 	left: `${x.value}px`,
// 	top: `${y.value}px`,
// 	cursor: isDragging.value ? "grabbing" : "grab"
// }));

const handleToHome = () => {
	router.push({
		path: "/overview"
	});
};

const isShowAiBox = ref(false);

const closeAiBox = () => {
	isShowAiBox.value = false;
};

const openAiBox = () => {
	isShowAiBox.value = true;
};

const handleHomeCommand = command => {
	router.push(command);
};

const personTypeList = ref([])

// 获取人物类别
const handleGetPersonType = async() => {
	try {
		const res = await getPersonType()
		console.log('res', res);
		if(res.code === 200) {
			personTypeList.value = res.data
		} else {
			personTypeList.value = []
		}
		window.sessionStorage.setItem('personTypeList', JSON.stringify(personTypeList.value))
		
	} catch (error) {
		
	}
}

onMounted(() => {
	handleGetPersonType()
})

</script>

<style>
/* 全局样式重置 */
* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
}

body {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.el-popover {
	width: 100%;
	font-family: "Microsoft YaHei";
	color: rgba(95, 101, 108, 1);
	font-style: Regular;
	font-size: 16px;
	font-weight: 400;
	line-height: 30px;
	letter-spacing: 0px;
	text-align: justify;
}

.el-popper[data-popper-placement^=top]>.el-popper__arrow:before {
	display: none;
}
</style>

<style lang="scss" scoped>
#app {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
	width: 100%;
	height: 100vh;
	// overflow-y: hidden;
}

/* 确保Element Plus容器组件占满宽度 */
.el-container {
	width: 100%;
	height: 100%;
}

.navbar {
	display: flex;
	justify-content: center;
	align-items: center;
	background: white;
	color: #333;
	height: 100%;
	border-bottom: 1px solid #e5e7eb;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	position: relative;
	box-sizing: border-box;
	height: 96px;
}

.main-container {
	/* 移除宽度限制，让子页面自己控制布局 */
	width: 100%;
	height: 984px;
	position: relative;
}

.nav-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	position: absolute;
	left: 160px;

	.brand-icon {
		width: 48px;
		height: 48px;

		img {
			width: 100%;
			height: 100%;
		}
	}
}

.brand-icon {
	font-size: 24px;
	color: #1e3a8a;
}

.brand-text {
	cursor: pointer;

	.text-ch {
		height: 37px;
		color: rgba(10, 18, 30, 1);
		font-family: Microsoft YaHei;
		font-size: 32px;
		font-weight: 700;
		line-height: 37px;
	}

	.text-en {
		color: rgba(10, 18, 30, 1);
		font-family: Microsoft YaHei;
		font-size: 10px;
		font-weight: 400;
		line-height: 13px;
	}
}

.nav-menu {
	display: flex;
	align-items: center;
	gap: 32px;
}

.nav-link {
	display: flex;
	align-items: center;
	gap: 6px;
	color: #333;
	text-decoration: none;
	padding: 8px 12px;
	border-radius: 6px;
	transition: all 0.3s;
	font-size: 14px;
	cursor: pointer;
}

.nav-link:hover,
.nav-link.router-link-active {
	background-color: #1459bb;
	color: #fff;
}

.home-dropdown {
	display: inline-block;
}

.dropdown-trigger {
	cursor: pointer;
}

.dropdown-arrow {
	font-size: 12px;
	margin-left: 4px;
	transition: transform 0.3s;
}

.home-dropdown:hover .dropdown-arrow {
	transform: rotate(180deg);
}

.user-info {
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 8px 12px;
	border-radius: 6px;
	color: #333;
	position: absolute;
	right: 37px;

	.email {
		width: 20px;
		height: 20px;

		img {
			width: 100%;
			height: 100%;
		}
	}

	.avator {
		width: 32px;
		height: 32px;

		img {
			width: 100%;
			height: 100%;
		}
	}

	.user {
		color: rgba(59, 65, 75, 1);
		font-family: Microsoft YaHei;
		font-size: 16px;
		font-weight: 400;
		line-height: 30px;
	}
}

.wrapper {
	position: relative;
	.target {
		// position: absolute;
		// bottom: 20%;
		// right: 46px;
		z-index: 9999;
	}

	.ai-btn {
		position: absolute;
		bottom: 240px;
		right: 10px;
		z-index: 9999;
		cursor: pointer;

		.icon {
			width: 96px;
			height: 96px;

			img {
				width: 100%;
				height: 100%;
			}
		}

		.text {
			margin-top: -15px;
			height: 24px;
			color: rgba(59, 65, 75, 1);
			font-family: Microsoft YaHei;
			font-size: 16px;
			font-weight: 400;
			line-height: 24px;
			text-align: center;
		}
	}

	.ai-dialog {
		position: absolute;
		right: 100px;
		top: 100px;
		z-index: 9999;
	}
}

.el-header {
	padding: 0;
	height: 96px;
	position: relative;
	z-index: 1;
}

.el-main {
	padding: 0;
	height: calc(100vh - 96px);
	overflow: hidden;
	overflow-y: auto;
	background-color: rgba(246, 251, 255, 1);
}
</style>
