<template>
  <div class="container-box">
    <div class="header-bar">
      <h2>站点设置</h2>
    </div>

    <el-divider></el-divider>

    <div class="settings-container">
      <el-tabs v-model="activeTab" class="settings-tabs">
        <el-tab-pane label="基本信息" name="basic">
          <normalSettings
            ref="normalSettingsRef"
            v-if="activeTab === 'basic'"
          />
        </el-tab-pane>

        <el-tab-pane label="SEO设置" name="seo">
          <seoSettings ref="seoSettingsRef" v-if="activeTab === 'seo'" />
        </el-tab-pane>

        <el-tab-pane label="联系方式" name="contact">
          <contactSettings
            ref="contactSettingsRef"
            v-if="activeTab === 'contact'"
          />
        </el-tab-pane>

        <el-tab-pane label="登录验证" v-if="roleId === 1" name="loginVerification">
          <loginVerificationSettings
            ref="loginVerificationSettingsRef"
            v-if="activeTab === 'loginVerification'"
          />
        </el-tab-pane>

        <el-tab-pane label="法律声明&隐私条款" name="legalNotice">
          <legalNoticeSettings
            ref="legalNoticeSettingsRef"
            v-if="activeTab === 'legalNotice'"
          />
        </el-tab-pane>

        <el-tab-pane label="其他设置" name="other">
          <otherSettings ref="otherSettingsRef" v-if="activeTab === 'other'" />
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import normalSettings from "./components/normalSettings.vue";
import seoSettings from "./components/seoSettings.vue";
import contactSettings from "./components/contactSettings.vue";
import otherSettings from "./components/otherSettings.vue";
import legalNoticeSettings from "./components/legalNotice.vue";
import loginVerificationSettings from "./components/loginVerification.vue";
import { useAuthStore } from '@/stores/auth';

const authStore = useAuthStore();
const roleId = computed(() => Number(authStore.user?.rid) || 0);
const activeTab = ref("basic");
</script>

<style lang="less" scoped>
.container-box {
  padding: 20px;
  border-radius: 4px;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--el-text-color-primary);

  h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
  }
}

.settings-container {
  margin-top: 20px;
}

.settings-tabs {
  :deep(.el-tabs__header) {
    margin-bottom: 20px;
  }

  :deep(.el-tabs__nav-wrap::after) {
    height: 1px;
  }
}
</style>
