nav.vue 1.74 KB
<template>
  <el-container>
    <el-aside width="15%">
      <el-menu :default-active="$route.path" class="el-menu-vertical-demo" router>
        <div style="height:20%">

        </div>
        <el-menu-item index="/nav/search">
          <i class="el-icon-search"></i>
          <span slot="title">检索合同</span>
        </el-menu-item>
        <el-menu-item index="/nav/contract/0">
          <i class="el-icon-plus"></i>
          <span slot="title">添加合同</span>
        </el-menu-item>
        <el-menu-item index="/nav/manage">
          <i class="el-icon-setting"></i>
          <span slot="title">后台管理</span>
        </el-menu-item>
        <el-menu-item index="" @click="exit">
          <i class="el-icon-back"></i>
          <span slot="title">退出</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      username: ""
    };
  },

  methods: {
    exit() {
      this.$confirm("确认退出?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          sessionStorage.removeItem("username");
          sessionStorage.removeItem("loginCheck");
          this.$router.push({ path: "/" });
        })
        .catch(() => {});
    }
  },
  beforeCreate() {
    if (!sessionStorage.getItem("loginCheck")) {
      alert("请登录");
      this.$router.push({ path: "/" });
    }
  },
  mounted() {

  }
};
</script>

<style>
.el-main {
  text-align: center;
}
.el-menu {
  position: relative;
}

.el-container,
.el-aside {
  height: 100%;
}
.el-menu {
  height: 100%;
}
</style>