75 lines
1.7 KiB
Vue
Raw Normal View History

2022-01-05 18:04:41 +08:00
<template>
2022-01-05 20:52:49 +08:00
<n-space class="header-left-btn">
2022-01-05 18:04:41 +08:00
<n-tooltip
v-for="item in btnList"
:key="item.key"
2022-01-05 18:04:41 +08:00
placement="bottom"
trigger="hover"
>
<template #trigger>
<n-button
:type="item.select ? 'info' : ''"
size="small"
ghost
@click="clickHandle(item)"
>
2022-01-05 18:04:41 +08:00
<component :is="item.icon"></component>
</n-button>
</template>
<span>
{{ item.title }}
</span>
</n-tooltip>
</n-space>
</template>
<script setup lang="ts">
import { reactive, watchEffect, ref } from 'vue'
2022-01-05 18:04:41 +08:00
import { renderIcon } from '@/utils'
2022-01-05 20:52:49 +08:00
import { icon } from '@/plugins'
const { LayersIcon, BarChartIcon, PrismIcon } = icon.ionicons5
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
2022-01-05 20:52:49 +08:00
const chartLayoutStore = useChartLayoutStore()
2022-01-05 18:04:41 +08:00
const init = (layers: boolean, charts: boolean, details: boolean) => [
2022-01-05 18:04:41 +08:00
{
key: 'layers',
select: chartLayoutStore.getLayers,
2022-01-05 18:04:41 +08:00
title: '图层控制',
2022-01-05 20:52:49 +08:00
icon: renderIcon(LayersIcon)
2022-01-05 18:04:41 +08:00
},
{
key: 'charts',
select: chartLayoutStore.getCharts,
2022-01-05 18:04:41 +08:00
title: '图表组件',
icon: renderIcon(BarChartIcon)
2022-01-05 20:52:49 +08:00
},
{
key: 'details',
select: chartLayoutStore.getDetails,
2022-01-05 20:52:49 +08:00
title: '详情设置',
icon: renderIcon(PrismIcon)
2022-01-05 18:04:41 +08:00
}
]
const btnList = ref()
watchEffect(() => {
btnList.value = init(
chartLayoutStore.getLayers,
chartLayoutStore.getCharts,
chartLayoutStore.getDetails
)
})
const clickHandle = (item: { [T: string]: string }) => {
chartLayoutStore.setItem(item.key, !item.select)
}
2022-01-05 18:04:41 +08:00
</script>
2022-01-05 20:52:49 +08:00
<style lang="scss" scoped>
.header-left-btn {
padding-right: 212px;
}
</style>