fix: context menu click
This commit is contained in:
@@ -16,10 +16,8 @@ const ImagePreview = ({ context = "chat" }: Props) => {
|
||||
if (!container) return;
|
||||
const chatHandler = (evt: MouseEvent) => {
|
||||
const target = evt.target as HTMLImageElement;
|
||||
console.log({ target });
|
||||
|
||||
if (!target) return;
|
||||
if (target.nodeName == "IMG" && target.classList.contains("preview")) {
|
||||
if (target && target.nodeName == "IMG" && target.classList.contains("preview")) {
|
||||
evt.stopPropagation();
|
||||
const thumbnail = target.src;
|
||||
const originUrl = target.dataset.origin || target.src;
|
||||
const downloadLink = target.dataset.download || target.src;
|
||||
@@ -28,11 +26,10 @@ const ImagePreview = ({ context = "chat" }: Props) => {
|
||||
}
|
||||
};
|
||||
const markdownHandler = (evt: MouseEvent) => {
|
||||
evt.stopPropagation();
|
||||
const target = evt.target as HTMLImageElement;
|
||||
if (!target) return;
|
||||
// 图片 并且没被 a 标签包裹
|
||||
if (target.nodeName == "IMG" && target.parentElement?.tagName !== "A") {
|
||||
if (target && target.nodeName == "IMG" && target.parentElement?.tagName !== "A") {
|
||||
evt.stopPropagation();
|
||||
const urlObj = new URL(target.src);
|
||||
const originUrl = `${urlObj.origin}${urlObj.pathname}?file_path=${urlObj.searchParams.get(
|
||||
"file_path"
|
||||
|
||||
Reference in New Issue
Block a user