mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 12:10:17 +09:00
fix avatar for export message preview and saved image
This commit is contained in:
parent
a029b4330b
commit
9f91c2d05c
@ -23,7 +23,6 @@ import CopyIcon from "../icons/copy.svg";
|
|||||||
import LoadingIcon from "../icons/three-dots.svg";
|
import LoadingIcon from "../icons/three-dots.svg";
|
||||||
import ChatGptIcon from "../icons/chatgpt.png";
|
import ChatGptIcon from "../icons/chatgpt.png";
|
||||||
import ShareIcon from "../icons/share.svg";
|
import ShareIcon from "../icons/share.svg";
|
||||||
import BotIcon from "../icons/bot.png";
|
|
||||||
|
|
||||||
import DownloadIcon from "../icons/download.svg";
|
import DownloadIcon from "../icons/download.svg";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
@ -33,13 +32,13 @@ import dynamic from "next/dynamic";
|
|||||||
import NextImage from "next/image";
|
import NextImage from "next/image";
|
||||||
|
|
||||||
import { toBlob, toPng } from "html-to-image";
|
import { toBlob, toPng } from "html-to-image";
|
||||||
import { DEFAULT_MASK_AVATAR } from "../store/mask";
|
|
||||||
|
|
||||||
import { prettyObject } from "../utils/format";
|
import { prettyObject } from "../utils/format";
|
||||||
import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
|
import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
|
||||||
import { getClientConfig } from "../config/client";
|
import { getClientConfig } from "../config/client";
|
||||||
import { type ClientApi, getClientApi } from "../client/api";
|
import { type ClientApi, getClientApi } from "../client/api";
|
||||||
import { getMessageTextContent } from "../utils";
|
import { getMessageTextContent } from "../utils";
|
||||||
|
import { MaskAvatar } from "./mask";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
||||||
@ -407,22 +406,6 @@ export function PreviewActions(props: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExportAvatar(props: { avatar: string }) {
|
|
||||||
if (props.avatar === DEFAULT_MASK_AVATAR) {
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
src={BotIcon.src}
|
|
||||||
width={30}
|
|
||||||
height={30}
|
|
||||||
alt="bot"
|
|
||||||
className="user-avatar"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Avatar avatar={props.avatar} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ImagePreviewer(props: {
|
export function ImagePreviewer(props: {
|
||||||
messages: ChatMessage[];
|
messages: ChatMessage[];
|
||||||
topic: string;
|
topic: string;
|
||||||
@ -546,9 +529,12 @@ export function ImagePreviewer(props: {
|
|||||||
github.com/ChatGPTNextWeb/ChatGPT-Next-Web
|
github.com/ChatGPTNextWeb/ChatGPT-Next-Web
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["icons"]}>
|
<div className={styles["icons"]}>
|
||||||
<ExportAvatar avatar={config.avatar} />
|
<MaskAvatar avatar={config.avatar} />
|
||||||
<span className={styles["icon-space"]}>&</span>
|
<span className={styles["icon-space"]}>&</span>
|
||||||
<ExportAvatar avatar={mask.avatar} />
|
<MaskAvatar
|
||||||
|
avatar={mask.avatar}
|
||||||
|
model={session.mask.modelConfig.model}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -576,9 +562,14 @@ export function ImagePreviewer(props: {
|
|||||||
key={i}
|
key={i}
|
||||||
>
|
>
|
||||||
<div className={styles["avatar"]}>
|
<div className={styles["avatar"]}>
|
||||||
<ExportAvatar
|
{m.role === "user" ? (
|
||||||
avatar={m.role === "user" ? config.avatar : mask.avatar}
|
<Avatar avatar={config.avatar}></Avatar>
|
||||||
|
) : (
|
||||||
|
<MaskAvatar
|
||||||
|
avatar={session.mask.avatar}
|
||||||
|
model={m.model || session.mask.modelConfig.model}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles["body"]}>
|
<div className={styles["body"]}>
|
||||||
|
Loading…
Reference in New Issue
Block a user