101 lines
2.6 KiB
Vue
Raw Normal View History

2022-01-06 13:45:51 +08:00
<template>
2022-01-16 22:17:34 +08:00
<n-layout has-sider sider-placement="right">
<n-layout-content>
<!-- 为了展示折叠的按钮放在了这里 呜呜呜 -->
<ContentDrag />
</n-layout-content>
<n-layout-sider
collapse-mode="transform"
:collapsed-width="0"
:width="350"
:collapsed="collapsed"
:native-scrollbar="false"
show-trigger="bar"
@collapse="collapsedHindle"
@expand="expandHindle"
>
<ContentBox class="go-content-layers go-boderbox" :showTop="false" :depth="2">
<n-tabs class="tabs-box" size="small" type="segment">
<n-tab-pane
v-for="item in tabList"
:key="item.key"
:name="item.key"
display-directive="show:lazy"
>
<template #tab>
<n-space>
<span>{{ item.title }}</span>
<n-icon size="16" class="icon-position">
<component :is="item.icon"></component>
</n-icon>
</n-space>
</template>
<component :is="item.render"></component>
</n-tab-pane>
</n-tabs>
</ContentBox>
</n-layout-sider>
</n-layout>
2022-01-06 13:45:51 +08:00
</template>
<script setup lang="ts">
2022-01-16 22:17:34 +08:00
import { shallowRef, ref, toRefs, watch } from 'vue'
2022-01-06 13:45:51 +08:00
import { icon } from '@/plugins'
2022-01-06 15:37:44 +08:00
import { ContentBox } from '../ContentBox/index'
2022-01-08 21:01:52 +08:00
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
2022-01-16 22:17:34 +08:00
import { ChartLayoutStoreEnums } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
2022-01-08 21:01:52 +08:00
import { Setting } from './components/Setting/index'
import { Behind } from './components/Behind/index'
2022-01-16 22:17:34 +08:00
import { ContentDrag } from '../ContentDrag/index'
2022-01-08 21:01:52 +08:00
2022-01-16 22:17:34 +08:00
const { getDetails } = toRefs(useChartLayoutStore())
const { setItem } = useChartLayoutStore()
2022-01-06 15:37:44 +08:00
const { CubeIcon, FlashIcon } = icon.ionicons5
2022-01-08 21:01:52 +08:00
2022-01-16 22:17:34 +08:00
const collapsed = ref<boolean>(getDetails.value)
const collapsedHindle = () => {
collapsed.value = true
setItem(ChartLayoutStoreEnums.DETAILS, true)
}
const expandHindle = () => {
collapsed.value = false
setItem(ChartLayoutStoreEnums.DETAILS, false)
}
watch(getDetails, (newData) => {
if (newData) {
collapsedHindle()
} else {
expandHindle()
}
})
const tabList = shallowRef([
2022-01-08 21:01:52 +08:00
{
key: 'setting',
title: '配置项',
2022-01-10 09:49:08 +08:00
icon: CubeIcon,
2022-01-16 22:17:34 +08:00
render: Setting
2022-01-08 21:01:52 +08:00
},
{
key: 'behind',
title: '后端数据',
2022-01-10 09:49:08 +08:00
icon: FlashIcon,
2022-01-16 22:17:34 +08:00
render: Behind
2022-01-08 21:01:52 +08:00
}
])
2022-01-06 13:45:51 +08:00
</script>
2022-01-06 15:37:44 +08:00
<style lang="scss" scoped>
@include go(content-layers) {
padding: 10px;
2022-01-08 21:01:52 +08:00
overflow: hidden;
2022-01-06 15:37:44 +08:00
.icon-position {
padding-top: 2px;
}
}
2022-01-06 13:45:51 +08:00
</style>