guoshilong
2023-11-13 54849757852f6ab40eb17afbd03d1d839b60a38d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
  <div class="demo-project-sidebar-wrapper flex-justify-between">
    <div>
    <router-link
      v-for="item in options"
      :key="item.key"
      :to="item.path"
      :class="{
        'menu-item': true,
        selected: selectedRoute(item),
      }"
    >
      <a-tooltip :title="item.label" placement="right">
        <Icon class="fz20" style="width: 50px;" :icon="item.icon"/>
      </a-tooltip>
    </router-link>
    </div>
    <div class="mb20 flex-display flex-column flex-align-center flex-justify-between">
      <a-tooltip title="返回项目列表" placement="right">
        <a @click="goBack"> <Icon icon="ImportOutlined" style="font-size: 22px; color: white"/></a>
      </a-tooltip>
    </div>
  </div>
</template>
 
<script lang="ts">
import { createVNode, defineComponent } from 'vue'
import { getRoot } from '/@/root'
import * as icons from '@ant-design/icons-vue'
import { ERouterName } from '/@/types'
import { UnBind } from '/@/api/manage'
import { useMyStore } from '/@/store'
interface IOptions {
  key: number
  label: string
  path:
    | string
    | {
        path: string
        query?: any
      }
  icon: string
}
 
const Icon = (props: {icon: string}) => {
  return createVNode((icons as any)[props.icon])
}
 
export default defineComponent({
  components: {
    Icon,
  },
  name: 'Sidebar',
  setup () {
    const root = getRoot()
    const options = [
      { key: 0, label: '团队', path: '/' + ERouterName.TSA, icon: 'TeamOutlined' },
      // { key: 1, label: '直播', path: '/' + ERouterName.LIVESTREAM, icon: 'VideoCameraOutlined' },
      { key: 2, label: '标注', path: '/' + ERouterName.LAYER, icon: 'EnvironmentOutlined' },
      { key: 3, label: '媒体库', path: '/' + ERouterName.MEDIA, icon: 'PictureOutlined' },
      { key: 4, label: '航线库', path: '/' + ERouterName.WAYLINE, icon: 'NodeIndexOutlined' },
      { key: 5, label: '计划库', path: '/' + ERouterName.TASK, icon: 'CalendarOutlined' },
      { key: 6, label: '设备', path: '/' + ERouterName.IMPLEMENT, icon: 'ClusterOutlined' },
      { key: 7, label: '历史航线', path: '/' + ERouterName.ROUTE_HISTORY, icon: 'StockOutlined' }
    ]
    const store = useMyStore()
    function selectedRoute (item: IOptions) {
      const path = typeof item.path === 'string' ? item.path : item.path.path
      return root.$route.path?.indexOf(path) === 0
    }
    const osdVisible = computed(() => {
      return store.state.osdVisible
    })
    const snList = computed(() => store.state.common.snList)
    async function goBack () {
      const query = toRefs(osdVisible.value)
      snList.value.forEach(async (v: string) => {
        await UnBind(v)
      })
      store.commit('SET_OSD_VISIBLE_INFO', { ...query, visible: false })
      store.commit('SET_SELECT_WAYLINE_INFO', {})
      store.commit('SET_SELECT_DOCK_INFO', {})
      root.$router.push('/' + ERouterName.PROJECT_LIST)
    }
    return {
      options,
      selectedRoute,
      goBack,
    }
  }
})
</script>
 
<style scoped lang="scss">
.demo-project-sidebar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 50px;
  border-right: 1px solid #4f4f4f;
  color: $text-white-basic;
  // flex: 1;
  overflow: hidden;
  .menu-item {
    width: 100%;
    padding: 16px 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: $text-white-basic;
    cursor: pointer;
    &.selected {
      background-color: #101010;
      color: $primary;
    }
    &.disabled {
      pointer-events: none;
      opacity: 0.45;
    }
  }
  .filling {
    flex: 1;
  }
 
  .setting-icon {
    font-size: 24px;
    margin-bottom: 24px;
    color: $text-white-basic;
  }
 
}
.ant-tooltip-open {
  border: 0;
}
</style>