From d040a92b183f472618bbac75352e8cafa0c1c9c7 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu <1171051090@qq.com> Date: Wed, 23 Dec 2020 22:48:35 +0800 Subject: [PATCH] update --- src/hooks/useSlideBackgroundStyle.ts | 17 ++ src/views/Editor/Canvas/SlideBackground.vue | 14 +- src/views/Editor/Thumbnails/index.vue | 9 +- src/views/_common/ThumbnailSlide.vue | 77 ++++++++ src/views/_common/_element/BaseElement.vue | 46 +++++ .../ImageElement/BaseImageElement.vue | 169 ++++++++++++++++++ .../_element/TextElement/BaseTextElement.vue | 93 ++++++++++ .../_common/_element/TextElement/index.vue | 2 +- 8 files changed, 413 insertions(+), 14 deletions(-) create mode 100644 src/hooks/useSlideBackgroundStyle.ts create mode 100644 src/views/_common/ThumbnailSlide.vue create mode 100644 src/views/_common/_element/BaseElement.vue create mode 100644 src/views/_common/_element/ImageElement/BaseImageElement.vue create mode 100644 src/views/_common/_element/TextElement/BaseTextElement.vue diff --git a/src/hooks/useSlideBackgroundStyle.ts b/src/hooks/useSlideBackgroundStyle.ts new file mode 100644 index 0000000..758ace1 --- /dev/null +++ b/src/hooks/useSlideBackgroundStyle.ts @@ -0,0 +1,17 @@ +import { Ref, computed } from 'vue' + +export default (background: Ref<[string, string] | undefined>) => { + const backgroundStyle = computed(() => { + if(!background.value) return { backgroundColor: '#fff' } + + const [type, value] = background.value + if(type === 'solid') return { backgroundColor: value } + else if(type === 'image') return { backgroundImage: `url(${value}` } + + return { backgroundColor: '#fff' } + }) + + return { + backgroundStyle, + } +} \ No newline at end of file diff --git a/src/views/Editor/Canvas/SlideBackground.vue b/src/views/Editor/Canvas/SlideBackground.vue index c29b25f..1234c6e 100644 --- a/src/views/Editor/Canvas/SlideBackground.vue +++ b/src/views/Editor/Canvas/SlideBackground.vue @@ -14,8 +14,8 @@ import { Ref, computed, defineComponent } from 'vue' import { useStore } from 'vuex' import { State } from '@/store' -import { Slide } from '@/types/slides' import GridLines from './GridLines.vue' +import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle' export default defineComponent({ name: 'slide-background', @@ -25,17 +25,9 @@ export default defineComponent({ setup() { const store = useStore() const showGridLines = computed(() => store.state.showGridLines) - const currentSlide: Ref = computed(() => store.getters.currentSlide) + const background: Ref<[string, string] | undefined> = computed(() => store.getters.currentSlide.background) - const backgroundStyle = computed(() => { - if(!currentSlide.value.background) return { backgroundColor: '#fff' } - - const [type, value] = currentSlide.value.background - if(type === 'solid') return { backgroundColor: value } - else if(type === 'image') return { backgroundImage: `url(${value}` } - - return { backgroundColor: '#fff' } - }) + const { backgroundStyle } = useSlideBackgroundStyle(background) return { showGridLines, diff --git a/src/views/Editor/Thumbnails/index.vue b/src/views/Editor/Thumbnails/index.vue index 269c77a..e6116b6 100644 --- a/src/views/Editor/Thumbnails/index.vue +++ b/src/views/Editor/Thumbnails/index.vue @@ -16,7 +16,7 @@ @end="handleDragEnd" itemKey="id" > -