diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx
index 7765b77a..f26b3a7d 100644
--- a/app/components/exporter.tsx
+++ b/app/components/exporter.tsx
@@ -1,7 +1,8 @@
+/* eslint-disable @next/next/no-img-element */
import { ChatMessage, useAppConfig, useChatStore } from "../store";
import Locale from "../locales";
import styles from "./exporter.module.scss";
-import { List, ListItem, Modal, Select, showToast } from "./ui-lib";
+import { List, ListItem, Modal, Select, showModal, showToast } from "./ui-lib";
import { IconButton } from "./button";
import { copyToClipboard, downloadAs, useMobileScreen } from "../utils";
@@ -23,6 +24,7 @@ import { DEFAULT_MASK_AVATAR } from "../store/mask";
import { api } from "../client/api";
import { prettyObject } from "../utils/format";
import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
+import { getClientConfig } from "../config/client";
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => ,
@@ -357,6 +359,24 @@ function ExportAvatar(props: { avatar: string }) {
return ;
}
+export function showImageModal(img: string) {
+ showModal({
+ title: Locale.Export.Image.Modal,
+ children: (
+
+
+
+ ),
+ defaultMax: true,
+ });
+}
+
export function ImagePreviewer(props: {
messages: ChatMessage[];
topic: string;
@@ -369,6 +389,7 @@ export function ImagePreviewer(props: {
const previewRef = useRef(null);
const copy = () => {
+ showToast(Locale.Export.Image.Toast);
const dom = previewRef.current;
if (!dom) return;
toBlob(dom).then((blob) => {
@@ -393,17 +414,15 @@ export function ImagePreviewer(props: {
const isMobile = useMobileScreen();
const download = () => {
+ showToast(Locale.Export.Image.Toast);
const dom = previewRef.current;
if (!dom) return;
toPng(dom)
.then((blob) => {
if (!blob) return;
- if (isMobile) {
- const image = new Image();
- image.src = blob;
- const win = window.open("");
- win?.document.write(image.outerHTML);
+ if (isMobile || getClientConfig()?.isApp) {
+ showImageModal(blob);
} else {
const link = document.createElement("a");
link.download = `${props.topic}.png`;
diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx
index 5e6a50dc..da520bd8 100644
--- a/app/components/ui-lib.tsx
+++ b/app/components/ui-lib.tsx
@@ -95,6 +95,7 @@ interface ModalProps {
title: string;
children?: any;
actions?: JSX.Element[];
+ defaultMax?: boolean;
onClose?: () => void;
}
export function Modal(props: ModalProps) {
@@ -113,7 +114,7 @@ export function Modal(props: ModalProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- const [isMax, setMax] = useState(false);
+ const [isMax, setMax] = useState(!!props.defaultMax);
return (