feat: 统一画质、编码、音质的名称显示逻辑

This commit is contained in:
lanyeeee
2026-02-01 08:45:46 +08:00
parent c9d377239b
commit f09e8cfc49
4 changed files with 62 additions and 39 deletions
@@ -1,40 +1,10 @@
<script setup lang="ts">
import { AudioQuality, VideoQuality, CodecType } from '../../../bindings.ts'
import { useStore } from '../../../store.ts'
import { VueDraggable } from 'vue-draggable-plus'
import ColorfulTag from '../../../components/ColorfulTag.vue'
import { getVideoQualityName, getAudioQualityName, getCodecTypeName } from '../../../utils.tsx'
const store = useStore()
const videoQualityNameMap: Map<VideoQuality, string> = new Map([
['240P', '240P 极速'],
['360P', '360P 流畅'],
['480P', '480P 标清'],
['720P', '720P 准高清'],
['720P60', '720P 60帧'],
['1080P', '1080P 高清'],
['AiRepair', 'AI智能修复'],
['1080P+', '1080P 高码率'],
['1080P60', '1080P 60帧'],
['4K', '4K 超高清'],
['HDR', 'HDR 真彩色'],
['Dolby', '杜比视界'],
['8K', '8K 超高清'],
])
const audioQualityNameMap: Map<AudioQuality, string> = new Map([
['64K', '64K'],
['132K', '132K'],
['192K', '192K'],
['Dolby', '杜比全景声'],
['HiRes', 'Hi-Res 无损'],
])
const codecTypeNameMap: Map<CodecType, string> = new Map([
['AVC', 'AVC (H.264)'],
['HEVC', 'HEVC (H.265)'],
['AV1', 'AV1'],
])
</script>
<template>
@@ -109,7 +79,7 @@ const codecTypeNameMap: Map<CodecType, string> = new Map([
color="blue"
v-for="videoQuality in store.config.video_quality_priority"
:key="videoQuality">
{{ videoQualityNameMap.get(videoQuality) || videoQuality }}
{{ getVideoQualityName(videoQuality) }}
</ColorfulTag>
</VueDraggable>
</div>
@@ -129,7 +99,7 @@ const codecTypeNameMap: Map<CodecType, string> = new Map([
color="blue"
v-for="audioQuality in store.config.audio_quality_priority"
:key="audioQuality">
{{ audioQualityNameMap.get(audioQuality) || audioQuality }}
{{ getAudioQualityName(audioQuality) }}
</ColorfulTag>
</VueDraggable>
</div>
@@ -148,7 +118,7 @@ const codecTypeNameMap: Map<CodecType, string> = new Map([
color="blue"
v-for="codecType in store.config.codec_type_priority"
:key="codecType">
{{ codecTypeNameMap.get(codecType) || codecType }}
{{ getCodecTypeName(codecType, { AVC: 'AVC (H.264)', HEVC: 'HEVC (H.265)' }) }}
</ColorfulTag>
</VueDraggable>
</div>
@@ -19,7 +19,7 @@ import { computed, DeepReadonly, inject } from 'vue'
import ColorfulTag from '../../../components/ColorfulTag.vue'
import { searchPaneRefKey } from '../../../injection_keys.ts'
import { ProgressData } from '../DownloadPane.vue'
import { ensureHttps } from '../../../utils.tsx'
import { ensureHttps, getAudioQualityName, getCodecTypeName, getVideoQualityName } from '../../../utils.tsx'
import IconButton from '../../../components/IconButton.vue'
import ModifyProgressDialogContent from './ModifyProgressDialogContent.vue'
@@ -170,14 +170,19 @@ function handleModifyClick() {
<div class="mt-auto flex gap-1 flex-wrap pt-2" title="任务内容">
<ColorfulTag v-if="p.video_task.selected" color="blue">
<span :class="{ 'text-gray': p.video_task.skipped }">
<span>视频(编码:{{ p.video_task.codec_type }} 画质:{{ p.video_task.video_quality }})</span>
<span>
<span>视频(</span>
<span>{{ getVideoQualityName(p.video_task.video_quality) }}</span>
<span>&nbsp;-&nbsp;</span>
<span>{{ getCodecTypeName(p.video_task.codec_type) }})</span>
</span>
<span v-if="p.video_task.skipped">(跳过)</span>
</span>
</ColorfulTag>
<ColorfulTag v-if="p.audio_task.selected" color="blue">
<span :class="{ 'text-gray': p.audio_task.skipped }">
<span>音频(音质:{{ p.audio_task.audio_quality }})</span>
<span>音频({{ getAudioQualityName(p.audio_task.audio_quality) }})</span>
<span v-if="p.audio_task.skipped">(跳过)</span>
</span>
</ColorfulTag>
@@ -10,6 +10,7 @@ import {
} from '../../../bindings'
import { ProgressData } from '../DownloadPane.vue'
import { SelectOption } from 'naive-ui'
import { getAudioQualityName, getCodecTypeName, getVideoQualityName } from '../../../utils'
type VideoFormatOption = SelectOption & {
videoQuality: VideoQuality
@@ -43,7 +44,7 @@ const videoFormatOptions = computed<VideoFormatOption[]>(() => {
const videoQuality = videoQualityAndCodecType.video_quality
const codecType = videoQualityAndCodecType.codec_type
return {
label: `画质:${videoQuality} 编码:${codecType}`,
label: `${getVideoQualityName(videoQuality)} - ${getCodecTypeName(codecType)}`,
value: toVideoFormatSelectValue(videoQuality, codecType),
videoQuality: videoQuality,
codecType: codecType,
@@ -64,7 +65,7 @@ const audioFormatOptions = computed<AudioFormatOption[]>(() => {
}
const options: AudioFormatOption[] = availableMediaFormats.value.audio_qualities.map((quality) => {
return { label: quality, value: quality }
return { label: getAudioQualityName(quality), value: quality }
})
return [priorityOption, ...options]
+47
View File
@@ -4,6 +4,7 @@ import { PhChecks, PhCheck, PhX } from '@phosphor-icons/vue'
import { SelectionEvent } from '@viselect/vue'
import TaskToQueueAnimation from './components/TaskToQueueAnimation.vue'
import { EpisodeInfo } from './panes/SearchPane/components/EpisodeCard.vue'
import { AudioQuality, CodecType, VideoQuality } from './bindings'
export function extractAid(url: string): number | undefined {
const parsedUrl = new URL(url)
@@ -235,3 +236,49 @@ export function ensureHttps(url: string): string {
}
return url
}
const videoQualityNameMap: Record<VideoQuality, string> = {
Unknown: '未知',
'240P': '240P 极速',
'360P': '360P 流畅',
'480P': '480P 标清',
'720P': '720P 准高清',
'720P60': '720P 60帧',
'1080P': '1080P 高清',
AiRepair: 'AI智能修复',
'1080P+': '1080P 高码率',
'1080P60': '1080P 60帧',
'4K': '4K 超高清',
HDR: 'HDR 真彩色',
Dolby: '杜比视界',
'8K': '8K 超高清',
}
export function getVideoQualityName(quality: VideoQuality, customMap?: Partial<Record<VideoQuality, string>>): string {
return customMap?.[quality] ?? videoQualityNameMap[quality]
}
const audioQualityNameMap: Record<AudioQuality, string> = {
Unknown: '未知',
'64K': '64K',
'132K': '132K',
'192K': '192K',
Dolby: '杜比全景声',
HiRes: 'Hi-Res 无损',
}
export function getAudioQualityName(quality: AudioQuality, customMap?: Partial<Record<AudioQuality, string>>): string {
return customMap?.[quality] ?? audioQualityNameMap[quality]
}
const codecTypeNameMap: Record<CodecType, string> = {
Unknown: '未知',
Audio: '音频',
AVC: 'AVC',
HEVC: 'HEVC',
AV1: 'AV1',
}
export function getCodecTypeName(codecType: CodecType, customMap?: Partial<Record<CodecType, string>>): string {
return customMap?.[codecType] ?? codecTypeNameMap[codecType]
}