App.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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" @select="handleSelect" :collapse="isCollapse">
  7. <el-menu-item index="cardindex">
  8. <i class="el-icon-search"></i>
  9. <span 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="newbooks">
  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. <pre>{{ apiError }}</pre>
  39. </el-main>
  40. </el-container>
  41. </template>
  42. <script>
  43. import Vue from 'vue';
  44. import Component from 'vue-class-component';
  45. export default @Component({
  46. props: {
  47. test: String
  48. },
  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. handleSelect(key, keyPath) {
  71. console.log(key, keyPath);
  72. }
  73. toggleCollapse() {
  74. this.commit('uistate/setAsideBarCollapse', !this.uistate.asideBarCollapse);
  75. }
  76. get isCollapse() {
  77. return this.uistate.asideBarCollapse;
  78. }
  79. get asideWidth() {
  80. if (this.uistate.asideBarCollapse) {
  81. return '64px';
  82. } else {
  83. return '160px';
  84. }
  85. }
  86. get buttonCollapseIcon() {
  87. if (this.uistate.asideBarCollapse) {
  88. return 'el-icon-d-arrow-right';
  89. } else {
  90. return 'el-icon-d-arrow-left';
  91. }
  92. }
  93. get appName() {
  94. if (this.isCollapse)
  95. return '<br><br>';
  96. else
  97. return `${this.config.name} <br>v${this.config.version}`;
  98. }
  99. get apiError() {
  100. return this.state.apiError;
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .app-name {
  106. margin-left: 10px;
  107. margin-top: 10px;
  108. text-align: center;
  109. line-height: 140%;
  110. font-weight: bold;
  111. }
  112. .el-container {
  113. height: 100%;
  114. }
  115. .el-aside {
  116. line-height: 1;
  117. background-color: #ccc;
  118. color: #000;
  119. }
  120. .el-main {
  121. background-color: #E6EDF4;
  122. color: #000;
  123. }
  124. .el-menu-vertical:not(.el-menu--collapse) {
  125. background-color: inherit;
  126. color: inherit;
  127. text-align: left;
  128. width: 100%;
  129. border: 0;
  130. }
  131. .el-menu--collapse {
  132. background-color: inherit;
  133. color: inherit;
  134. border: 0;
  135. }
  136. .el-button-collapse, .el-button-collapse:focus, .el-button-collapse:active, .el-button-collapse:hover {
  137. background-color: inherit;
  138. color: inherit;
  139. margin-top: 5px;
  140. width: 100%;
  141. border: 0;
  142. }
  143. .el-menu-item {
  144. font-size: 85%;
  145. }
  146. </style>
  147. <style>
  148. body, html, #app {
  149. margin: 0;
  150. padding: 0;
  151. height: 100%;
  152. font: normal 12pt Arial, Verdana, Sans-serif;
  153. }
  154. </style>