owe
This commit is contained in:
1 parent
9b9f07dea5
commit
2e1974c35d
15 files changed
+406
-169
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user