SideBar.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <el-menu :default-active="active" class="side-bar" :collapse="true" :router="true">
  3. <el-menu-item v-for="tab in sidebar" :index="tab.name" :key="tab.name" v-show="!tab.hide" style="height: 70px;">
  4. <el-tooltip placement="right" :content="tab.description">
  5. <i class="icon" :target="tab.name">
  6. <div v-if="calculateLength(tab.description) === 1" class="title" style="margin-left: 2px;">
  7. {{tab.description}}
  8. </div>
  9. <div v-else-if="calculateLength(tab.description) === 2" class="title" style="margin-left: -3px;">
  10. {{tab.description}}
  11. </div>
  12. <div v-else-if="calculateLength(tab.description) === 3" class="title" style="margin-left: -8px;">
  13. {{tab.description}}
  14. </div>
  15. <div v-else class="title" style="margin-left: -3px;">
  16. {{tab.description.slice(0, 3)}}
  17. </div>
  18. </i>
  19. </el-tooltip>
  20. </el-menu-item>
  21. </el-menu>
  22. </template>
  23. <script>
  24. const sidebar = [
  25. { name: 'schedule', description: '项目规划', hide: false },
  26. { name: 'taskList', description: '任务列表', hide: false },
  27. { name: 'bugList', description: '缺陷列表', hide: false },
  28. { name: 'pipeline', description: '流水线及产物', hide: false },
  29. { name: 'database', description: '数据库', hide: false },
  30. { name: 'apitest', description: '测试', hide: false },
  31. { name: 'invite', description: '项目关联', hide: false },
  32. { name: 'git', description: '提交记录', hide: false },
  33. { name: 'codereview', description: '代码评审', hide: false },
  34. ];
  35. export default {
  36. name: 'SideBar',
  37. data() {
  38. return {
  39. sidebar,
  40. };
  41. },
  42. computed: {
  43. active() {
  44. const li = this.$route.path.split('/');
  45. return li[li.length - 1];
  46. },
  47. },
  48. methods: {
  49. calculateLength(name) {
  50. if (name.length === 2) {
  51. return 1;
  52. }
  53. if (name.length === 3) {
  54. return 2;
  55. }
  56. if (name.length === 4) {
  57. return 3;
  58. }
  59. return 0;
  60. },
  61. },
  62. };
  63. </script>
  64. <style lang="scss" scoped>
  65. .side-bar {
  66. height: 100%;
  67. }
  68. .icon {
  69. width: 28px;
  70. height: 28px;
  71. float: right;
  72. background-position: center;
  73. background-repeat: no-repeat;
  74. background-size: 100% 100%;
  75. margin-top: 14px;
  76. transition: all .2s linear;
  77. .el-menu-item:hover & {
  78. cursor: pointer;
  79. transition-duration:0.2s;
  80. transform:scale(1.1);
  81. transition-timing-function:ease-in-out;
  82. }
  83. }
  84. .icon[target=schedule]{
  85. background-image: url("../assets/icon_new/schedule.svg");
  86. .el-menu-item:hover & {
  87. background-image: url("../assets/icon_new/schedule-hover.svg");
  88. color: #2c2c2c;
  89. }
  90. .el-menu-item.is-active & {
  91. background-image: url("../assets/icon_new/schedule-using.svg");
  92. color: #1296db;
  93. }
  94. }
  95. .icon[target=taskList]{
  96. background-image: url("../assets/icon_new/task.svg");
  97. .el-menu-item:hover & {
  98. background-image: url("../assets/icon_new/task-hover.svg");
  99. color: #2c2c2c;
  100. }
  101. .el-menu-item.is-active & {
  102. background-image: url("../assets/icon_new/task-using.svg");
  103. color: #1296db;
  104. }
  105. }
  106. .icon[target=bugList]{
  107. background-image: url("../assets/icon_new/bug.svg");
  108. .el-menu-item:hover & {
  109. background-image: url("../assets/icon_new/bug-hover.svg");
  110. color: #2c2c2c;
  111. }
  112. .el-menu-item.is-active & {
  113. background-image: url("../assets/icon_new/bug-using.svg");
  114. color: #1296db;
  115. }
  116. }
  117. .icon[target=statistics]{
  118. background-image: url("../assets/icon/training.svg");
  119. .el-menu-item:hover & {
  120. background-image: url("../assets/icon/training-hover.svg");
  121. }
  122. .el-menu-item.is-active & {
  123. background-image: url("../assets/icon/training-using.svg");
  124. }
  125. }
  126. .icon[target=pipeline]{
  127. background-image: url("../assets/icon_new/pipeline.svg");
  128. .el-menu-item:hover & {
  129. background-image: url("../assets/icon_new/pipeline-hover.svg");
  130. color: #2c2c2c;
  131. }
  132. .el-menu-item.is-active & {
  133. background-image: url("../assets/icon_new/pipeline-using.svg");
  134. color: #1296db;
  135. }
  136. }
  137. .icon[target=database]{
  138. background-image: url("../assets/icon_new/database.svg");
  139. .el-menu-item:hover & {
  140. background-image: url("../assets/icon_new/database-hover.svg");
  141. color: #2c2c2c;
  142. }
  143. .el-menu-item.is-active & {
  144. background-image: url("../assets/icon_new/database-using.svg");
  145. color: #1296db;
  146. }
  147. }
  148. .icon[target=apitest]{
  149. background-image: url("../assets/icon_new/test.svg");
  150. .el-menu-item:hover & {
  151. background-image: url("../assets/icon_new/test-hover.svg");
  152. color: #2c2c2c;
  153. }
  154. .el-menu-item.is-active & {
  155. background-image: url("../assets/icon_new/test-using.svg");
  156. color: #1296db;
  157. }
  158. }
  159. .icon[target=invite]{
  160. background-image: url("../assets/icon_new/link.svg");
  161. .el-menu-item:hover & {
  162. background-image: url("../assets/icon_new/link-hover.svg");
  163. color: #2c2c2c;
  164. }
  165. .el-menu-item.is-active & {
  166. background-image: url("../assets/icon_new/link-using.svg");
  167. color: #1296db;
  168. }
  169. }
  170. .icon[target=git]{
  171. background-image: url("../assets/icon_new/git.svg");
  172. .el-menu-item:hover & {
  173. background-image: url("../assets/icon_new/git-hover.svg");
  174. color: #2c2c2c;
  175. }
  176. .el-menu-item.is-active & {
  177. background-image: url("../assets/icon_new/git-using.svg");
  178. color: #1296db;
  179. }
  180. }
  181. .icon[target=codereview]{
  182. background-image: url("../assets/icon_new/codereview.svg");
  183. .el-menu-item:hover & {
  184. background-image: url("../assets/icon_new/codereview-hover.svg");
  185. color: #2c2c2c;
  186. }
  187. .el-menu-item.is-active & {
  188. background-image: url("../assets/icon_new/codereview-using.svg");
  189. color: #1296db;
  190. }
  191. }
  192. .title{
  193. font-size: 9px;
  194. margin-top: 12px;
  195. font-style: normal;
  196. }
  197. </style>