浏览代码

修改进入列表时判断类型是不是单页,是就跳走

asd123a20 2 年之前
父节点
当前提交
800fdb19b2
共有 4 个文件被更改,包括 65 次插入43 次删除
  1. 2 2
      src/components/breadcrumb/index.vue
  2. 2 2
      src/components/leftmenu/index.vue
  3. 49 38
      src/views/list.vue
  4. 12 1
      src/views/pages.vue

+ 2 - 2
src/components/breadcrumb/index.vue

@@ -35,8 +35,8 @@ export default {
 
 <style lang="scss" scoped>
 .headsBreadcrumb {
-  width: 65%;
-  margin: 0 auto;
+  width: 70%;
+  // margin: 0 auto;
   margin-top: 2%;
 }
 </style>

+ 2 - 2
src/components/leftmenu/index.vue

@@ -62,12 +62,12 @@ export default {
     background: url('../../assets/newbg.jpg');
     background-size: 100% 100%;
     color: #fff;
-    width: 70%;
+    width: 100%;
     margin: 0 auto;
     line-height: 3em;
   }
   .el-menu {
-    width: 70%;
+    width: 100%;
     margin: 0 auto;
     // display: flex;
     border: none;

+ 49 - 38
src/views/list.vue

@@ -48,13 +48,16 @@ export default {
   async mounted() {
     // 当前菜单参数
     this.code = this.$route.params.code;
-    // 顶级菜单参数
-    this.parentCode = this.$route.query.parentCode;
-    await this.filterQuery();
-    // 获取一例菜单
-    this.menu = this.$setChildrenSession({ menus: this.menusall, iscode: this.parentCode });
-    // 控制左侧菜单当前选项
-    this.$refs.letnav.setIndex();
+    const topahes = await this.topage();
+    if (topahes) {
+      // 顶级菜单参数
+      this.parentCode = this.$route.query.parentCode;
+      await this.filterQuery();
+      // 获取一例菜单
+      this.menu = this.$setChildrenSession({ menus: this.menusall, iscode: this.parentCode });
+      // 控制左侧菜单当前选项
+      this.$refs.letnav.setIndex();
+    }
   },
   methods: {
     ...mapActions(['contentsList']),
@@ -67,6 +70,14 @@ export default {
     // 列表点击
     newClick(e) {
       this.$router.push(`/details/${e._id}`);
+    },
+    topage() {
+      const item = this.menusall.find(e => e.code == this.code);
+      if (item.type == '2') {
+        this.$router.push(`/pages/${item.code}`);
+        return false;
+      }
+      return true;
     }
   },
   filters: {
@@ -88,49 +99,49 @@ export default {
     width: 100%;
     display: flex;
     .listBoxLeft {
-      width: 25%;
+      width: 20%;
       margin-top: 5%;
       margin-right: 5%;
     }
     .listBoxRight {
-      width: 70%;
+      width: 75%;
       margin-top: 5%;
       .listBox {
         width: 100%;
         margin: 0 auto;
         margin-bottom: 5%;
-        .el-card__body {
+        ::v-deep .el-card__body {
           display: flex;
-        }
-        .listimg {
-          display: block;
-          width: 15%;
-          height: 150px;
-          cursor: pointer;
-        }
-        .text {
-          width: 70%;
-          margin-left: 5%;
-          .title {
+          .listimg {
+            display: block;
+            width: 15%;
+            height: 150px;
             cursor: pointer;
-            width: 100%;
-            overflow: hidden;
-            text-overflow: ellipsis;
-            white-space: nowrap;
-          }
-          .describe {
-            width: 100%;
-            overflow: hidden;
-            text-overflow: ellipsis;
-            display: -webkit-box;
-            -webkit-line-clamp: 2;
-            -webkit-box-orient: vertical;
-            color: #999;
           }
-          .date {
-            width: 100%;
-            color: #999;
-            line-height: 3em;
+          .text {
+            width: 70%;
+            margin-left: 5%;
+            .title {
+              cursor: pointer;
+              width: 100%;
+              overflow: hidden;
+              text-overflow: ellipsis;
+              white-space: nowrap;
+            }
+            .describe {
+              width: 100%;
+              overflow: hidden;
+              text-overflow: ellipsis;
+              display: -webkit-box;
+              -webkit-line-clamp: 2;
+              -webkit-box-orient: vertical;
+              color: #999;
+            }
+            .date {
+              width: 100%;
+              color: #999;
+              line-height: 3em;
+            }
           }
         }
       }

+ 12 - 1
src/views/pages.vue

@@ -3,7 +3,7 @@
     <h1 class="title">{{ pagesItem.title }}</h1>
     <span class="describe">{{ pagesItem.describe }}</span>
     <span class="date">发表时间: {{ pagesItem.updateAt | dates }}<span class="visit">访问量: {{ pagesItem.visit }}</span></span>
-    <pre class="content" v-html="pagesItem.content"></pre>
+    <div class="content" v-html="pagesItem.content"></div>
   </div>
   <el-divider class="divider" v-else>暂无数据</el-divider>
 </template>
@@ -55,5 +55,16 @@ export default {
       margin-left: 30px;
     }
   }
+  .content {
+    text-align: left;
+    white-space: pre-wrap;
+    word-wrap: break-word;
+    iframe {
+      width: 70%;
+      height: 500px;
+      display: block;
+      margin: 0 auto;
+    }
+  }
 }
 </style>