App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 :class="itemTitleClass('/cardindex')" slot="title">Картотека</span>
  10. </el-menu-item>
  11. <el-menu-item index="/reader">
  12. <i class="el-icon-tickets"></i>
  13. <span :class="itemTitleClass('/reader')" slot="title">Читалка</span>
  14. </el-menu-item>
  15. <el-menu-item index="/forum" disabled>
  16. <i class="el-icon-message"></i>
  17. <span :class="itemTitleClass('/forum')" slot="title">Форум-чат</span>
  18. </el-menu-item>
  19. <el-menu-item index="/income">
  20. <i class="el-icon-upload"></i>
  21. <span :class="itemTitleClass('/income')" slot="title">Поступления</span>
  22. </el-menu-item>
  23. <el-menu-item index="/sources">
  24. <i class="el-icon-menu"></i>
  25. <span :class="itemTitleClass('/sources')" slot="title">Источники</span>
  26. </el-menu-item>
  27. <el-menu-item index="/settings">
  28. <i class="el-icon-setting"></i>
  29. <span :class="itemTitleClass('/settings')" slot="title">Параметры</span>
  30. </el-menu-item>
  31. <el-menu-item index="/help">
  32. <i class="el-icon-question"></i>
  33. <span :class="itemTitleClass('/help')" 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 '170px';
  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. return (m ? m[1] : this.$route.path);
  100. }
  101. itemTitleClass(path) {
  102. return (this.rootRoute == path ? {'bold-font': true} : {});
  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. .bold-font {
  116. font-weight: bold;
  117. }
  118. .el-container {
  119. height: 100%;
  120. }
  121. .el-aside {
  122. line-height: 1;
  123. background-color: #ccc;
  124. color: #000;
  125. }
  126. .el-main {
  127. padding: 5px;
  128. background-color: #E6EDF4;
  129. color: #000;
  130. }
  131. .el-menu-vertical:not(.el-menu--collapse) {
  132. background-color: inherit;
  133. color: inherit;
  134. text-align: left;
  135. width: 100%;
  136. border: 0;
  137. }
  138. .el-menu--collapse {
  139. background-color: inherit;
  140. color: inherit;
  141. border: 0;
  142. }
  143. .el-button-collapse, .el-button-collapse:focus, .el-button-collapse:active, .el-button-collapse:hover {
  144. background-color: inherit;
  145. color: inherit;
  146. margin-top: 5px;
  147. width: 100%;
  148. border: 0;
  149. }
  150. .el-menu-item {
  151. font-size: 85%;
  152. }
  153. </style>
  154. <style>
  155. body, html, #app {
  156. margin: 0;
  157. padding: 0;
  158. height: 100%;
  159. font: normal 12pt Arial, Verdana, Sans-serif;
  160. }
  161. </style>