index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <n-layout has-sider sider-placement="right">
  3. <n-layout-content>
  4. <!-- 为了展示折叠的按钮,放在了这里 呜呜呜 -->
  5. <ContentDrag />
  6. </n-layout-content>
  7. <n-layout-sider
  8. collapse-mode="transform"
  9. :collapsed-width="0"
  10. :width="350"
  11. :collapsed="collapsed"
  12. :native-scrollbar="false"
  13. show-trigger="bar"
  14. @collapse="collapsedHindle"
  15. @expand="expandHindle"
  16. >
  17. <ContentBox class="go-content-layers go-boderbox" :showTop="false" :depth="2">
  18. <n-tabs class="tabs-box" size="small" type="segment">
  19. <n-tab-pane
  20. v-for="item in tabList"
  21. :key="item.key"
  22. :name="item.key"
  23. display-directive="show:lazy"
  24. >
  25. <template #tab>
  26. <n-space>
  27. <span>{{ item.title }}</span>
  28. <n-icon size="16" class="icon-position">
  29. <component :is="item.icon"></component>
  30. </n-icon>
  31. </n-space>
  32. </template>
  33. <component :is="item.render"></component>
  34. </n-tab-pane>
  35. </n-tabs>
  36. </ContentBox>
  37. </n-layout-sider>
  38. </n-layout>
  39. </template>
  40. <script setup lang="ts">
  41. import { shallowRef, ref, toRefs, watch, reactive } from 'vue'
  42. import { icon } from '@/plugins'
  43. import { ContentBox } from '../ContentBox/index'
  44. import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
  45. import { ChartLayoutStoreEnums } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  46. import { Setting } from './components/Setting/index'
  47. import { Behind } from './components/Behind/index'
  48. import { Page } from './components/Page/index'
  49. import { ContentDrag } from '../ContentDrag/index'
  50. const { getDetails } = toRefs(useChartLayoutStore())
  51. const { setItem } = useChartLayoutStore()
  52. const { CubeIcon, FlashIcon } = icon.ionicons5
  53. const collapsed = ref<boolean>(getDetails.value)
  54. const collapsedHindle = () => {
  55. collapsed.value = true
  56. setItem(ChartLayoutStoreEnums.DETAILS, true)
  57. }
  58. const expandHindle = () => {
  59. collapsed.value = false
  60. setItem(ChartLayoutStoreEnums.DETAILS, false)
  61. }
  62. watch(getDetails, (newData) => {
  63. if (newData) {
  64. collapsedHindle()
  65. } else {
  66. expandHindle()
  67. }
  68. })
  69. // 页面设置
  70. const pageSetting = reactive({
  71. key: 'pageSetting',
  72. title: '页面设置',
  73. render: Page
  74. })
  75. const tabList = shallowRef([
  76. {
  77. key: 'setting',
  78. title: '设置',
  79. icon: CubeIcon,
  80. render: Setting
  81. },
  82. {
  83. key: 'behind',
  84. title: '后端数据',
  85. icon: FlashIcon,
  86. render: Behind
  87. }
  88. ])
  89. </script>
  90. <style lang="scss" scoped>
  91. @include go(content-layers) {
  92. padding: 10px;
  93. overflow: hidden;
  94. .icon-position {
  95. padding-top: 2px;
  96. }
  97. }
  98. </style>