feat: i18n system, lang switch component, english subtitles, UI improvements, roadmap update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
|
||||
interface SubCue {
|
||||
start: number
|
||||
@@ -10,20 +10,25 @@ interface SubCue {
|
||||
const props = defineProps<{
|
||||
currentTime: number
|
||||
subtitleUrl: string | null
|
||||
subtitles?: Record<string, string> | null
|
||||
lang?: string
|
||||
}>()
|
||||
|
||||
const cues = ref<SubCue[]>([])
|
||||
const currentText = ref('')
|
||||
const loadedUrl = ref('')
|
||||
|
||||
watch(() => props.subtitleUrl, async (url) => {
|
||||
const effectiveUrl = computed(() => {
|
||||
if (props.lang && props.subtitles?.[props.lang]) return props.subtitles[props.lang]
|
||||
return props.subtitleUrl
|
||||
})
|
||||
|
||||
watch(effectiveUrl, async (url) => {
|
||||
if (!url) {
|
||||
cues.value = []
|
||||
currentText.value = ''
|
||||
loadedUrl.value = ''
|
||||
return
|
||||
}
|
||||
if (url === loadedUrl.value) return
|
||||
loadedUrl.value = url
|
||||
try {
|
||||
const resp = await fetch(url)
|
||||
|
||||
Reference in New Issue
Block a user