mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🐛 修复默认画质错误,调整 aspect-ratio
This commit is contained in:
@@ -47,22 +47,40 @@ interface TpVodProps {
|
|||||||
|
|
||||||
const props = defineProps<TpVodProps>();
|
const props = defineProps<TpVodProps>();
|
||||||
const container = ref<Artplayer | null>(null);
|
const container = ref<Artplayer | null>(null);
|
||||||
|
const vodAspectRatio = ref<number>(16 / 9);
|
||||||
|
|
||||||
console.log("tpVod", props.data.insert.vod.id, toRaw(props.data).insert.vod);
|
console.log("tpVod", props.data.insert.vod.id, toRaw(props.data).insert.vod);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
const resolutions = props.data.insert.vod.resolutions;
|
||||||
|
const highestResolution = resolutions.reduce((prev, curr) => {
|
||||||
|
return prev.size > curr.size ? prev : curr;
|
||||||
|
});
|
||||||
|
const width = highestResolution.width;
|
||||||
|
const height = highestResolution.height;
|
||||||
|
if (width && height) {
|
||||||
|
width > height
|
||||||
|
? (vodAspectRatio.value = width / height)
|
||||||
|
: (vodAspectRatio.value = height / width);
|
||||||
|
}
|
||||||
const option: Option = {
|
const option: Option = {
|
||||||
id: props.data.insert.vod.id,
|
id: props.data.insert.vod.id,
|
||||||
container: `#tp-vod-${props.data.insert.vod.id}`,
|
container: `#tp-vod-${props.data.insert.vod.id}`,
|
||||||
url: "",
|
url: highestResolution.url,
|
||||||
poster: props.data.insert.vod.cover,
|
poster: props.data.insert.vod.cover,
|
||||||
type: "",
|
type: highestResolution.format,
|
||||||
playbackRate: true,
|
playbackRate: true,
|
||||||
aspectRatio: true,
|
aspectRatio: true,
|
||||||
setting: true,
|
setting: true,
|
||||||
hotkey: true,
|
hotkey: true,
|
||||||
pip: true,
|
pip: true,
|
||||||
quality: [],
|
quality: resolutions.map((resolution) => {
|
||||||
|
return {
|
||||||
|
default: resolution.label == highestResolution.label,
|
||||||
|
html: resolution.label,
|
||||||
|
url: resolution.url,
|
||||||
|
};
|
||||||
|
}),
|
||||||
fullscreen: true,
|
fullscreen: true,
|
||||||
icons: {
|
icons: {
|
||||||
// eslint-disable-next-line @typescript-eslint/quotes
|
// eslint-disable-next-line @typescript-eslint/quotes
|
||||||
@@ -80,32 +98,6 @@ onMounted(async () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const resolutions = props.data.insert.vod.resolutions;
|
|
||||||
let size = 0,
|
|
||||||
label = "";
|
|
||||||
for (const resolution of resolutions) {
|
|
||||||
if (option.url === "") {
|
|
||||||
option.url = resolution.url;
|
|
||||||
option.type = resolution.format;
|
|
||||||
size = resolution.size;
|
|
||||||
label = resolution.label;
|
|
||||||
}
|
|
||||||
if (resolution.size > size) {
|
|
||||||
size = resolution.size;
|
|
||||||
label = resolution.label;
|
|
||||||
}
|
|
||||||
const quality = {
|
|
||||||
default: false,
|
|
||||||
html: resolution.label,
|
|
||||||
url: resolution.url,
|
|
||||||
};
|
|
||||||
option.quality?.push(quality);
|
|
||||||
}
|
|
||||||
option?.quality?.map((item) => {
|
|
||||||
if (item.html == label) {
|
|
||||||
item.default = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
container.value = new Artplayer(option);
|
container.value = new Artplayer(option);
|
||||||
container.value?.on("fullscreen", async (state) => {
|
container.value?.on("fullscreen", async (state) => {
|
||||||
await TauriWindow.getCurrent().setFullscreen(state);
|
await TauriWindow.getCurrent().setFullscreen(state);
|
||||||
@@ -132,14 +124,14 @@ function getVodTime(): string {
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: v-bind(vodAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tp-vod-container {
|
.tp-vod-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: v-bind(vodAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tp-vod-cover {
|
.tp-vod-cover {
|
||||||
|
|||||||
Reference in New Issue
Block a user