AudioStylePanel.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div class="audio-style-panel">
  3. <div class="row">
  4. <div style="width: 40%;">图标颜色:</div>
  5. <Popover trigger="click" style="width: 60%;">
  6. <template #content>
  7. <ColorPicker
  8. :modelValue="handleAudioElement.color"
  9. @update:modelValue="value => updateAudio({ color: value })"
  10. />
  11. </template>
  12. <ColorButton :color="handleAudioElement.color" />
  13. </Popover>
  14. </div>
  15. <div class="row switch-row">
  16. <div style="width: 40%;">自动播放:</div>
  17. <div class="switch-wrapper" style="width: 60%;">
  18. <Switch
  19. :value="handleAudioElement.autoplay"
  20. @update:value="value => updateAudio({ autoplay: value })"
  21. />
  22. </div>
  23. </div>
  24. <div class="row switch-row">
  25. <div style="width: 40%;">循环播放:</div>
  26. <div class="switch-wrapper" style="width: 60%;">
  27. <Switch
  28. :value="handleAudioElement.loop"
  29. @update:value="value => updateAudio({ loop: value })"
  30. />
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script lang="ts" setup>
  36. import type { Ref } from 'vue'
  37. import { storeToRefs } from 'pinia'
  38. import { useMainStore, useSlidesStore } from '@/store'
  39. import type { PPTAudioElement } from '@/types/slides'
  40. import useHistorySnapshot from '@/hooks/useHistorySnapshot'
  41. import ColorButton from '@/components/ColorButton.vue'
  42. import ColorPicker from '@/components/ColorPicker/index.vue'
  43. import Switch from '@/components/Switch.vue'
  44. import Popover from '@/components/Popover.vue'
  45. const slidesStore = useSlidesStore()
  46. const { handleElement } = storeToRefs(useMainStore())
  47. const handleAudioElement = handleElement as Ref<PPTAudioElement>
  48. const { addHistorySnapshot } = useHistorySnapshot()
  49. const updateAudio = (props: Partial<PPTAudioElement>) => {
  50. if (!handleElement.value) return
  51. slidesStore.updateElement({ id: handleElement.value.id, props })
  52. addHistorySnapshot()
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .row {
  57. width: 100%;
  58. display: flex;
  59. align-items: center;
  60. margin-bottom: 10px;
  61. }
  62. .switch-row {
  63. height: 32px;
  64. }
  65. .switch-wrapper {
  66. text-align: right;
  67. }
  68. </style>