2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<button
|
2022-10-25 17:29:56 +00:00
|
|
|
v-koel-tooltip.top
|
2022-07-15 07:23:55 +00:00
|
|
|
:class="{ active: mode !== 'NO_REPEAT' }"
|
2022-10-25 17:29:56 +00:00
|
|
|
:title="`Change repeat mode (current: ${readableMode})`"
|
2024-04-04 22:20:42 +00:00
|
|
|
class="opacity-30"
|
2022-04-15 14:24:30 +00:00
|
|
|
data-testid="repeat-mode-switch"
|
2022-04-25 13:08:00 +00:00
|
|
|
type="button"
|
2022-05-29 21:37:56 +00:00
|
|
|
@click.prevent="changeMode"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2024-03-27 11:31:39 +00:00
|
|
|
<Repeat1 v-if="mode === 'REPEAT_ONE'" :size="16" />
|
|
|
|
<Repeat v-else :size="16" />
|
2022-04-15 14:24:30 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2024-03-27 11:31:39 +00:00
|
|
|
import { Repeat, Repeat1 } from 'lucide-vue-next'
|
2022-04-25 13:08:00 +00:00
|
|
|
import { computed, toRef } from 'vue'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { playbackService } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { preferenceStore } from '@/stores'
|
|
|
|
|
2024-01-23 22:50:50 +00:00
|
|
|
const mode = toRef(preferenceStore.state, 'repeat_mode')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-29 21:37:56 +00:00
|
|
|
const readableMode = computed(() => mode.value
|
2022-04-15 17:00:08 +00:00
|
|
|
.split('_')
|
|
|
|
.map(part => part[0].toUpperCase() + part.substring(1).toLowerCase())
|
|
|
|
.join(' ')
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-03-18 17:56:17 +00:00
|
|
|
const changeMode = () => playbackService.rotateRepeatMode()
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2022-07-15 07:23:55 +00:00
|
|
|
.active {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply opacity-70;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|