App.vue 1.69 KB
<template>
  <div id="app">
    <div class="wrapper-header">
      <img class="logo" src="./assets/logo.png" alt="">
      <a-menu v-model="current" mode="horizontal">
        <a-menu-item key="home" @click="handleTab('Home')"><a-icon type="home" />项目主页</a-menu-item>
        <a-menu-item key="documentation" @click="handleTab('Documentation')"><a-icon type="file-text" />项目文档描述</a-menu-item>
        <a-menu-item key="record" @click="handleTab('Record')"><a-icon type="message" />问题记录</a-menu-item>
      </a-menu>
    </div>
    <div class="wrapper-content">
      <router-view />
    </div>
  </div>
</template>

<script>
let currentName = ''
export default {
  name: 'App',
  data() {
    return {
      current: ['home'],
    }
  },
  mounted() {
    currentName = window.location.pathname.substr(1)
    console.log(currentName)
    if (!currentName) this.current = ['home']
    else this.current = [currentName]
  },
  methods: {
    handleTab(name) {
      this.to(name)
    }
  },
}
</script>

<style>
.wrapper-header {
  display: flex;
  background-color: #2b303b;
}
.wrapper-header .logo {
  display: inline-flex;
  width: 50px;
  height: 50px;
}
.wrapper-header .ant-menu {
  display: inline-flex;
  background-color: #2b303b;
  color: #fff;
}
.wrapper-header .ant-menu-horizontal > .ant-menu-item:hover,
.wrapper-header .ant-menu-horizontal > .ant-menu-item-active,
.wrapper-header .ant-menu-horizontal > .ant-menu-item-selected {
  border-bottom: none;
}
.wrapper-header .ant-menu-horizontal {
  border-bottom: none;
}
.wrapper-header .ant-menu-horizontal > .ant-menu-item > a {
  color: #fff;
}
.wrapper-content {
  margin: 30px auto;
  padding: 0 10px;
  max-width: 1200px;
}
</style>