frame.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <el-container class="layout" direction="vertical">
  3. <el-header class="header" :height="layout.headerHeight" :style="{ lineHeight: layout.headerHeight }">
  4. <div class="header-box">
  5. <naf-logo :width="asideWidth" :shortName="shortName" />
  6. <naf-lite-bar :menu-collapse="menuCollapse" @toggle-menu="toggleMenu" />
  7. </div>
  8. </el-header>
  9. <el-main style="padding: 0;display: flex;">
  10. <el-container class="main">
  11. <el-aside :width="asideWidth" class="sider" v-show="asideShow">
  12. <naf-sider :menu-items="menuItems" :style="{ width: asideWidth }" theme="light" :is-collapse="menuCollapse" />
  13. </el-aside>
  14. <el-main class="content">
  15. <div class="bread" :height="layout.breadHeight" v-show="asideShow">
  16. <naf-bread></naf-bread>
  17. </div>
  18. <div class="page" ref="pageContainer">
  19. <el-alert :title="errMsg" type="info" :description="errDesc" show-icon v-if="showError"> </el-alert>
  20. <router-view v-else />
  21. </div>
  22. </el-main>
  23. </el-container>
  24. </el-main>
  25. </el-container>
  26. </template>
  27. <script>
  28. import config from '@frame/config';
  29. import NafSider from '@naf/frame/sider';
  30. import NafLogo from './logo';
  31. import NafLiteBar from './litebar';
  32. import NafBread from './bread';
  33. const defaultConfig = {
  34. breadHeight: '24px',
  35. headerHeight: '64px',
  36. footerHeight: '48px',
  37. asideExpandWidth: '256px',
  38. asideCollapseWidth: '64px',
  39. };
  40. const { layout = {} } = config;
  41. export default {
  42. name: 'Frame',
  43. components: {
  44. NafSider,
  45. NafLogo,
  46. NafLiteBar,
  47. NafBread,
  48. },
  49. props: {
  50. menuItems: { type: Array, required: true },
  51. shortName: { type: String, default: '系统管理' },
  52. // menuCollapse: { type: Boolean, default: false },
  53. },
  54. data() {
  55. return {
  56. layout: { ...defaultConfig, ...layout },
  57. showError: false,
  58. errMsg: '',
  59. errDesc: '',
  60. menuCollapse: false,
  61. };
  62. },
  63. methods: {
  64. toggleMenu() {
  65. this.menuCollapse = !this.menuCollapse;
  66. },
  67. },
  68. computed: {
  69. asideWidth() {
  70. return this.menuCollapse ? layout.asideCollapseWidth : layout.asideExpandWidth;
  71. },
  72. asideShow() {
  73. return true;
  74. },
  75. },
  76. created() {
  77. // eslint-disable-next-line no-undef
  78. // if (!dd) {
  79. // throw new BusinessError();
  80. // }
  81. },
  82. errorCaptured(err, vm, info) {
  83. this.showError = true;
  84. this.errMsg = err.message || '处理发生错误';
  85. this.errDesc = err.details || info || '页面加载过程中发生错误';
  86. },
  87. };
  88. </script>
  89. <style scoped lang="less">
  90. .layout {
  91. height: 100%;
  92. width: 100%;
  93. overflow: hidden;
  94. }
  95. .header {
  96. padding: 0;
  97. .header-box {
  98. background: #20a0ff;
  99. color: #fff;
  100. display: flex;
  101. flex-direction: row;
  102. padding: 0;
  103. height: 100%;
  104. width: 100%;
  105. }
  106. }
  107. .sider {
  108. background: #00b1ff;
  109. height: 100%;
  110. overflow-y: auto;
  111. overflow-x: hidden;
  112. border-right: solid 1px #e6e6e6;
  113. }
  114. .main {
  115. // FOR EDGE
  116. overflow: hidden;
  117. }
  118. .content {
  119. overflow: hidden;
  120. display: flex;
  121. flex-direction: column;
  122. padding: 0;
  123. .bread {
  124. padding: 10px 20px;
  125. }
  126. .page {
  127. flex: 1;
  128. overflow: auto;
  129. display: block;
  130. padding: 10px;
  131. }
  132. }
  133. </style>