index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div class="element-style-panel">
  3. <div v-if="!currentPanelComponent">
  4. 请先选中要编辑的元素
  5. </div>
  6. <component v-if="handleElement" :is="currentPanelComponent"></component>
  7. </div>
  8. </template>
  9. <script lang="ts">
  10. import { computed, defineComponent, Ref } from 'vue'
  11. import { useStore } from 'vuex'
  12. import { State } from '@/store'
  13. import { ElementTypes, PPTElement } from '@/types/slides'
  14. import TextStylePanel from './TextStylePanel.vue'
  15. import ImageStylePanel from './ImageStylePanel.vue'
  16. import ShapeStylePanel from './ShapeStylePanel.vue'
  17. import LineStylePanel from './LineStylePanel.vue'
  18. import ChartStylePanel from './ChartStylePanel/index.vue'
  19. export default defineComponent({
  20. name: 'element-style-panel',
  21. setup() {
  22. const store = useStore<State>()
  23. const handleElement: Ref<PPTElement> = computed(() => store.getters.handleElement)
  24. const currentPanelComponent = computed(() => {
  25. if(!handleElement.value) return null
  26. const panelMap = {
  27. [ElementTypes.TEXT]: TextStylePanel,
  28. [ElementTypes.IMAGE]: ImageStylePanel,
  29. [ElementTypes.SHAPE]: ShapeStylePanel,
  30. [ElementTypes.LINE]: LineStylePanel,
  31. [ElementTypes.CHART]: ChartStylePanel,
  32. }
  33. return panelMap[handleElement.value.type] || null
  34. })
  35. return {
  36. handleElement,
  37. currentPanelComponent,
  38. }
  39. },
  40. })
  41. </script>