mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 图片模板默认使用主题色
This commit is contained in:
parent
c87f9d99b8
commit
fd7a87383d
@ -27,8 +27,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch, computed } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
import tinycolor from 'tinycolor2'
|
||||||
import { useMainStore, useSlidesStore } from '@/store'
|
import { useMainStore, useSlidesStore } from '@/store'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
|
|
||||||
@ -37,16 +38,19 @@ import ColorPicker from '@/components/ColorPicker/index.vue'
|
|||||||
import Switch from '@/components/Switch.vue'
|
import Switch from '@/components/Switch.vue'
|
||||||
import Popover from '@/components/Popover.vue'
|
import Popover from '@/components/Popover.vue'
|
||||||
|
|
||||||
const defaultColorMask = 'rgba(226, 83, 77, 0.5)'
|
|
||||||
|
|
||||||
const slidesStore = useSlidesStore()
|
const slidesStore = useSlidesStore()
|
||||||
const { handleElement, handleElementId } = storeToRefs(useMainStore())
|
const { handleElement, handleElementId } = storeToRefs(useMainStore())
|
||||||
|
const { theme } = storeToRefs(slidesStore)
|
||||||
const colorMask = ref(defaultColorMask)
|
|
||||||
const hasColorMask = ref(false)
|
|
||||||
|
|
||||||
const { addHistorySnapshot } = useHistorySnapshot()
|
const { addHistorySnapshot } = useHistorySnapshot()
|
||||||
|
|
||||||
|
const defaultColorMask = computed(() => {
|
||||||
|
const themeColor = theme.value.themeColors[0]
|
||||||
|
return tinycolor(themeColor).setAlpha(0.5).toRgbString()
|
||||||
|
})
|
||||||
|
const colorMask = ref('')
|
||||||
|
const hasColorMask = ref(false)
|
||||||
|
|
||||||
watch(handleElement, () => {
|
watch(handleElement, () => {
|
||||||
if (!handleElement.value || handleElement.value.type !== 'image') return
|
if (!handleElement.value || handleElement.value.type !== 'image') return
|
||||||
|
|
||||||
@ -60,7 +64,7 @@ watch(handleElement, () => {
|
|||||||
const toggleColorMask = (checked: boolean) => {
|
const toggleColorMask = (checked: boolean) => {
|
||||||
if (!handleElement.value) return
|
if (!handleElement.value) return
|
||||||
if (checked) {
|
if (checked) {
|
||||||
slidesStore.updateElement({ id: handleElement.value.id, props: { colorMask: defaultColorMask } })
|
slidesStore.updateElement({ id: handleElement.value.id, props: { colorMask: defaultColorMask.value } })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
slidesStore.removeElementProps({ id: handleElement.value.id, propName: 'colorMask' })
|
slidesStore.removeElementProps({ id: handleElement.value.id, propName: 'colorMask' })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user