<template>
  <div class="app-container">
    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      router
    >
      <el-menu-item index="/dashboard">控制台</el-menu-item>
      <el-menu-item index="/kb">知识库管理</el-menu-item>
      <el-menu-item index="/rag-lab">RAG 实验室</el-menu-item>
      <el-menu-item index="/monitoring">会话监控</el-menu-item>
      <el-menu-item index="/admin/embedding">嵌入模型配置</el-menu-item>
      <div class="flex-grow" />
      <div class="tenant-selector">
        <el-select v-model="currentTenantId" placeholder="选择租户" @change="handleTenantChange">
          <el-option label="默认租户" value="default" />
          <el-option label="租户 A" value="tenant_a" />
          <el-option label="租户 B" value="tenant_b" />
        </el-select>
      </div>
    </el-menu>
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import { useTenantStore } from '@/stores/tenant'

const route = useRoute()
const tenantStore = useTenantStore()

const activeIndex = computed(() => route.path)
const currentTenantId = ref(tenantStore.currentTenantId)

const handleTenantChange = (val: string) => {
  tenantStore.setTenant(val)
}
</script>

<style scoped>
.flex-grow {
  flex-grow: 1;
}
.tenant-selector {
  display: flex;
  align-items: center;
  padding: 0 20px;
}
.app-container {
  padding: 20px;
}
</style>
