feat: view all images of a memo (#393)

* feat: view all images of a memo

* fix: function arguments

* refactor: unified image preview

* refactor: image preview for resource dialog

Co-authored-by: XQ <qiaobingxue1998@163.com>
This commit is contained in:
Zhou Yunliang
2022-11-02 20:00:28 +08:00
committed by GitHub
parent bebcabc292
commit 91a61e058a
6 changed files with 47 additions and 125 deletions

View File

@ -83,10 +83,17 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
inputEl.click();
};
const getResouceUrl = useCallback((resource: Resource) => {
return `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
}, []);
const handlePreviewBtnClick = (resource: Resource) => {
const resourceUrl = `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
const resourceUrl = getResouceUrl(resource);
if (resource.type.startsWith("image")) {
showPreviewImageDialog(resourceUrl);
showPreviewImageDialog(
resources.filter((r) => r.type.startsWith("image")).map((r) => getResouceUrl(r)),
resources.findIndex((r) => r.id === resource.id)
);
} else {
window.open(resourceUrl);
}