|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { getResourceUrl } from "@/utils/resource";
|
|
|
|
|
import { getResourceType, getResourceUrl } from "@/utils/resource";
|
|
|
|
|
import Icon from "./Icon";
|
|
|
|
|
import SquareDiv from "./kit/SquareDiv";
|
|
|
|
|
import showPreviewImageDialog from "./PreviewImageDialog";
|
|
|
|
@ -9,32 +9,6 @@ interface ResourceCoverProps {
|
|
|
|
|
resource: Resource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getResourceType = (resource: Resource) => {
|
|
|
|
|
if (resource.type.startsWith("image")) {
|
|
|
|
|
return "image/*";
|
|
|
|
|
} else if (resource.type.startsWith("video")) {
|
|
|
|
|
return "video/*";
|
|
|
|
|
} else if (resource.type.startsWith("audio")) {
|
|
|
|
|
return "audio/*";
|
|
|
|
|
} else if (resource.type.startsWith("text")) {
|
|
|
|
|
return "text/*";
|
|
|
|
|
} else if (resource.type.startsWith("application/epub+zip")) {
|
|
|
|
|
return "application/epub+zip";
|
|
|
|
|
} else if (resource.type.startsWith("application/pdf")) {
|
|
|
|
|
return "application/pdf";
|
|
|
|
|
} else if (resource.type.includes("word")) {
|
|
|
|
|
return "application/msword";
|
|
|
|
|
} else if (resource.type.includes("excel")) {
|
|
|
|
|
return "application/msexcel";
|
|
|
|
|
} else if (resource.type.startsWith("application/zip")) {
|
|
|
|
|
return "application/zip";
|
|
|
|
|
} else if (resource.type.startsWith("application/x-java-archive")) {
|
|
|
|
|
return "application/x-java-archive";
|
|
|
|
|
} else {
|
|
|
|
|
return "application/octet-stream";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ResourceCover = ({ resource }: ResourceCoverProps) => {
|
|
|
|
|
const resourceType = getResourceType(resource);
|
|
|
|
|
const resourceUrl = getResourceUrl(resource);
|
|
|
|
|