<template>
  <div class="news-container">
    <el-card class="news-card">
      <el-tabs v-model="activeTab" @tab-click="handleTabClick">
        <el-tab-pane label="文章管理" name="article">
          <ArticlePanel />
        </el-tab-pane>
        <el-tab-pane label="分类管理" name="category">
          <CategoryPanel />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import ArticlePanel from '../components/article/ArticlePanel.vue'
import CategoryPanel from '../components/category/CategoryPanel.vue'

export default defineComponent({
  name: 'NewsManagement',
  components: {
    ArticlePanel,
    CategoryPanel
  },
  setup() {
    const router = useRouter()
    const route = useRoute()
    const activeTab = ref(route.query.tab || 'article')

    const handleTabClick = () => {
      router.push({ 
        path: '/news', 
        query: { tab: activeTab.value } 
      })
    }

    return {
      activeTab,
      handleTabClick
    }
  }
})
</script>

<style scoped>
.news-container {
  padding: 20px;
}

.news-card {
  margin-bottom: 20px;
}
</style>
