index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!-- vue 页面模板 -->
  2. <template>
  3. <div class="layout">
  4. <Layout>
  5. <PageHeader title=" ">
  6. <template #action>
  7. <div class="login_out" @click="login_out">退出</div>
  8. </template>
  9. <template #content> </template>
  10. </PageHeader>
  11. <Layout>
  12. <Sider hide-trigger :style="{ background: '#fff' }">
  13. <Menu
  14. :active-name="active_name"
  15. theme="primary"
  16. width="auto"
  17. :open-names="['home']"
  18. @on-select="changePage"
  19. accordion
  20. >
  21. <div v-for="(item, i) in menu_list" :key="i">
  22. <Submenu v-if="item.children && item.children.length" :name="item.router">
  23. <template #title>
  24. <Icon :type="item.icon || 'ios-browsers'" />
  25. {{ item.name }}
  26. </template>
  27. <MenuItem
  28. v-for="v in item.children"
  29. :key="v.router"
  30. :name="v.router"
  31. >
  32. {{ v.name }}
  33. </MenuItem>
  34. </Submenu>
  35. <MenuItem v-else :name="item.router">
  36. <Icon :type="item.icon || 'ios-browsers'" />
  37. {{ item.name }}
  38. </MenuItem>
  39. </div>
  40. </Menu>
  41. </Sider>
  42. <Layout :style="{ padding: '24px' }">
  43. <Content
  44. :style="{
  45. padding: '24px',
  46. height: content_height + 'px',
  47. overflow: 'auto',
  48. background: '#fff',
  49. }"
  50. >
  51. <router-view></router-view>
  52. </Content>
  53. </Layout>
  54. </Layout>
  55. </Layout>
  56. </div>
  57. </template>
  58. <script>
  59. import api from '../../api/index.js';
  60. export default {
  61. data() {
  62. return {
  63. content_height: 0,
  64. active_name: '',
  65. menu_list: [],
  66. };
  67. },
  68. mounted() {
  69. // 计算内容区域高度
  70. this.content_height = document.documentElement.clientHeight - 120;
  71. this.active_name = this.$route.path;
  72. api.menu_api().then(r => {
  73. this.menu_list = r || [];
  74. });
  75. },
  76. methods: {
  77. changePage(p) {
  78. this.$router.push(p);
  79. },
  80. login_out() {
  81. api.login_out_api().then(r => {
  82. console.log(r);
  83. localStorage.setItem('neican_token', '');
  84. this.$router.replace('/');
  85. });
  86. },
  87. },
  88. };
  89. </script>
  90. <style lang="scss">
  91. .layout {
  92. border: 1px solid #d7dde4;
  93. background: #f5f7f9;
  94. position: relative;
  95. border-radius: 4px;
  96. overflow: hidden;
  97. width: 100%;
  98. height: 100%;
  99. .login_out {
  100. cursor: pointer;
  101. }
  102. }
  103. </style>