mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-21 05:25:45 +08:00
⚡️ 全屏播放视频,默认最高清晰度
This commit is contained in:
@@ -13,7 +13,7 @@ edition = "2021"
|
|||||||
tauri-build = { version = "1.4", features = [] }
|
tauri-build = { version = "1.4", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "1.4", features = [ "dialog-message", "process-exit", "fs-read-dir", "window-hide", "os-all", "clipboard-all", "dialog-open", "dialog-save", "fs-create-dir", "fs-remove-dir", "fs-write-file", "fs-remove-file", "fs-read-file", "path-all", "fs-exists", "window-close", "window-set-title", "window-unminimize", "window-show", "window-set-focus", "http-request", "shell-open"] }
|
tauri = { version = "1.4", features = [ "window-set-fullscreen", "dialog-message", "process-exit", "fs-read-dir", "window-hide", "os-all", "clipboard-all", "dialog-open", "dialog-save", "fs-create-dir", "fs-remove-dir", "fs-write-file", "fs-remove-file", "fs-read-file", "path-all", "fs-exists", "window-close", "window-set-title", "window-unminimize", "window-show", "window-set-focus", "http-request", "shell-open"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
url = "2.4.1"
|
url = "2.4.1"
|
||||||
|
|||||||
@@ -47,11 +47,12 @@
|
|||||||
},
|
},
|
||||||
"window": {
|
"window": {
|
||||||
"all": false,
|
"all": false,
|
||||||
|
"setFocus": true,
|
||||||
"setTitle": true,
|
"setTitle": true,
|
||||||
|
"setFullscreen": true,
|
||||||
"unminimize": true,
|
"unminimize": true,
|
||||||
"show": true,
|
"show": true,
|
||||||
"close": true,
|
"close": true,
|
||||||
"setFocus": true,
|
|
||||||
"hide": true
|
"hide": true
|
||||||
},
|
},
|
||||||
"os": {
|
"os": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tp-vod-box">
|
<div class="tp-vod-box">
|
||||||
<div class="tp-vod-container" data-html2canvas-ignore />
|
<div class="tp-vod-container" data-html2canvas-ignore></div>
|
||||||
<div class="tp-vod-cover">
|
<div class="tp-vod-cover">
|
||||||
<img alt="cover" :src="props.data.insert.vod.cover" />
|
<img alt="cover" :src="props.data.insert.vod.cover" />
|
||||||
<img src="/source/UI/video_play.svg" alt="icon" />
|
<img src="/source/UI/video_play.svg" alt="icon" />
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { window as TauriWindow } from "@tauri-apps/api";
|
||||||
import Artplayer from "artplayer";
|
import Artplayer from "artplayer";
|
||||||
import type { Option } from "artplayer/types/option";
|
import type { Option } from "artplayer/types/option";
|
||||||
import { onMounted, ref, toRaw } from "vue";
|
import { onMounted, ref, toRaw } from "vue";
|
||||||
@@ -51,13 +52,13 @@ onMounted(async () => {
|
|||||||
url: "",
|
url: "",
|
||||||
poster: props.data.insert.vod.cover,
|
poster: props.data.insert.vod.cover,
|
||||||
type: "",
|
type: "",
|
||||||
autoSize: true,
|
|
||||||
playbackRate: true,
|
playbackRate: true,
|
||||||
aspectRatio: true,
|
aspectRatio: true,
|
||||||
setting: true,
|
setting: true,
|
||||||
hotkey: true,
|
hotkey: true,
|
||||||
pip: true,
|
pip: true,
|
||||||
quality: [],
|
quality: [],
|
||||||
|
fullscreen: true,
|
||||||
icons: {
|
icons: {
|
||||||
// eslint-disable-next-line @typescript-eslint/quotes
|
// eslint-disable-next-line @typescript-eslint/quotes
|
||||||
state: `<img src="/source/UI/video_play.svg" alt="icon" />`,
|
state: `<img src="/source/UI/video_play.svg" alt="icon" />`,
|
||||||
@@ -75,10 +76,18 @@ onMounted(async () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
const resolutions = props.data.insert.vod.resolutions;
|
const resolutions = props.data.insert.vod.resolutions;
|
||||||
resolutions.forEach((resolution) => {
|
let size = 0,
|
||||||
|
label = "";
|
||||||
|
for (const resolution of resolutions) {
|
||||||
if (option.url === "") {
|
if (option.url === "") {
|
||||||
option.url = resolution.url;
|
option.url = resolution.url;
|
||||||
option.type = resolution.format;
|
option.type = resolution.format;
|
||||||
|
size = resolution.size;
|
||||||
|
label = resolution.label;
|
||||||
|
}
|
||||||
|
if (resolution.size > size) {
|
||||||
|
size = resolution.size;
|
||||||
|
label = resolution.label;
|
||||||
}
|
}
|
||||||
const quality = {
|
const quality = {
|
||||||
default: false,
|
default: false,
|
||||||
@@ -86,8 +95,16 @@ onMounted(async () => {
|
|||||||
url: resolution.url,
|
url: resolution.url,
|
||||||
};
|
};
|
||||||
option.quality?.push(quality);
|
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) => {
|
||||||
|
await TauriWindow.getCurrent().setFullscreen(state);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getVodTime(): string {
|
function getVodTime(): string {
|
||||||
@@ -114,8 +131,8 @@ function getVodTime(): string {
|
|||||||
.tp-vod-container {
|
.tp-vod-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
height: 450px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
aspect-ratio: 16 / 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tp-vod-cover {
|
.tp-vod-cover {
|
||||||
|
|||||||
Reference in New Issue
Block a user