From cae892f7fa165fadbf0c4e8928846f715cda7a88 Mon Sep 17 00:00:00 2001
From: 明梦爽 <2972214568@qq.com>
Date: 星期三, 23 三月 2022 18:29:30 +0800
Subject: [PATCH] 增加介绍文档

---
 src/components/Home.vue |   97 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 63 insertions(+), 34 deletions(-)

diff --git a/src/components/Home.vue b/src/components/Home.vue
index 4038afd..3e42a65 100644
--- a/src/components/Home.vue
+++ b/src/components/Home.vue
@@ -11,20 +11,8 @@
     </el-header>
     <!-- 涓婚〉瀵艰埅鏍� -->
     <el-row>
-      <el-menu
-        mode="horizontal"
-        background-color="rgb(64, 112, 186)"
-        text-color="white"
-        class="menu"
-        active-text-color="#000000"
-        :default-active="activeIndex"
-        @select="handleSelect"
-      >
-        <el-menu-item
-          :key="index"
-          v-for="(item, index) in menuList"
-          :index="item.index"
-        >
+      <el-menu mode="horizontal" background-color="rgb(64, 112, 186)" text-color="white" class="menu" active-text-color="#000000" :default-active="activeIndex" @select="handleSelect">
+        <el-menu-item :key="index" v-for="(item, index) in menuList" :index="(item.id).toString()">
           {{ item.name }}
         </el-menu-item>
       </el-menu>
@@ -40,37 +28,78 @@
 </template>
 
 <script>
+import {getNavList} from '../api/api'
+import axios from 'axios'
 export default {
   name: '',
   data() {
     return {
-      activeIndex: 'index',
-      menuList: [
-        { index: 'index', name: '棣栭〉' },
-        { index: 'introduce', name: '绉戝崗姒傚喌' },
-        { index: 'zhengce', name: '鏀跨瓥娉曡' },
-        { index: 'keXieXiangMu', name: '绉戝崗椤圭洰' },
-        { index: 'xueShuJiaoLiu', name: '瀛︽湳浜ゆ祦' },
-        { index: 'banShiZhiNan', name: '鍔炰簨鎸囧崡' },
-        { index: 'kePu', name: '绉戞櫘椋庨噰' },
-        { index: 'xueXiaoShouYe', name: '瀛︽牎棣栭〉' },
-        { index: 'telephone', name: '鑱旂郴鎴戜滑' }
-      ]
+      activeIndex: '1',
+      menuList: [{name: '棣栭〉',id: 1},{name: '绉戝崗姒傚喌',id: 22},{name: '鏀跨瓥娉曡',id: 23},{name: '绉戝崗椤圭洰',id: 24},
+      {name: '瀛︽湳浜ゆ祦',id: 25},{name: '鍔炰簨鎸囧崡',id: 26},{name: '绉戞櫘椋庨噰',id: 27},{name: '瀛︽牎棣栭〉',id: 28},
+      {name: '鑱旂郴鎴戜滑',id: 29}],
+      menuList2:[]
     }
   },
-  created() {},
-  mounted() {},
+  created() {
+    // this.getNavArr();
+  },
+  mounted() {
+    let api3 = 'http://localhost:7070/news_type/all'
+    axios.get(api3).then((res)=>{
+      // console.log(res);
+      this.menuList2 = res.data.data
+    }).catch((error)=>{
+      console.log(error);
+    })
+  },
   watch: {},
   methods: {
+    // //鑾峰彇瀵艰埅鏍�
+    // getNavArr(){
+    //   const data ={};
+    //   getNavList(data).then(res => {
+    //     console.log('res', res)
+    //     if(res.code == 200){
+    //       this.menuList2 = res.data.data
+    //     }
+    //     this.menuList2 = res.data.data
+    //   }).catch(err => {
+    //     console.log('err', err)
+    //   })
+    // },
+    
+    formatterTitle(t){
+      switch(t){
+        case '1':
+          return 'index'
+        case '22':
+          return 'introduce'
+        case '23':
+          return 'zhengce'
+        case '24':
+          return 'keXieXiangMu'
+        case '25':
+          return 'xueShuJiaoLiu'
+        case '26':
+          return 'banShiZhiNan'
+        case '27':
+          return 'kePuFengCai'
+        case '28':
+          return 'xueXiaoShouYe'
+        case '29':
+          return 'telephone'
+      }
+    },
     handleSelect(key, keyPath) {
-      console.log(key, keyPath)
-      if (key == 'xueXiaoShouYe') {
-        window.location.href = 'https://www.pdsu.edu.cn/#'
+      if (key == '28') {
+        window.open('https://www.pdsu.edu.cn/#')
       } else {
         this.$router.push({
-          path: '/home/' + key,
+          path: '/home/' + this.formatterTitle(key),
           query: {
-            title: key
+            title: this.formatterTitle(key),
+            id:key
           }
         })
       }
@@ -88,7 +117,7 @@
 }
 .el-header {
   height: 120px !important;
-  padding: 0 40px;
+  padding: 0 80px 0 120px;
   overflow: hidden;
   display: flex;
   justify-content: space-between;

--
Gitblit v1.8.0