index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <div class="news-container">
  3. <el-card class="news-card">
  4. <el-tabs v-model="activeTab" @tab-click="handleTabClick">
  5. <el-tab-pane label="文章管理" name="article">
  6. <ArticlePanel />
  7. </el-tab-pane>
  8. <el-tab-pane label="分类管理" name="category">
  9. <CategoryPanel />
  10. </el-tab-pane>
  11. </el-tabs>
  12. </el-card>
  13. </div>
  14. </template>
  15. <script>
  16. import { defineComponent, ref } from 'vue'
  17. import { useRouter, useRoute } from 'vue-router'
  18. import ArticlePanel from '../components/article/ArticlePanel.vue'
  19. import CategoryPanel from '../components/category/CategoryPanel.vue'
  20. export default defineComponent({
  21. name: 'NewsManagement',
  22. components: {
  23. ArticlePanel,
  24. CategoryPanel
  25. },
  26. setup() {
  27. const router = useRouter()
  28. const route = useRoute()
  29. const activeTab = ref(route.query.tab || 'article')
  30. const handleTabClick = () => {
  31. router.push({
  32. path: '/news',
  33. query: { tab: activeTab.value }
  34. })
  35. }
  36. return {
  37. activeTab,
  38. handleTabClick
  39. }
  40. }
  41. })
  42. </script>
  43. <style scoped>
  44. .news-container {
  45. padding: 20px;
  46. }
  47. .news-card {
  48. margin-bottom: 20px;
  49. }
  50. </style>