Skip to content

Commit b44686b

Browse files
authored
Merge pull request #6189 from bestsanmao/bug_fix
fix avatar for export message preview and saved image
2 parents 34bdd4b + 9f91c2d commit b44686b

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

app/components/exporter.tsx

+14-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import CopyIcon from "../icons/copy.svg";
2323
import LoadingIcon from "../icons/three-dots.svg";
2424
import ChatGptIcon from "../icons/chatgpt.png";
2525
import ShareIcon from "../icons/share.svg";
26-
import BotIcon from "../icons/bot.png";
2726

2827
import DownloadIcon from "../icons/download.svg";
2928
import { useEffect, useMemo, useRef, useState } from "react";
@@ -33,13 +32,13 @@ import dynamic from "next/dynamic";
3332
import NextImage from "next/image";
3433

3534
import { toBlob, toPng } from "html-to-image";
36-
import { DEFAULT_MASK_AVATAR } from "../store/mask";
3735

3836
import { prettyObject } from "../utils/format";
3937
import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
4038
import { getClientConfig } from "../config/client";
4139
import { type ClientApi, getClientApi } from "../client/api";
4240
import { getMessageTextContent } from "../utils";
41+
import { MaskAvatar } from "./mask";
4342
import clsx from "clsx";
4443

4544
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
@@ -407,22 +406,6 @@ export function PreviewActions(props: {
407406
);
408407
}
409408

410-
function ExportAvatar(props: { avatar: string }) {
411-
if (props.avatar === DEFAULT_MASK_AVATAR) {
412-
return (
413-
<img
414-
src={BotIcon.src}
415-
width={30}
416-
height={30}
417-
alt="bot"
418-
className="user-avatar"
419-
/>
420-
);
421-
}
422-
423-
return <Avatar avatar={props.avatar} />;
424-
}
425-
426409
export function ImagePreviewer(props: {
427410
messages: ChatMessage[];
428411
topic: string;
@@ -546,9 +529,12 @@ export function ImagePreviewer(props: {
546529
github.com/ChatGPTNextWeb/ChatGPT-Next-Web
547530
</div>
548531
<div className={styles["icons"]}>
549-
<ExportAvatar avatar={config.avatar} />
532+
<MaskAvatar avatar={config.avatar} />
550533
<span className={styles["icon-space"]}>&</span>
551-
<ExportAvatar avatar={mask.avatar} />
534+
<MaskAvatar
535+
avatar={mask.avatar}
536+
model={session.mask.modelConfig.model}
537+
/>
552538
</div>
553539
</div>
554540
<div>
@@ -576,9 +562,14 @@ export function ImagePreviewer(props: {
576562
key={i}
577563
>
578564
<div className={styles["avatar"]}>
579-
<ExportAvatar
580-
avatar={m.role === "user" ? config.avatar : mask.avatar}
581-
/>
565+
{m.role === "user" ? (
566+
<Avatar avatar={config.avatar}></Avatar>
567+
) : (
568+
<MaskAvatar
569+
avatar={session.mask.avatar}
570+
model={m.model || session.mask.modelConfig.model}
571+
/>
572+
)}
582573
</div>
583574

584575
<div className={styles["body"]}>

0 commit comments

Comments
 (0)