App.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <el-container>
  3. <el-aside :width="asideWidth">
  4. {{ appName }}
  5. <el-button class="el-button-collapse" @click="toggleCollapse" :icon="buttonCollapseIcon"></el-button>
  6. <el-menu default-active="1" class="el-menu-vertical" @select="handleSelect" :collapse="isCollapse">
  7. <el-menu-item index="1">
  8. <i class="el-icon-search"></i>
  9. <span slot="title">Картотека</span>
  10. </el-menu-item>
  11. <el-menu-item index="2">
  12. <i class="el-icon-menu"></i>
  13. <span slot="title">Источники</span>
  14. </el-menu-item>
  15. <el-menu-item index="3" disabled>
  16. <i class="el-icon-message"></i>
  17. <span slot="title">Форум</span>
  18. </el-menu-item>
  19. <el-menu-item index="4">
  20. <i class="el-icon-setting"></i>
  21. <span slot="title">Параметры</span>
  22. </el-menu-item>
  23. <el-menu-item index="5">
  24. <i class="el-icon-question"></i>
  25. <span slot="title">Справка</span>
  26. </el-menu-item>
  27. </el-menu>
  28. </el-aside>
  29. <el-main>
  30. <pre>{{ apiError }}</pre>
  31. </el-main>
  32. </el-container>
  33. </template>
  34. <script>
  35. import Vue from 'vue';
  36. import Component from 'vue-class-component';
  37. export default @Component({
  38. props: {
  39. test: String
  40. },
  41. })
  42. class App extends Vue {
  43. created() {
  44. this.commit = this.$store.commit;
  45. this.dispatch = this.$store.dispatch;
  46. this.state = this.$store.state;
  47. this.uistate = this.$store.state.uistate;
  48. this.config = this.$store.state.config;
  49. }
  50. mounted() {
  51. this.dispatch('config/loadConfig');
  52. this.$watch('apiError', function(newError, oldError) {
  53. if (newError) {
  54. this.$notify.error({
  55. title: 'Error',
  56. dangerouslyUseHTMLString: true,
  57. message: newError.response.config.url + '<br>' + newError.response.statusText
  58. });
  59. }
  60. });
  61. }
  62. handleSelect(key, keyPath) {
  63. console.log(key, keyPath);
  64. }
  65. toggleCollapse() {
  66. this.commit('uistate/setAsideBarCollapse', !this.uistate.asideBarCollapse);
  67. }
  68. get isCollapse() {
  69. return this.uistate.asideBarCollapse;
  70. }
  71. get asideWidth() {
  72. if (this.uistate.asideBarCollapse) {
  73. return '64px';
  74. } else {
  75. return '170px';
  76. }
  77. }
  78. get buttonCollapseIcon() {
  79. if (this.uistate.asideBarCollapse) {
  80. return 'el-icon-d-arrow-right';
  81. } else {
  82. return 'el-icon-d-arrow-left';
  83. }
  84. }
  85. get appName() {
  86. return `${this.config.name} v${this.config.version}`;
  87. }
  88. get apiError() {
  89. return this.state.apiError;
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .el-container {
  95. height: 100%;
  96. }
  97. .el-aside {
  98. line-height: 1;
  99. background-color: #ddd;
  100. color: #000;
  101. }
  102. .el-main {
  103. background-color: #E9EEF3;
  104. color: #333;
  105. }
  106. .el-menu-vertical:not(.el-menu--collapse) {
  107. background-color: inherit;
  108. color: inherit;
  109. text-align: left;
  110. width: 100%;
  111. border: 0;
  112. }
  113. .el-menu--collapse {
  114. background-color: inherit;
  115. color: inherit;
  116. border: 0;
  117. }
  118. .el-button-collapse, .el-button-collapse:focus, .el-button-collapse:active, .el-button-collapse:hover {
  119. background-color: inherit;
  120. color: inherit;
  121. margin-top: 5px;
  122. width: 100%;
  123. border: 0;
  124. }
  125. </style>
  126. <style>
  127. body, html, #app {
  128. margin: 0;
  129. padding: 0;
  130. height: 100%;
  131. }
  132. </style>