Skip to content

Commit

Permalink
✨ 视频支持封面下载
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Jul 12, 2024
1 parent ea5e568 commit 3347482
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/post/tp-vod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import Artplayer from "artplayer";
import type { Option } from "artplayer/types/option.js";
import { onMounted, ref, toRaw } from "vue";
import { getImageBuffer, saveCanvasImg } from "../../utils/TGShare.js";
import { bytesToSize } from "../../utils/toolFunc.js";
import showSnackbar from "../func/snackbar.js";
interface TpVod {
insert: {
vod: {
Expand Down Expand Up @@ -97,6 +101,19 @@ onMounted(async () => {
}</span>`,
tooltip: `播放数:${props.data.insert.vod?.view_num ?? 0}`,
},
{
name: "download-cover",
index: 0,
position: "right",
html: `<i class="mdi mdi-download"></i>`,
tooltip: "下载封面",
click: async () => {
const buffer = await getImageBuffer(props.data.insert.vod.cover);
const size = bytesToSize(buffer.byteLength);
await saveCanvasImg(buffer, `vod-cover-${props.data.insert.vod.id}`);
showSnackbar({ text: `封面已下载到本地,大小:${size}` });
},
},
],
};
container.value = new Artplayer(option);
Expand Down

0 comments on commit 3347482

Please sign in to comment.