owe
This commit is contained in:
1 parent
9b9f07dea5
commit
2e1974c35d
15 files changed
+406
-169
No files matched your search
@@ -82,6 +82,7 @@ import { Howl } from "howler";
|
||||
import { PublishVideoEntity } from "@/data/auto/publishVideoEntity";
|
||||
import publishVideoService from "@/service/master/publishVideoService";
|
||||
import { useWindowSize } from "@vueuse/core";
|
||||
import { request } from "@/utils/request";
|
||||
import fileTypePolicy from "@/policy/custom/fileTypePolicy";
|
||||
import { PublishAudioEntity } from "@/data/auto/publishAudioEntity";
|
||||
import { FamilyFolderFavoriteViewEntity } from "@/data/auto/familyFolderFavoriteViewEntity";
|
||||
@@ -292,18 +293,20 @@ const onChangeFolder = async (fvalue: string) => {
|
||||
onSearchByFilePath(fvalue);
|
||||
};
|
||||
|
||||
/** DMS 记录 → 播放列表项(m3u8 的封面用同名 png 兜底) */
|
||||
/** DMS 记录 → 播放列表项:Url=原码、FormattedM3u8=转码(10秒),封面用同名 png 兜底 */
|
||||
const toVideoItem = (
|
||||
record: DmsFileUploadDeleteLogViewDisplayData,
|
||||
): VideoItem => {
|
||||
const item = new PublishVideoDetailDisplayData();
|
||||
item.Title = record.OrgFileName;
|
||||
item.FormattedUrl = record.Url;
|
||||
item.Url = record.Url;
|
||||
item.FormattedM3u8 = record.FormattedM3u8;
|
||||
item.FormattedUrl = record.FormattedM3u8 || record.Url;
|
||||
item.FormattedPic = (record.FormattedPic || "").replace(/\.m3u8$/, ".png");
|
||||
return item;
|
||||
};
|
||||
|
||||
/** 当前目录里已转码(有 Url)的视频,作为弹窗播放器的播放列表 */
|
||||
/** 当前目录里的视频,作为弹窗播放器的播放列表 */
|
||||
const buildVideoList = (
|
||||
records: DmsFileUploadDeleteLogViewDisplayData[],
|
||||
): VideoItem[] =>
|
||||
@@ -312,7 +315,7 @@ const buildVideoList = (
|
||||
(x) =>
|
||||
x.IsDirectoryIndc != "Y" &&
|
||||
fileTypePolicy.isVideo(x.OrderKey || x.OrgFileName) &&
|
||||
!!x.Url,
|
||||
!!(x.FormattedM3u8 || x.Url),
|
||||
)
|
||||
.map(toVideoItem);
|
||||
|
||||
@@ -328,27 +331,6 @@ const openVideoPlay = (list: VideoItem[], index: number, title: string) => {
|
||||
videoPlayModal.value = true;
|
||||
};
|
||||
|
||||
/** 未转码的视频没有 Url,直接取源片路径播放 */
|
||||
const onSourceVideoPlay = async (
|
||||
record: DmsFileUploadDeleteLogViewDisplayData,
|
||||
) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const url = await dmsFileService.FindDeleteLogM3u8Path(record.FileId);
|
||||
const item = toVideoItem(record);
|
||||
item.FormattedUrl = url;
|
||||
openVideoPlay([item], 0, record.OrgFileName);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "视频加载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onPreviewFile = async (
|
||||
usernameOrRecord: any,
|
||||
orderKey?: string,
|
||||
@@ -483,8 +465,57 @@ const onShareFamily = async (record: Record<string, any>) => {
|
||||
showModalShare.value = true;
|
||||
};
|
||||
|
||||
const onDownloadFile = async (fid: number, fname: string) => {
|
||||
GetOrgPictureFile(fid, fname, false);
|
||||
/** 按 URL 直接下载(视频走这条:Url 就是原码文件) */
|
||||
const downloadByUrl = async (url: string, fileName: string) => {
|
||||
if (!url) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "该文件没有可下载的地址",
|
||||
placement: "topRight",
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
spinTip.value = "下载中...";
|
||||
// 与 VideoPlayer 一致:先取回字节流,再用 Blob + <a download> 落盘
|
||||
const res = await request<ArrayBuffer>({
|
||||
url,
|
||||
method: "get",
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
const blobUrl = window.URL.createObjectURL(new Blob([res]));
|
||||
const link = document.createElement("a");
|
||||
link.href = blobUrl;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
setTimeout(() => window.URL.revokeObjectURL(blobUrl), 1000);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "下载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
spinTip.value = "加载中...";
|
||||
}
|
||||
};
|
||||
|
||||
/** 下载一条记录:视频下原码,其它文件走原来的分片合并下载 */
|
||||
const onDownloadFile = async (
|
||||
record: DmsFileUploadDeleteLogViewDisplayData,
|
||||
) => {
|
||||
if (
|
||||
fileTypePolicy.isVideo(record.OrgFileName) ||
|
||||
fileTypePolicy.isVideo(record.OrderKey)
|
||||
) {
|
||||
await downloadByUrl(record.Url, record.OrgFileName);
|
||||
return;
|
||||
}
|
||||
GetOrgPictureFile(record.FileId, record.OrgFileName, false);
|
||||
};
|
||||
|
||||
const GetOrgPictureFile = async (
|
||||
@@ -975,16 +1006,19 @@ const onOpenFile = (record: DmsFileUploadDeleteLogViewDisplayData) => {
|
||||
} else if (fileTypePolicy.isAudio(record.OrgFileName)) {
|
||||
onPlayAudio(toUploadView(record));
|
||||
} else {
|
||||
onDownloadFile(record.FileId, record.OrgFileName);
|
||||
onDownloadFile(record);
|
||||
}
|
||||
};
|
||||
|
||||
const onDownloadSelected = (items: DmsFileUploadDeleteLogViewDisplayData[]) => {
|
||||
items.forEach((item) => {
|
||||
const onDownloadSelected = async (
|
||||
items: DmsFileUploadDeleteLogViewDisplayData[],
|
||||
) => {
|
||||
// 逐个串行下载:并发触发多个 <a download> 浏览器会拦截后面的
|
||||
for (const item of items) {
|
||||
if (item.IsDirectoryIndc != "Y") {
|
||||
onDownloadFile(item.FileId, item.OrgFileName);
|
||||
await onDownloadFile(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onShareSelected = (items: DmsFileUploadDeleteLogViewDisplayData[]) => {
|
||||
@@ -1018,15 +1052,9 @@ const onViewPreviewSelected = (items: DmsFileUploadDeleteLogViewDisplayData[]) =
|
||||
};
|
||||
|
||||
/** 播放视频:把当前目录的视频串成播放列表,从点中的那一个开始 */
|
||||
const onUrlVideoPlayItem = async (
|
||||
record: DmsFileUploadDeleteLogViewDisplayData,
|
||||
) => {
|
||||
if (!record.Url) {
|
||||
await onSourceVideoPlay(record);
|
||||
return;
|
||||
}
|
||||
const onUrlVideoPlayItem = (record: DmsFileUploadDeleteLogViewDisplayData) => {
|
||||
const list = buildVideoList(datas.value);
|
||||
let index = list.findIndex((x) => x.FormattedUrl === record.Url);
|
||||
let index = list.findIndex((x) => x.Url === record.Url);
|
||||
if (index < 0) {
|
||||
list.unshift(toVideoItem(record));
|
||||
index = 0;
|
||||
|
||||
@@ -88,6 +88,7 @@ import { Howl } from "howler";
|
||||
import { PublishVideoEntity } from "@/data/auto/publishVideoEntity";
|
||||
import publishVideoService from "@/service/master/publishVideoService";
|
||||
import { useWindowSize } from "@vueuse/core";
|
||||
import { request } from "@/utils/request";
|
||||
import fileTypePolicy from "@/policy/custom/fileTypePolicy";
|
||||
import { PublishAudioEntity } from "@/data/auto/publishAudioEntity";
|
||||
import { FamilyFolderFavoriteViewEntity } from "@/data/auto/familyFolderFavoriteViewEntity";
|
||||
@@ -462,16 +463,18 @@ const onChangeFolder = async (fvalue: string) => {
|
||||
onSearchByFilePath(fvalue);
|
||||
};
|
||||
|
||||
/** DMS 记录 → 播放列表项(m3u8 的封面用同名 png 兜底) */
|
||||
/** DMS 记录 → 播放列表项:Url=原码、FormattedM3u8=转码(10秒),封面用同名 png 兜底 */
|
||||
const toVideoItem = (record: DmsFileUploadViewDisplayData): VideoItem => {
|
||||
const item = new PublishVideoDetailDisplayData();
|
||||
item.Title = record.OrgFileName;
|
||||
item.FormattedUrl = record.Url;
|
||||
item.Url = record.Url;
|
||||
item.FormattedM3u8 = record.FormattedM3u8;
|
||||
item.FormattedUrl = record.FormattedM3u8 || record.Url;
|
||||
item.FormattedPic = (record.FormattedPic || "").replace(/\.m3u8$/, ".png");
|
||||
return item;
|
||||
};
|
||||
|
||||
/** 当前目录里已转码(有 Url)的视频,作为弹窗播放器的播放列表 */
|
||||
/** 当前目录里的视频,作为弹窗播放器的播放列表 */
|
||||
const buildVideoList = (
|
||||
records: DmsFileUploadViewDisplayData[],
|
||||
): VideoItem[] =>
|
||||
@@ -480,7 +483,7 @@ const buildVideoList = (
|
||||
(x) =>
|
||||
x.IsDirectoryIndc != "Y" &&
|
||||
fileTypePolicy.isVideo(x.OrderKey || x.OrgFileName) &&
|
||||
!!x.Url,
|
||||
!!(x.FormattedM3u8 || x.Url),
|
||||
)
|
||||
.map(toVideoItem);
|
||||
|
||||
@@ -496,25 +499,6 @@ const openVideoPlay = (list: VideoItem[], index: number, title: string) => {
|
||||
videoPlayModal.value = true;
|
||||
};
|
||||
|
||||
/** 未转码的视频没有 Url,直接取源片路径播放 */
|
||||
const onSourceVideoPlay = async (record: DmsFileUploadViewDisplayData) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const url = await dmsFileService.FindSourceVideoPath(record.FileId);
|
||||
const item = toVideoItem(record);
|
||||
item.FormattedUrl = url;
|
||||
openVideoPlay([item], 0, record.OrgFileName);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "视频加载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onPreviewFile = async (usernameOrRecord: any, orderKey?: string) => {
|
||||
let username: string;
|
||||
let fname: string;
|
||||
@@ -643,8 +627,53 @@ const onShareFamily = async (records: DmsFileUploadViewDisplayData[]) => {
|
||||
showModalShare.value = true;
|
||||
};
|
||||
|
||||
const onDownloadFile = async (fid: number, fname: string) => {
|
||||
GetOrgPictureFile(fid, fname, false);
|
||||
/** 按 URL 直接下载(视频走这条:Url 就是原码文件) */
|
||||
const downloadByUrl = async (url: string, fileName: string) => {
|
||||
if (!url) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "该文件没有可下载的地址",
|
||||
placement: "topRight",
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
spinTip.value = "下载中...";
|
||||
// 与 VideoPlayer 一致:先取回字节流,再用 Blob + <a download> 落盘
|
||||
const res = await request<ArrayBuffer>({
|
||||
url,
|
||||
method: "get",
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
const blobUrl = window.URL.createObjectURL(new Blob([res]));
|
||||
const link = document.createElement("a");
|
||||
link.href = blobUrl;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
// 立刻 revoke 部分浏览器会来不及触发下载,延后释放
|
||||
setTimeout(() => window.URL.revokeObjectURL(blobUrl), 1000);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "下载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
spinTip.value = "加载中...";
|
||||
}
|
||||
};
|
||||
|
||||
/** 下载一条记录:视频下原码,其它文件走原来的分片合并下载 */
|
||||
const onDownloadFile = async (record: DmsFileUploadViewDisplayData) => {
|
||||
if (fileTypePolicy.isVideo(record.OrgFileName) || fileTypePolicy.isVideo(record.OrderKey)) {
|
||||
await downloadByUrl(record.Url, record.OrgFileName);
|
||||
return;
|
||||
}
|
||||
GetOrgPictureFile(record.FileId, record.OrgFileName, false);
|
||||
};
|
||||
|
||||
const GetOrgPictureFile = async (
|
||||
@@ -1164,16 +1193,17 @@ const onOpenFile = (record: DmsFileUploadViewDisplayData) => {
|
||||
} else if (fileTypePolicy.isAudio(record.OrgFileName)) {
|
||||
onPlayAudio(toUploadView(record));
|
||||
} else {
|
||||
onDownloadFile(record.FileId, record.OrgFileName);
|
||||
onDownloadFile(record);
|
||||
}
|
||||
};
|
||||
|
||||
const onDownloadSelected = (items: DmsFileUploadViewDisplayData[]) => {
|
||||
items.forEach((item) => {
|
||||
const onDownloadSelected = async (items: DmsFileUploadViewDisplayData[]) => {
|
||||
// 逐个串行下载:并发触发多个 <a download> 浏览器会拦截后面的
|
||||
for (const item of items) {
|
||||
if (item.IsDirectoryIndc != "Y") {
|
||||
onDownloadFile(item.FileId, item.OrgFileName);
|
||||
await onDownloadFile(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onShareSelected = (items: DmsFileUploadViewDisplayData[]) => {
|
||||
@@ -1231,13 +1261,9 @@ const onViewPreviewSelected = (items: DmsFileUploadViewDisplayData[]) => {
|
||||
};
|
||||
|
||||
/** 播放视频:把当前目录的视频串成播放列表,从点中的那一个开始 */
|
||||
const onUrlVideoPlayItem = async (record: DmsFileUploadViewDisplayData) => {
|
||||
if (!record.Url) {
|
||||
await onSourceVideoPlay(record);
|
||||
return;
|
||||
}
|
||||
const onUrlVideoPlayItem = (record: DmsFileUploadViewDisplayData) => {
|
||||
const list = buildVideoList(datas.value);
|
||||
let index = list.findIndex((x) => x.FormattedUrl === record.Url);
|
||||
let index = list.findIndex((x) => x.Url === record.Url);
|
||||
if (index < 0) {
|
||||
list.unshift(toVideoItem(record));
|
||||
index = 0;
|
||||
|
||||
@@ -74,6 +74,7 @@ import { Howl } from "howler";
|
||||
import { PublishVideoEntity } from "@/data/auto/publishVideoEntity";
|
||||
import publishVideoService from "@/service/master/publishVideoService";
|
||||
import { useWindowSize } from "@vueuse/core";
|
||||
import { request } from "@/utils/request";
|
||||
import fileTypePolicy from "@/policy/custom/fileTypePolicy";
|
||||
import { PublishAudioEntity } from "@/data/auto/publishAudioEntity";
|
||||
import { FamilyFolderFavoriteViewEntity } from "@/data/auto/familyFolderFavoriteViewEntity";
|
||||
@@ -292,16 +293,18 @@ const onChangeFolder = async (fvalue: string) => {
|
||||
onSearchByFilePath(fvalue);
|
||||
};
|
||||
|
||||
/** DMS 记录 → 播放列表项(m3u8 的封面用同名 png 兜底) */
|
||||
/** DMS 记录 → 播放列表项:Url=原码、FormattedM3u8=转码(10秒),封面用同名 png 兜底 */
|
||||
const toVideoItem = (record: FamilyDmsFileViewDisplayData): VideoItem => {
|
||||
const item = new PublishVideoDetailDisplayData();
|
||||
item.Title = record.OrgFileName;
|
||||
item.FormattedUrl = record.Url;
|
||||
item.Url = record.Url;
|
||||
item.FormattedM3u8 = record.FormattedM3u8;
|
||||
item.FormattedUrl = record.FormattedM3u8 || record.Url;
|
||||
item.FormattedPic = (record.FormattedPic || "").replace(/\.m3u8$/, ".png");
|
||||
return item;
|
||||
};
|
||||
|
||||
/** 当前目录里已转码(有 Url)的视频,作为弹窗播放器的播放列表 */
|
||||
/** 当前目录里的视频,作为弹窗播放器的播放列表 */
|
||||
const buildVideoList = (
|
||||
records: FamilyDmsFileViewDisplayData[],
|
||||
): VideoItem[] =>
|
||||
@@ -310,7 +313,7 @@ const buildVideoList = (
|
||||
(x) =>
|
||||
x.IsDirectoryIndc != "Y" &&
|
||||
fileTypePolicy.isVideo(x.OrderKey || x.OrgFileName) &&
|
||||
!!x.Url,
|
||||
!!(x.FormattedM3u8 || x.Url),
|
||||
)
|
||||
.map(toVideoItem);
|
||||
|
||||
@@ -326,25 +329,6 @@ const openVideoPlay = (list: VideoItem[], index: number, title: string) => {
|
||||
videoPlayModal.value = true;
|
||||
};
|
||||
|
||||
/** 未转码的视频没有 Url,直接取源片路径播放 */
|
||||
const onSourceVideoPlay = async (record: FamilyDmsFileViewDisplayData) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const url = await dmsFileService.FindSourceVideoPath(record.FileId);
|
||||
const item = toVideoItem(record);
|
||||
item.FormattedUrl = url;
|
||||
openVideoPlay([item], 0, record.OrgFileName);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "视频加载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onPreviewFile = async (usernameOrRecord: any, orderKey?: string) => {
|
||||
let username: string;
|
||||
let fname: string;
|
||||
@@ -473,8 +457,55 @@ const onShareFamily = async (record: Record<string, any>) => {
|
||||
showModalShare.value = true;
|
||||
};
|
||||
|
||||
const onDownloadFile = async (fid: number, fname: string) => {
|
||||
GetOrgPictureFile(fid, fname, false);
|
||||
/** 按 URL 直接下载(视频走这条:Url 就是原码文件) */
|
||||
const downloadByUrl = async (url: string, fileName: string) => {
|
||||
if (!url) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "该文件没有可下载的地址",
|
||||
placement: "topRight",
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
spinTip.value = "下载中...";
|
||||
// 与 VideoPlayer 一致:先取回字节流,再用 Blob + <a download> 落盘
|
||||
const res = await request<ArrayBuffer>({
|
||||
url,
|
||||
method: "get",
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
const blobUrl = window.URL.createObjectURL(new Blob([res]));
|
||||
const link = document.createElement("a");
|
||||
link.href = blobUrl;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
setTimeout(() => window.URL.revokeObjectURL(blobUrl), 1000);
|
||||
} catch (error) {
|
||||
notification.info({
|
||||
message: "系统提示:",
|
||||
description: "下载失败",
|
||||
placement: "topRight",
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
spinTip.value = "加载中...";
|
||||
}
|
||||
};
|
||||
|
||||
/** 下载一条记录:视频下原码,其它文件走原来的分片合并下载 */
|
||||
const onDownloadFile = async (record: FamilyDmsFileViewDisplayData) => {
|
||||
if (
|
||||
fileTypePolicy.isVideo(record.OrgFileName) ||
|
||||
fileTypePolicy.isVideo(record.OrderKey)
|
||||
) {
|
||||
await downloadByUrl(record.Url, record.OrgFileName);
|
||||
return;
|
||||
}
|
||||
GetOrgPictureFile(record.FileId, record.OrgFileName, false);
|
||||
};
|
||||
|
||||
const GetOrgPictureFile = async (
|
||||
@@ -1076,16 +1107,17 @@ const onOpenFile = (record: FamilyDmsFileViewDisplayData) => {
|
||||
} else if (fileTypePolicy.isAudio(record.OrgFileName)) {
|
||||
onPlayAudio(toUploadView(record));
|
||||
} else {
|
||||
onDownloadFile(record.FileId, record.OrgFileName);
|
||||
onDownloadFile(record);
|
||||
}
|
||||
};
|
||||
|
||||
const onDownloadSelected = (items: FamilyDmsFileViewDisplayData[]) => {
|
||||
items.forEach((item) => {
|
||||
const onDownloadSelected = async (items: FamilyDmsFileViewDisplayData[]) => {
|
||||
// 逐个串行下载:并发触发多个 <a download> 浏览器会拦截后面的
|
||||
for (const item of items) {
|
||||
if (item.IsDirectoryIndc != "Y") {
|
||||
onDownloadFile(item.FileId, item.OrgFileName);
|
||||
await onDownloadFile(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onShareSelected = (items: FamilyDmsFileViewDisplayData[]) => {
|
||||
@@ -1137,13 +1169,9 @@ const onViewPreviewSelected = (items: FamilyDmsFileViewDisplayData[]) => {
|
||||
};
|
||||
|
||||
/** 播放视频:把当前目录的视频串成播放列表,从点中的那一个开始 */
|
||||
const onUrlVideoPlayItem = async (record: FamilyDmsFileViewDisplayData) => {
|
||||
if (!record.Url) {
|
||||
await onSourceVideoPlay(record);
|
||||
return;
|
||||
}
|
||||
const onUrlVideoPlayItem = (record: FamilyDmsFileViewDisplayData) => {
|
||||
const list = buildVideoList(datas.value);
|
||||
let index = list.findIndex((x) => x.FormattedUrl === record.Url);
|
||||
let index = list.findIndex((x) => x.Url === record.Url);
|
||||
if (index < 0) {
|
||||
list.unshift(toVideoItem(record));
|
||||
index = 0;
|
||||
|
||||
@@ -36,6 +36,21 @@ onMounted(async () => {
|
||||
await loadVideos();
|
||||
});
|
||||
|
||||
/**
|
||||
* 发布专辑详情(FindPublishVideoDefault / FindByKey)里,Url 存的是
|
||||
* OrderKey(形如 xxxx-3-3.mp4 的文件名),不是可播放地址;
|
||||
* 真正的原码地址在 FormattedUrl 上(后端 3 参 PackUrl 现在固定返回原码)。
|
||||
* 这里把 Url 补成地址,否则播放器切「原码」时会拿文件名当地址请求、直接 404。
|
||||
* 网盘列表模式(mode=list)的 Url 本身就是完整地址,不受影响。
|
||||
*/
|
||||
const normalizeDetails = (details: PublishVideoDetailDisplayData[]) =>
|
||||
(details ?? []).map((d) => {
|
||||
if (d.Url && !/^(https?:)?\/\//i.test(d.Url)) {
|
||||
d.Url = d.FormattedUrl || "";
|
||||
}
|
||||
return d;
|
||||
});
|
||||
|
||||
const loadVideos = async () => {
|
||||
try {
|
||||
// 模式一:从网盘中心加载某个路径下的所有视频
|
||||
@@ -65,7 +80,9 @@ const loadVideos = async () => {
|
||||
for (const item of dr.Datas) {
|
||||
const detail = new PublishVideoDetailDisplayData();
|
||||
detail.Title = item.OrgFileName;
|
||||
detail.FormattedUrl = item.Url;
|
||||
detail.Url = item.Url; // 原码
|
||||
detail.FormattedM3u8 = item.FormattedM3u8; // 转码(10秒)
|
||||
detail.FormattedUrl = item.FormattedM3u8 || item.Url;
|
||||
// m3u8 通常配套同名 jpg/png 封面,这里把后缀替换成 .png 兜底
|
||||
detail.FormattedPic = (item.FormattedPic || "").replace(/\.m3u8$/, ".png");
|
||||
videos.value.push(detail);
|
||||
@@ -75,12 +92,12 @@ const loadVideos = async () => {
|
||||
// 默认发布视频
|
||||
else if (!publishName.value || publishName.value.length === 0) {
|
||||
const data: PublishVideoData = await publishVideoService.FindPublishVideoDefault();
|
||||
videos.value = data?.Details ?? [];
|
||||
videos.value = normalizeDetails(data?.Details ?? []);
|
||||
}
|
||||
// 按 key 加载
|
||||
else {
|
||||
const data: PublishVideoData = await publishVideoService.FindByKey(publishName.value);
|
||||
videos.value = data?.Details ?? [];
|
||||
videos.value = normalizeDetails(data?.Details ?? []);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
Reference in new issue
Block a user