App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. <keep-alive>
  39. <router-view></router-view>
  40. </keep-alive>
  41. </el-main>
  42. </el-container>
  43. </template>
  44. <script>
  45. //-----------------------------------------------------------------------------
  46. import Vue from 'vue';
  47. import Component from 'vue-class-component';
  48. export default @Component({
  49. })
  50. class App extends Vue {
  51. created() {
  52. this.commit = this.$store.commit;
  53. this.dispatch = this.$store.dispatch;
  54. this.state = this.$store.state;
  55. this.uistate = this.$store.state.uistate;
  56. this.config = this.$store.state.config;
  57. }
  58. mounted() {
  59. this.dispatch('config/loadConfig');
  60. this.$watch('apiError', function(newError, oldError) {
  61. if (newError) {
  62. this.$notify.error({
  63. title: 'Ошибка API',
  64. dangerouslyUseHTMLString: true,
  65. message: newError.response.config.url + '<br>' + newError.response.statusText
  66. });
  67. }
  68. });
  69. }
  70. toggleCollapse() {
  71. this.commit('uistate/setAsideBarCollapse', !this.uistate.asideBarCollapse);
  72. }
  73. get isCollapse() {
  74. return this.uistate.asideBarCollapse;
  75. }
  76. get asideWidth() {
  77. if (this.uistate.asideBarCollapse) {
  78. return '64px';
  79. } else {
  80. return '170px';
  81. }
  82. }
  83. get buttonCollapseIcon() {
  84. if (this.uistate.asideBarCollapse) {
  85. return 'el-icon-d-arrow-right';
  86. } else {
  87. return 'el-icon-d-arrow-left';
  88. }
  89. }
  90. get appName() {
  91. if (this.isCollapse)
  92. return '<br><br>';
  93. else
  94. return `${this.config.name} <br>v${this.config.version}`;
  95. }
  96. get apiError() {
  97. return this.state.apiError;
  98. }
  99. get rootRoute() {
  100. const m = this.$route.path.match(/^(\/[^\/]*).*$/i);
  101. return (m ? m[1] : this.$route.path);
  102. }
  103. itemTitleClass(path) {
  104. return (this.rootRoute == path ? {'bold-font': true} : {});
  105. }
  106. }
  107. //-----------------------------------------------------------------------------
  108. </script>
  109. <style scoped>
  110. .app-name {
  111. margin-left: 10px;
  112. margin-top: 10px;
  113. text-align: center;
  114. line-height: 140%;
  115. font-weight: bold;
  116. }
  117. .bold-font {
  118. font-weight: bold;
  119. }
  120. .el-container {
  121. height: 100%;
  122. }
  123. .el-aside {
  124. line-height: 1;
  125. background-color: #ccc;
  126. color: #000;
  127. }
  128. .el-main {
  129. padding: 5px;
  130. background-color: #E6EDF4;
  131. color: #000;
  132. }
  133. .el-menu-vertical:not(.el-menu--collapse) {
  134. background-color: inherit;
  135. color: inherit;
  136. text-align: left;
  137. width: 100%;
  138. border: 0;
  139. }
  140. .el-menu--collapse {
  141. background-color: inherit;
  142. color: inherit;
  143. border: 0;
  144. }
  145. .el-button-collapse, .el-button-collapse:focus, .el-button-collapse:active, .el-button-collapse:hover {
  146. background-color: inherit;
  147. color: inherit;
  148. margin-top: 5px;
  149. width: 100%;
  150. height: 64px;
  151. border: 0;
  152. }
  153. .el-menu-item {
  154. font-size: 85%;
  155. }
  156. </style>
  157. <style>
  158. body, html, #app {
  159. margin: 0;
  160. padding: 0;
  161. height: 100%;
  162. font: normal 12pt Arial, Verdana, Sans-serif;
  163. }
  164. </style>