<!-- app/pages/dashboard.vue - 运行状态与最近问答记录页面 -->
<script lang="ts" setup>
import QaRecordDetail from "@/components/dashboard/QaRecordDetail.vue";
import QaRecordsTable from "@/components/dashboard/QaRecordsTable.vue";
import StatsOverview from "@/components/dashboard/StatsOverview.vue";
import { useAnswerStore } from "@/stores/answer";

definePageMeta({ middleware: "auth" });

const answerStore = useAnswerStore();

useHead({
  title: "Dashboard - OCS AI 答题服务"
});

/**
 * 客户端 ready 后加载 Dashboard 数据
 *
 * Dashboard 数据来自当前运行中的 Nitro 进程；放到客户端 ready 阶段可以避免
 * `nuxt build` 在构建期等待运行态请求，同时刷新页面后仍会自动拉取真实状态。
 */
if (import.meta.client) {
  onNuxtReady(() => {
    void answerStore.loadDashboard();
  });
}
</script>

<template>
  <div class="grid gap-6">
    <StatsOverview />
    <QaRecordsTable />
    <QaRecordDetail />
  </div>
</template>
