<script setup>
import { computed } from "vue";
import { useRoute } from "vue-router";
import HospitalLayout from "@/components/layout/HospitalLayout.vue";
import AdminLayout from "@/components/layout/AdminLayout.vue";
// 导入 Element Plus 语言包
import zhCn from "element-plus/es/locale/lang/zh-cn";
const route = useRoute();

// 当前路由使用的布局类型（来自 meta.layoutType）
const layoutType = computed(() => {
  if (route.meta?.layout === false) return "none";
  return route.meta?.layoutType || "none";
});
</script>

<template>
  <el-config-provider :locale="zhCn">
    <router-view v-slot="{ Component }">
      <!-- 无布局：登录页 -->
      <component v-if="layoutType === 'none' || !Component" :is="Component" />

      <!-- 医院端：顶部菜单布局 -->
      <HospitalLayout v-else-if="layoutType === 'hospital'">
        <component :is="Component" />
      </HospitalLayout>

      <!-- 管理端：侧边栏布局 -->
      <AdminLayout v-else-if="layoutType === 'admin'">
        <component :is="Component" />
      </AdminLayout>

      <!-- 兜底 -->
      <component v-else :is="Component" />
    </router-view>
  </el-config-provider>
</template>

<style></style>
