feat: i18n support for quality selector labels
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, onMounted, onUnmounted } from 'vue'
|
import { ref, watch, onMounted, onUnmounted, computed } from 'vue'
|
||||||
import { useI18n } from '@/composables/useI18n'
|
import { useI18n } from '@/composables/useI18n'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { useGameStore } from '@/stores/gameStore'
|
||||||
|
|
||||||
@@ -22,6 +22,19 @@ const emit = defineEmits<{
|
|||||||
const speedLabel = ref('')
|
const speedLabel = ref('')
|
||||||
const showSpeedMenu = ref(false)
|
const showSpeedMenu = ref(false)
|
||||||
const speedOptions = [1, 2, 4]
|
const speedOptions = [1, 2, 4]
|
||||||
|
const showQualityMenu = ref(false)
|
||||||
|
const qualityOptions = computed(() => [
|
||||||
|
{ value: '', label: t('ui.qualityAuto') },
|
||||||
|
{ value: '超清 (1080P)', label: t('ui.quality1080p') },
|
||||||
|
{ value: '高清 (720P)', label: t('ui.quality720p') },
|
||||||
|
{ value: '标清 (480P)', label: t('ui.quality480p') },
|
||||||
|
])
|
||||||
|
|
||||||
|
function currentQualityLabel() {
|
||||||
|
if (!store.preferredQuality) return t('ui.qualityAuto')
|
||||||
|
const found = qualityOptions.value.find(q => q.value === store.preferredQuality)
|
||||||
|
return found?.label || store.preferredQuality
|
||||||
|
}
|
||||||
|
|
||||||
function updateLabel(rate: number) {
|
function updateLabel(rate: number) {
|
||||||
speedLabel.value = rate + 'x'
|
speedLabel.value = rate + 'x'
|
||||||
@@ -33,10 +46,16 @@ function selectSpeed(rate: number) {
|
|||||||
emit('speedChange', rate)
|
emit('speedChange', rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectQuality(q: string) {
|
||||||
|
store.setPreferredQuality(q)
|
||||||
|
showQualityMenu.value = false
|
||||||
|
}
|
||||||
|
|
||||||
function onDocClick(e: MouseEvent) {
|
function onDocClick(e: MouseEvent) {
|
||||||
const target = e.target as HTMLElement
|
const target = e.target as HTMLElement
|
||||||
if (!target.closest('.speed-wrapper')) {
|
if (!target.closest('.speed-wrapper') && !target.closest('.quality-wrapper')) {
|
||||||
showSpeedMenu.value = false
|
showSpeedMenu.value = false
|
||||||
|
showQualityMenu.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,12 +90,22 @@ onUnmounted(() => document.removeEventListener('click', onDocClick))
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="showQuality && !hide" class="bottom-bar right" :class="{ hidden: !visible }">
|
<div v-if="showQuality && !hide" class="bottom-bar right" :class="{ hidden: !visible }">
|
||||||
<select class="bb-select" :value="store.preferredQuality" @change="store.setPreferredQuality(($event.target as HTMLSelectElement).value)">
|
<div class="quality-wrapper">
|
||||||
<option value="">自动</option>
|
<button class="bb-btn" @click.stop="showQualityMenu = !showQualityMenu">
|
||||||
<option value="超清 (1080P)">超清 (1080P)</option>
|
{{ currentQualityLabel() }} ▾
|
||||||
<option value="高清 (720P)">高清 (720P)</option>
|
</button>
|
||||||
<option value="标清 (480P)">标清 (480P)</option>
|
<Transition name="speed-drop">
|
||||||
</select>
|
<div v-if="showQualityMenu" class="speed-menu">
|
||||||
|
<button
|
||||||
|
v-for="q in qualityOptions"
|
||||||
|
:key="q.value"
|
||||||
|
class="speed-option"
|
||||||
|
:class="{ active: store.preferredQuality === q.value }"
|
||||||
|
@click.stop="selectQuality(q.value)"
|
||||||
|
>{{ q.label }}</button>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -132,6 +161,10 @@ onUnmounted(() => document.removeEventListener('click', onDocClick))
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quality-wrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.speed-menu {
|
.speed-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: calc(100% + 4px);
|
bottom: calc(100% + 4px);
|
||||||
@@ -166,17 +199,6 @@ onUnmounted(() => document.removeEventListener('click', onDocClick))
|
|||||||
color: #c9a84c;
|
color: #c9a84c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bb-select {
|
|
||||||
padding: 6px 10px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #ccc;
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
||||||
border-radius: 3px;
|
|
||||||
cursor: pointer;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.speed-drop-enter-active,
|
.speed-drop-enter-active,
|
||||||
.speed-drop-leave-active {
|
.speed-drop-leave-active {
|
||||||
transition: all 0.15s ease;
|
transition: all 0.15s ease;
|
||||||
|
|||||||
@@ -37,6 +37,10 @@
|
|||||||
"qteSingleKey": "QTE Single Key",
|
"qteSingleKey": "QTE Single Key",
|
||||||
"antiMistap": "Anti Mistap",
|
"antiMistap": "Anti Mistap",
|
||||||
"pauseEnabled": "Pause Enabled",
|
"pauseEnabled": "Pause Enabled",
|
||||||
"none": "None"
|
"none": "None",
|
||||||
|
"qualityAuto": "Auto",
|
||||||
|
"quality1080p": "1080p",
|
||||||
|
"quality720p": "720p",
|
||||||
|
"quality480p": "480p"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,10 @@
|
|||||||
"qteSingleKey": "QTE 按键简化",
|
"qteSingleKey": "QTE 按键简化",
|
||||||
"antiMistap": "防误触延迟",
|
"antiMistap": "防误触延迟",
|
||||||
"pauseEnabled": "可暂停",
|
"pauseEnabled": "可暂停",
|
||||||
"none": "无"
|
"none": "无",
|
||||||
|
"qualityAuto": "自动",
|
||||||
|
"quality1080p": "超清",
|
||||||
|
"quality720p": "高清",
|
||||||
|
"quality480p": "标清"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user