<script setup lang="ts">
import { computed, onMounted } from "vue";
import { RouterLink, RouterView } from "vue-router";
import SpcInputPanel from "./components/SpcInputPanel.vue";
import { useSpc } from "./composables/useSpc";
import { routes } from "./router";

const { result, runSpc } = useSpc();
const navRoutes = computed(() => routes.filter((route) => route.path !== "/" && route.meta?.title));

onMounted(() => {
  if (!result.value) {
    void runSpc();
  }
});
</script>

<template>
  <div class="app-shell">
    <header class="topbar">
      <div>
        <p class="eyebrow">SPC Vue</p>
        <h1>SPC 控制图验证</h1>
      </div>
      <nav class="nav-tabs" aria-label="控制图页面">
        <RouterLink v-for="route in navRoutes" :key="route.path" :to="route.path">
          {{ route.meta?.title }}
        </RouterLink>
      </nav>
    </header>

    <main class="workspace">
      <SpcInputPanel />
      <section class="content-pane">
        <RouterView />
      </section>
    </main>
  </div>
</template>
