Merge pull request #2706 from kfear1337/bug

This commit is contained in:
Yifei Zhang 2023-08-26 19:58:46 +08:00 committed by GitHub
commit e009ea57b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -383,7 +383,7 @@ export function PreviewActions(props: {
function ExportAvatar(props: { avatar: string }) { function ExportAvatar(props: { avatar: string }) {
if (props.avatar === DEFAULT_MASK_AVATAR) { if (props.avatar === DEFAULT_MASK_AVATAR) {
return ( return (
<NextImage <img
src={BotIcon.src} src={BotIcon.src}
width={30} width={30}
height={30} height={30}
@ -393,7 +393,7 @@ function ExportAvatar(props: { avatar: string }) {
); );
} }
return <Avatar avatar={props.avatar}></Avatar>; return <Avatar avatar={props.avatar} />;
} }
export function ImagePreviewer(props: { export function ImagePreviewer(props: {
@ -422,6 +422,7 @@ export function ImagePreviewer(props: {
]) ])
.then(() => { .then(() => {
showToast(Locale.Copy.Success); showToast(Locale.Copy.Success);
refreshPreview();
}); });
} catch (e) { } catch (e) {
console.error("[Copy Image] ", e); console.error("[Copy Image] ", e);
@ -447,11 +448,19 @@ export function ImagePreviewer(props: {
link.download = `${props.topic}.png`; link.download = `${props.topic}.png`;
link.href = blob; link.href = blob;
link.click(); link.click();
refreshPreview();
} }
}) })
.catch((e) => console.log("[Export Image] ", e)); .catch((e) => console.log("[Export Image] ", e));
}; };
const refreshPreview = () => {
const dom = previewRef.current;
if (dom) {
dom.innerHTML = dom.innerHTML; // Refresh the content of the preview by resetting its HTML for fix a bug glitching
}
};
return ( return (
<div className={styles["image-previewer"]}> <div className={styles["image-previewer"]}>
<PreviewActions <PreviewActions