mirror of https://github.com/usememos/memos
feat: support audio player (#948)
parent
aacaf3f37c
commit
4cfd000b92
@ -0,0 +1,36 @@
|
||||
import Icon from "./Icon";
|
||||
|
||||
interface Props {
|
||||
resource: Resource;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const MemoResource: React.FC<Props> = (props: Props) => {
|
||||
const { className, resource } = props;
|
||||
const resourceUrl = `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
|
||||
|
||||
const handlePreviewBtnClick = () => {
|
||||
window.open(resourceUrl);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`w-auto flex flex-row justify-start items-center ${className}`}>
|
||||
{resource.type.startsWith("audio") ? (
|
||||
<>
|
||||
<audio className="h-8" src={resourceUrl} controls></audio>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Icon.FileText className="w-4 h-auto mr-1 text-gray-500" />
|
||||
<span className="text-gray-500 text-sm max-w-xs truncate font-mono cursor-pointer" onClick={handlePreviewBtnClick}>
|
||||
{resource.filename}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MemoResource;
|
Loading…
Reference in New Issue