<template>
  <div class="quick-login-container">
    <div class="loading-overlay">
      <div class="loading-content">
        <el-loading-spinner class="loading-spinner"></el-loading-spinner>
        <p class="loading-text">登录中...</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { autoLogin } from '@/utils/loginUtils.js'

const router = useRouter()

// 测试账号信息
const testAccount = {
  tenantName: import.meta.env.VITE_APP_TITLE,
  username: import.meta.env.VITE_APP_PROPAGATION_LOGIN_USERNAME,
  password: import.meta.env.VITE_APP_PROPAGATION_LOGIN_PASSWORD
}

// 组件挂载时立即执行自动登录
onMounted(async () => {
  await autoLogin(
      testAccount.tenantName,
      testAccount.username,
      testAccount.password,
      router,
      {
        path: '/ai-develop',
        state: {
          typeId: 5,
          typeName: 'AI时光旅行',
          typeSort: '02'
        }
      }
  )
})
</script>

<style scoped>
.quick-login-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(to bottom, #001169, #8a78d0);
}

.loading-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
}

.loading-text {
  font-size: 18px;
  font-weight: 500;
}
</style>