sidebar.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div class="demo-project-sidebar-wrapper flex-justify-between">
  3. <div>
  4. <router-link v-for="item in options" :key="item.key" :to="item.path" :class="{
  5. 'menu-item': true,
  6. selected: selectedRoute(item),
  7. }">
  8. <a-tooltip :title="item.label" placement="right">
  9. <Icon class="fz20" style="width: 50px;" :icon="item.icon" />
  10. </a-tooltip>
  11. </router-link>
  12. </div>
  13. <div class="mb20 flex-display flex-column flex-align-center flex-justify-between">
  14. <a-tooltip title="Back to home" placement="right">
  15. <a @click="goHome">
  16. <Icon icon="ImportOutlined" style="font-size: 22px; color: white" />
  17. </a>
  18. </a-tooltip>
  19. </div>
  20. </div>
  21. </template>
  22. <script lang="ts">
  23. import { createVNode, defineComponent } from 'vue'
  24. import { getRoot } from '/@/root'
  25. import * as icons from '@ant-design/icons-vue'
  26. import { ERouterName } from '/@/types'
  27. interface IOptions {
  28. key: number
  29. label: string
  30. path:
  31. | string
  32. | {
  33. path: string
  34. query?: any
  35. }
  36. icon: string
  37. }
  38. const Icon = (props: { icon: string }) => {
  39. return createVNode((icons as any)[props.icon])
  40. }
  41. export default defineComponent({
  42. components: {
  43. Icon,
  44. },
  45. name: 'Sidebar',
  46. setup() {
  47. const root = getRoot()
  48. const options = [
  49. { key: 0, label: 'Tsa', path: '/' + ERouterName.TSA, icon: 'TeamOutlined' },
  50. // { key: 1, label: 'Livestream', path: '/' + ERouterName.LIVESTREAM, icon: 'VideoCameraOutlined' },
  51. // { key: 2, label: 'Annotations', path: '/' + ERouterName.LAYER, icon: 'EnvironmentOutlined' },
  52. // { key: 3, label: 'Media Files', path: '/' + ERouterName.MEDIA, icon: 'PictureOutlined' },
  53. // { key: 4, label: 'Flight Route Library', path: '/' + ERouterName.WAYLINE, icon: 'NodeIndexOutlined' },
  54. // { key: 5, label: 'Task Plan Library', path: '/' + ERouterName.TASK, icon: 'CalendarOutlined' },
  55. // { key: 6, label: 'Flight Area', path: '/' + ERouterName.FLIGHT_AREA, icon: 'GroupOutlined' },
  56. ]
  57. function selectedRoute(item: IOptions) {
  58. const path = typeof item.path === 'string' ? item.path : item.path.path
  59. return root.$route.path?.indexOf(path) === 0
  60. }
  61. function goHome() {
  62. root.$router.push('/' + ERouterName.DEVICES)
  63. }
  64. return {
  65. options,
  66. selectedRoute,
  67. goHome,
  68. }
  69. }
  70. })
  71. </script>
  72. <style scoped lang="scss">
  73. .demo-project-sidebar-wrapper {
  74. display: flex;
  75. flex-direction: column;
  76. align-items: center;
  77. width: 50px;
  78. border-right: 1px solid #4f4f4f;
  79. color: $text-white-basic;
  80. // flex: 1;
  81. overflow: hidden;
  82. .menu-item {
  83. width: 100%;
  84. padding: 16px 0px;
  85. display: flex;
  86. flex-direction: column;
  87. align-items: center;
  88. color: $text-white-basic;
  89. cursor: pointer;
  90. &.selected {
  91. background-color: #101010;
  92. color: $primary;
  93. }
  94. &.disabled {
  95. pointer-events: none;
  96. opacity: 0.45;
  97. }
  98. }
  99. .filling {
  100. flex: 1;
  101. }
  102. .setting-icon {
  103. font-size: 24px;
  104. margin-bottom: 24px;
  105. color: $text-white-basic;
  106. }
  107. }
  108. .ant-tooltip-open {
  109. border: 0;
  110. }
  111. </style>