<template>
  <div>
    <el-config-provider :locale="elementPlusLocale">
      <NuxtLayout>
        <NuxtPage />
      </NuxtLayout>
    </el-config-provider>
  </div>
</template>

<script setup lang="ts">
import { ElConfigProvider } from "element-plus";

const { login } = useStrapiAuth();

const { getElementPlusLocale } = useLocalizations();

const elementPlusLocale = getElementPlusLocale();

onMounted(() => {
  // 检查用户是否已登录
  const user = useStrapiUser();
  if (!user.value) {
    // 如果未登录，重定向到登录页面
    login({ identifier: "remilia", password: "huanshuo51" })
      .then(() => {
        console.log("Login successful");
      })
      .catch((error) => {
        console.error("Login failed:", error);
      });
  } else {
    console.log("User is already logged in:", user.value);
  }
});
</script>
