App.vue 4.82 KB
<template>
  <div
    id="app"
    class="is-component"
  >
    <gl-header :height='"100px"'>
      <div>
        <div class="img">
          <viewer>
            <img
              style="border-width:0;"
              src="./assets/logo.png"
            >
          </viewer>
        </div>
        <h1>
          <span style="color: #409eff">{{header}}</span>
        </h1>
      </div>
    </gl-header>
    <div class="app-main">
      <el-scrollbar class="page-component__scroll">
        <gl-container>
          <gl-aside
            class="aside"
            :width='"270px"'
          >
            <el-scrollbar style="height: 100%;">
              <div
                class="nav-group"
                v-for="(i, index) in data"
                :key="index"
              >
                <div class="nav-group__title">{{i.title}}</div>
                <ul class="pure-menu-list">
                  <li
                    v-for="(k, ind) in i.list"
                    :key="ind"
                    @click="scrollTop(i.list[ind])"
                  >
                    <router-link
                      :to="{ name: k.link }"
                      ref="list"
                    >{{k.text}}</router-link>
                    <!-- <p
                      class="page-menu-list"
                      v-for="(j, jIndex) in k.pageLinkList"
                      :key="jIndex"
                      @click="jumpTo(k, jIndex)"
                    >{{j.text}}</p> -->
                  </li>
                </ul>
              </div>
            </el-scrollbar>
          </gl-aside>
          <gl-main class="main">
            <router-view></router-view>
          </gl-main>
        </gl-container>
      </el-scrollbar>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
      header: 'NodeJs和npm',
      data: [
        {
          title: '环境配置',
          list: [
            { text: 'NodeJs和npm', link: 'installNode', list: [{ text: 'nodejs' }, { text: 'npm' }, { text: 'npm安装包安装' }] },
            { text: 'Vue-cli', link: 'installCli' }
          ]
        },
        {
          title: '定制化模板',
          list: [
            { text: '项目结构', link: 'introduce' }
          ]
        },
        {
          title: '前端接口模拟器',
          list: [
            { text: 'Easy-Mock', link: 'easymock' }
          ]
        },
        {
          title: '独立权限系统',
          list: [
            { text: '配置项', link: 'configItem' },
            { text: '权限配置', link: 'configAuthority' }
          ]
        },
        {
          title: '组件封装',
          list: [
            { text: '表格组件', link: 'tableIntroduce' }
          ]
        }
      ]
    }
  },
  mounted () {
    var pageLink = window.location.href.split('/')[window.location.href.split('/').length - 1]
    for (var item of this.data) {
      var subItem = item.list.find(i => i.link === pageLink)
      if (subItem) {
        this.header = subItem.text
        break
      }
    }
  },
  methods: {
    scrollTop (val) {
      document.documentElement.scrollTop = 0
      this.header = val.text
    }
  }
}
</script>

<style scoped>
.el-header,
.el-footer {
  width: 100%;
  color: #333;
  text-align: center;
}
#app .el-header {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2001;
  background: #fff;
}
#app .el-header > div {
  width: 1360px;
  height: 100%;
  margin: 0 auto;
}
.el-container {
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
}
#app .el-header .img {
  width: 270px;
  height: 100%;
  float: left;
  box-sizing: border-box;
  padding: 20px 25px 25px 0;
}
#app .el-header img {
  width: 100%;
}
#app .el-header h1 {
  display: inline-block;
  height: 100px;
  line-height: 100px;
  font-size: 35px;
  letter-spacing: 5px;
  color: #4d4d4d;
  margin: 0;
}
.page-component__scroll {
  height: 100%;
}
.aside {
  position: fixed;
  top: 0;
  bottom: 0;
  margin-top: 100px;
  margin-bottom: -17px;
  overflow-x: auto;
  transition: all 1s;
  z-index: 1999;
}
.main {
  margin-left: 270px;
}
.app-main {
  margin: 100px 0 40px;
  width: 100%;
}
.nav-group__title {
  font-size: 14px;
  color: #999;
  line-height: 26px;
  margin-top: 15px;
}
.pure-menu-list li {
  list-style-type: none;
}
.pure-menu-list li a {
  display: block;
  height: 40px;
  color: #444;
  line-height: 40px;
  font-size: 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 400;
  text-decoration: none;
}
.pure-menu-list li p {
  cursor: pointer;
}
.pure-menu-list li p:hover {
  color: #409eff;
}
.pure-menu-list li .router-link-active {
  color: #409eff;
}
.page-menu-list {
  font-size: 12px;
  color: #999999;
  padding-left: 14px;
}
.el-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  height: 20px !important;
}
</style>