feat: 接入黄豆短剧独立清单与下载

This commit is contained in:
Nixevol
2026-10-21 22:54:56 +08:00
parent e31e80384c
commit 5b4a948e5f
25 changed files with 2093 additions and 132 deletions
+19 -6
View File
@@ -6,13 +6,18 @@ interface Episode {
idx: number;
title: string;
playable: boolean;
media?: string;
locked_reason?: string;
is_preview?: boolean;
}
const props = defineProps<{
token: string;
device: object | null;
dramaId: number;
dramaId: string | number;
apiBase?: string;
}>();
const apiBase = computed(() => props.apiBase || "/api");
const episodes = ref<Episode[]>([]);
const current = ref<number | null>(null);
@@ -27,7 +32,7 @@ async function load() {
loading.value = true;
error.value = "";
try {
const response = await fetch("/api/play/episodes", {
const response = await fetch(`${apiBase.value}/play/episodes`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token: props.token, device: props.device, vid: props.dramaId }),
@@ -62,7 +67,13 @@ function attach(cid: number) {
const video = videoRef.value;
if (!video) return;
stop();
const url = `/api/play/${props.dramaId}/${cid}/index.m3u8`;
const episode = episodes.value.find((item) => item.cid === cid);
if (episode?.media === "file") {
video.src = `${apiBase.value}/play/${props.dramaId}/${cid}/file`;
video.play().catch(() => undefined);
return;
}
const url = `${apiBase.value}/play/${props.dramaId}/${cid}/index.m3u8`;
if (Hls.isSupported()) {
const player = new Hls();
hls = player;
@@ -115,7 +126,8 @@ onUnmounted(stop);
@click="select(episode)"
>
<span class="play-episode-title">{{ episode.title }}</span>
<span v-if="!episode.playable" class="play-episode-lock">无地址</span>
<span v-if="!episode.playable" class="play-episode-lock">{{ episode.locked_reason || "无地址" }}</span>
<span v-else-if="episode.is_preview" class="play-episode-lock">试看</span>
</button>
<div v-if="!loading && episodes.length === 0" class="play-empty">没有分集</div>
</div>
@@ -157,8 +169,9 @@ onUnmounted(stop);
.play-episode {
width: 100%;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
gap: 4px 8px;
min-height: 36px;
margin: 0 0 4px;
padding: 6px 10px;
@@ -173,6 +186,6 @@ onUnmounted(stop);
.play-episode.current { background: rgba(99, 226, 183, 0.16); }
.play-episode:disabled { color: rgba(255, 255, 255, 0.35); cursor: default; }
.play-episode-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-episode-lock { flex: none; font-size: 12px; }
.play-episode-lock { flex: 1 1 100%; font-size: 12px; line-height: 1.3; white-space: normal; }
.play-empty { padding: 8px 10px; color: rgba(255, 255, 255, 0.45); }
</style>