<template>
  <div class="app-container">
    <div style="height: 20px"></div>

    <LogTable
      type="project"
      v-loading="listLoading"
      :scrapydServerId="scrapydServerId"
      :project="project"
      :data="list"
    />
  </div>
</template>


<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import LogTable from './LogTable.vue';
import { getProjectLogs } from '@/api/log';

const route = useRoute();
const scrapydServerId = ref('');
const project = ref('');
const list = ref<any[]>([]);
const listLoading = ref(true);

async function getData() {
  listLoading.value = true;

  try {
    const res = await getProjectLogs({
      project: project.value,
      scrapydServerId: scrapydServerId.value,
    });

    list.value = res.data;
  } catch (error) {
    console.error('获取项目日志失败:', error);
  } finally {
    listLoading.value = false;
  }
}

const handleStatusChange = () => {
  getData();
};

onMounted(() => {
  project.value = route.query.project as string;
  scrapydServerId.value = route.query.scrapydServerId as string;
  getData();
});
</script>

<style lang="scss" scoped></style>
