mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
添加设置图片元素为背景的功能
This commit is contained in:
parent
91942d4633
commit
081a092db4
@ -17,7 +17,6 @@ import {
|
|||||||
List,
|
List,
|
||||||
OrderedList,
|
OrderedList,
|
||||||
Drag,
|
Drag,
|
||||||
Formula,
|
|
||||||
Helpcenter,
|
Helpcenter,
|
||||||
SplitCells,
|
SplitCells,
|
||||||
MergeCells,
|
MergeCells,
|
||||||
@ -99,6 +98,8 @@ import {
|
|||||||
Undo,
|
Undo,
|
||||||
Transform,
|
Transform,
|
||||||
Click,
|
Click,
|
||||||
|
Theme,
|
||||||
|
Symbol,
|
||||||
} from '@icon-park/vue-next'
|
} from '@icon-park/vue-next'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -109,7 +110,7 @@ export default {
|
|||||||
app.component('IconPentagonOne', PentagonOne)
|
app.component('IconPentagonOne', PentagonOne)
|
||||||
app.component('IconConnection', Connection)
|
app.component('IconConnection', Connection)
|
||||||
app.component('IconInsertTable', InsertTable)
|
app.component('IconInsertTable', InsertTable)
|
||||||
app.component('IconFormula', Formula)
|
app.component('IconSymbol', Symbol)
|
||||||
|
|
||||||
// 剪贴板
|
// 剪贴板
|
||||||
app.component('IconCopy', Copy)
|
app.component('IconCopy', Copy)
|
||||||
@ -231,5 +232,6 @@ export default {
|
|||||||
app.component('IconUndo', Undo)
|
app.component('IconUndo', Undo)
|
||||||
app.component('IconTransform', Transform)
|
app.component('IconTransform', Transform)
|
||||||
app.component('IconClick', Click)
|
app.component('IconClick', Click)
|
||||||
|
app.component('IconTheme', Theme)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -88,13 +88,14 @@
|
|||||||
<Button class="full-width-btn"><IconTransform class="btn-icon" /> 替换图片</Button>
|
<Button class="full-width-btn"><IconTransform class="btn-icon" /> 替换图片</Button>
|
||||||
</FileInput>
|
</FileInput>
|
||||||
<Button class="full-width-btn" @click="resetImage()"><IconUndo class="btn-icon" /> 重置样式</Button>
|
<Button class="full-width-btn" @click="resetImage()"><IconUndo class="btn-icon" /> 重置样式</Button>
|
||||||
|
<Button class="full-width-btn" @click="setBackgroundImage()"><IconTheme class="btn-icon" /> 设为背景</Button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, ref, watch } from 'vue'
|
import { computed, defineComponent, ref, watch } from 'vue'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { PPTImageElement } from '@/types/slides'
|
import { PPTImageElement, Slide } from '@/types/slides'
|
||||||
import { CLIPPATHS } from '@/configs/imageClip'
|
import { CLIPPATHS } from '@/configs/imageClip'
|
||||||
import { getImageDataURL } from '@/utils/image'
|
import { getImageDataURL } from '@/utils/image'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
@ -165,6 +166,7 @@ export default defineComponent({
|
|||||||
setup() {
|
setup() {
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const handleElement = computed<PPTImageElement>(() => store.getters.handleElement)
|
const handleElement = computed<PPTImageElement>(() => store.getters.handleElement)
|
||||||
|
const currentSlide = computed<Slide>(() => store.getters.currentSlide)
|
||||||
|
|
||||||
const clipPanelVisible = ref(false)
|
const clipPanelVisible = ref(false)
|
||||||
|
|
||||||
@ -325,6 +327,17 @@ export default defineComponent({
|
|||||||
addHistorySnapshot()
|
addHistorySnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setBackgroundImage = () => {
|
||||||
|
const background = {
|
||||||
|
...currentSlide.value.background,
|
||||||
|
type: 'image',
|
||||||
|
image: handleElement.value.src,
|
||||||
|
imageSize: 'cover',
|
||||||
|
}
|
||||||
|
store.commit(MutationTypes.UPDATE_SLIDE, { background })
|
||||||
|
addHistorySnapshot()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clipPanelVisible,
|
clipPanelVisible,
|
||||||
shapeClipPathOptions,
|
shapeClipPathOptions,
|
||||||
@ -338,6 +351,7 @@ export default defineComponent({
|
|||||||
presetImageClip,
|
presetImageClip,
|
||||||
replaceImage,
|
replaceImage,
|
||||||
resetImage,
|
resetImage,
|
||||||
|
setBackgroundImage,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user