chore: add dev guard for memo chat (#1968)

This commit is contained in:
boojack
2023-07-16 13:02:52 +08:00
committed by GitHub
parent 032509ddba
commit 220cba84ae
17 changed files with 284 additions and 163 deletions

View File

@ -1,18 +1,33 @@
import classNames from "classnames";
import { getResourceUrl } from "@/utils/resource";
import Icon from "./Icon";
import SquareDiv from "./kit/SquareDiv";
import showPreviewImageDialog from "./PreviewImageDialog";
interface Props {
className: string;
resourceType: string;
resource: Resource;
}
const ResourceIcon = (props: Props) => {
const { className, resourceType } = props;
const { className, resource } = props;
let ResourceIcon = Icon.FileText;
if (resourceType.includes("image")) {
ResourceIcon = Icon.Image;
if (resource.type.includes("image")) {
const url = getResourceUrl(resource);
return (
<SquareDiv key={resource.id} className={classNames("cursor-pointer rounded hover:shadow", className)}>
<img
className="min-h-full min-w-full w-auto h-auto rounded"
src={resource.externalLink ? url : url + "?thumbnail=1"}
onClick={() => showPreviewImageDialog([url], 0)}
decoding="async"
loading="lazy"
/>
</SquareDiv>
);
}
const ResourceIcon = Icon.FileText;
return <ResourceIcon className={className} />;
};