From 420f8511a121dd1e3e5a13c03929de06a21394a6 Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Sat, 1 Apr 2023 17:57:17 +0800 Subject: [PATCH] feat: export as image --- app/components/home.module.scss | 1 + app/components/home.tsx | 49 ++++++++++++++++++++++++++++++++- app/icons/export-Image.svg | 1 + app/layout.tsx | 1 + app/locales/cn.ts | 4 +++ app/locales/en.ts | 4 +++ app/locales/es.ts | 12 ++++++-- app/locales/tw.ts | 4 +++ package.json | 3 +- yarn.lock | 5 ++++ 10 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 app/icons/export-Image.svg diff --git a/app/components/home.module.scss b/app/components/home.module.scss index 764805d80..15cae9080 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -218,6 +218,7 @@ flex: 1; overflow: auto; padding: 20px; + background-color: var(--white); } .chat-body-title { diff --git a/app/components/home.tsx b/app/components/home.tsx index 2f09aa273..14efeae9d 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -20,6 +20,7 @@ import MenuIcon from "../icons/menu.svg"; import CloseIcon from "../icons/close.svg"; import CopyIcon from "../icons/copy.svg"; import DownloadIcon from "../icons/download.svg"; +import ExportImage from "../icons/export-image.svg"; import { Message, SubmitKey, useChatStore, ChatSession } from "../store"; import { showModal, showToast } from "./ui-lib"; @@ -36,6 +37,7 @@ import dynamic from "next/dynamic"; import { REPO_URL } from "../constant"; import { ControllerPool } from "../requests"; import { Prompt, usePromptStore } from "../store/prompt"; +import { toPng } from "html-to-image"; export function Loading(props: { noLogo?: boolean }) { return ( @@ -341,6 +343,9 @@ export function Chat(props: { }, 500); }); + //export image + const [exportImageLoading, setExportImageLoading] = useState(false); + return (