App.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <el-container>
  3. <el-aside :width="asideWidth">
  4. <div class="app-name"><span v-html="appName"></span></div>
  5. <el-button class="el-button-collapse" @click="toggleCollapse" :icon="buttonCollapseIcon"></el-button>
  6. <el-menu class="el-menu-vertical" :default-active="rootRoute" :collapse="isCollapse" router>
  7. <el-menu-item index="/cardindex">
  8. <i class="el-icon-search"></i>
  9. <span style="font-weight: bold" slot="title">Картотека</span>
  10. </el-menu-item>
  11. <el-menu-item index="/reader">
  12. <i class="el-icon-tickets"></i>
  13. <span slot="title">Читалка</span>
  14. </el-menu-item>
  15. <el-menu-item index="/forum" disabled>
  16. <i class="el-icon-message"></i>
  17. <span slot="title">Форум-чат</span>
  18. </el-menu-item>
  19. <el-menu-item index="/income">
  20. <i class="el-icon-upload"></i>
  21. <span slot="title">Поступления</span>
  22. </el-menu-item>
  23. <el-menu-item index="/sources">
  24. <i class="el-icon-menu"></i>
  25. <span slot="title">Источники</span>
  26. </el-menu-item>
  27. <el-menu-item index="/settings">
  28. <i class="el-icon-setting"></i>
  29. <span slot="title">Параметры</span>
  30. </el-menu-item>
  31. <el-menu-item index="/help">
  32. <i class="el-icon-question"></i>
  33. <span slot="title">Справка</span>
  34. </el-menu-item>
  35. </el-menu>
  36. </el-aside>
  37. <el-main>
  38. <router-view></router-view>
  39. </el-main>
  40. </el-container>
  41. </template>
  42. <script>
  43. //-----------------------------------------------------------------------------
  44. import Vue from 'vue';
  45. import Component from 'vue-class-component';
  46. export default @Component({
  47. })
  48. class App extends Vue {
  49. created() {
  50. this.commit = this.$store.commit;
  51. this.dispatch = this.$store.dispatch;
  52. this.state = this.$store.state;
  53. this.uistate = this.$store.state.uistate;
  54. this.config = this.$store.state.config;
  55. }
  56. mounted() {
  57. this.dispatch('config/loadConfig');
  58. this.$watch('apiError', function(newError, oldError) {
  59. if (newError) {
  60. this.$notify.error({
  61. title: 'Ошибка API',
  62. dangerouslyUseHTMLString: true,
  63. message: newError.response.config.url + '<br>' + newError.response.statusText
  64. });
  65. }
  66. });
  67. }
  68. toggleCollapse() {
  69. this.commit('uistate/setAsideBarCollapse', !this.uistate.asideBarCollapse);
  70. }
  71. get isCollapse() {
  72. return this.uistate.asideBarCollapse;
  73. }
  74. get asideWidth() {
  75. if (this.uistate.asideBarCollapse) {
  76. return '64px';
  77. } else {
  78. return '160px';
  79. }
  80. }
  81. get buttonCollapseIcon() {
  82. if (this.uistate.asideBarCollapse) {
  83. return 'el-icon-d-arrow-right';
  84. } else {
  85. return 'el-icon-d-arrow-left';
  86. }
  87. }
  88. get appName() {
  89. if (this.isCollapse)
  90. return '<br><br>';
  91. else
  92. return `${this.config.name} <br>v${this.config.version}`;
  93. }
  94. get apiError() {
  95. return this.state.apiError;
  96. }
  97. get rootRoute() {
  98. const m = this.$route.path.match(/^(\/[^\/]*).*$/i);
  99. if (m)
  100. return m[1];
  101. else
  102. return this.$route.path;
  103. }
  104. }
  105. //-----------------------------------------------------------------------------
  106. </script>
  107. <style scoped>
  108. .app-name {
  109. margin-left: 10px;
  110. margin-top: 10px;
  111. text-align: center;
  112. line-height: 140%;
  113. font-weight: bold;
  114. }
  115. .el-container {
  116. height: 100%;
  117. }
  118. .el-aside {
  119. line-height: 1;
  120. background-color: #ccc;
  121. color: #000;
  122. }
  123. .el-main {
  124. background-color: #E6EDF4;
  125. color: #000;
  126. }
  127. .el-menu-vertical:not(.el-menu--collapse) {
  128. background-color: inherit;
  129. color: inherit;
  130. text-align: left;
  131. width: 100%;
  132. border: 0;
  133. }
  134. .el-menu--collapse {
  135. background-color: inherit;
  136. color: inherit;
  137. border: 0;
  138. }
  139. .el-button-collapse, .el-button-collapse:focus, .el-button-collapse:active, .el-button-collapse:hover {
  140. background-color: inherit;
  141. color: inherit;
  142. margin-top: 5px;
  143. width: 100%;
  144. border: 0;
  145. }
  146. .el-menu-item {
  147. font-size: 85%;
  148. }
  149. </style>
  150. <style>
  151. body, html, #app {
  152. margin: 0;
  153. padding: 0;
  154. height: 100%;
  155. font: normal 12pt Arial, Verdana, Sans-serif;
  156. }
  157. </style>