diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 7aa8bfec6..52307078d 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1,5 +1,5 @@ import { useDebouncedCallback } from "use-debounce"; -import { useState, useRef, useEffect, useLayoutEffect } from "react"; +import { memo, useState, useRef, useEffect, useLayoutEffect } from "react"; import SendWhiteIcon from "../icons/send-white.svg"; import BrainIcon from "../icons/brain.svg"; @@ -17,6 +17,7 @@ import { Message, SubmitKey, useChatStore, BOT_HELLO, ROLES } from "../store"; import { copyToClipboard, downloadAs, + getEmojiUrl, isMobileScreen, selectOrCopy, } from "../utils"; @@ -33,7 +34,7 @@ import chatStyle from "./chat.module.scss"; import { Modal, showModal, showToast } from "./ui-lib"; -const Markdown = dynamic(async () => (await import("./markdown")).Markdown, { +const Markdown = dynamic(async () => memo((await import("./markdown")).Markdown), { loading: () => , }); @@ -50,7 +51,7 @@ export function Avatar(props: { role: Message["role"] }) { return (
- +
); } @@ -60,7 +61,9 @@ function exportMessages(messages: Message[], topic: string) { `# ${topic}\n\n` + messages .map((m) => { - return m.role === "user" ? `## ${m.content}` : m.content.trim(); + return m.role === "user" + ? `## ${Locale.Export.MessageFromYou}:\n${m.content}` + : `## ${Locale.Export.MessageFromChatGPT}:\n${m.content.trim()}`; }) .join("\n\n"); const filename = `${topic}.md`; diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 9b25adfe3..0b1971a0e 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -26,7 +26,7 @@ import { import { Avatar } from "./chat"; import Locale, { AllLangs, changeLang, getLang } from "../locales"; -import { getCurrentVersion } from "../utils"; +import { getCurrentVersion, getEmojiUrl } from "../utils"; import Link from "next/link"; import { UPDATE_URL } from "../constant"; import { SearchService, usePromptStore } from "../store/prompt"; @@ -113,7 +113,6 @@ export function Settings(props: { closeSettings: () => void }) { useEffect(() => { checkUpdate(); - checkUsage(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -182,6 +181,7 @@ export function Settings(props: { closeSettings: () => void }) { { updateConfig((config) => (config.avatar = e.unified)); setShowEmojiPicker(false); @@ -417,7 +417,7 @@ export function Settings(props: { closeSettings: () => void }) { value={config.historyMessageCount} min="0" max="25" - step="2" + step="1" onChange={(e) => updateConfig( (config) => diff --git a/app/components/window.scss b/app/components/window.scss index d89c9eb10..a92aed4eb 100644 --- a/app/components/window.scss +++ b/app/components/window.scss @@ -10,6 +10,7 @@ .window-header-title { max-width: calc(100% - 100px); + overflow: hidden; .window-header-main-title { font-size: 20px; diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 8bca83634..b6c1efc28 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -33,6 +33,8 @@ const cn = { Title: "导出聊天记录为 Markdown", Copy: "全部复制", Download: "下载文件", + MessageFromYou: "来自你的消息", + MessageFromChatGPT: "来自 ChatGPT 的消息", }, Memory: { Title: "历史记忆", diff --git a/app/locales/en.ts b/app/locales/en.ts index ae8e88c2d..af8201503 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -35,6 +35,8 @@ const en: LocaleType = { Title: "All Messages", Copy: "Copy All", Download: "Download", + MessageFromYou: "Message From You", + MessageFromChatGPT: "Message From ChatGPT", }, Memory: { Title: "Memory Prompt", diff --git a/app/locales/es.ts b/app/locales/es.ts index f3714ef3b..5c73b608b 100644 --- a/app/locales/es.ts +++ b/app/locales/es.ts @@ -35,6 +35,8 @@ const es: LocaleType = { Title: "Todos los mensajes", Copy: "Copiar todo", Download: "Descargar", + MessageFromYou: "Mensaje de ti", + MessageFromChatGPT: "Mensaje de ChatGPT", }, Memory: { Title: "Historial de memoria", diff --git a/app/locales/it.ts b/app/locales/it.ts index c4736c1e0..ce87796d1 100644 --- a/app/locales/it.ts +++ b/app/locales/it.ts @@ -35,6 +35,8 @@ const it: LocaleType = { Title: "Tutti i messaggi", Copy: "Copia tutto", Download: "Scarica", + MessageFromYou: "Messaggio da te", + MessageFromChatGPT: "Messaggio da ChatGPT", }, Memory: { Title: "Prompt di memoria", diff --git a/app/locales/tw.ts b/app/locales/tw.ts index f27001971..eaab03fcd 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -34,6 +34,8 @@ const tw: LocaleType = { Title: "匯出聊天記錄為 Markdown", Copy: "複製全部", Download: "下載檔案", + MessageFromYou: "來自你的訊息", + MessageFromChatGPT: "來自 ChatGPT 的訊息", }, Memory: { Title: "上下文記憶 Prompt", diff --git a/app/utils.ts b/app/utils.ts index 5fe277c63..93f7561af 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -1,3 +1,4 @@ +import { EmojiStyle } from "emoji-picker-react"; import { showToast } from "./components/ui-lib"; import Locale from "./locales"; @@ -81,3 +82,7 @@ export function getCurrentVersion() { return currentId; } + +export function getEmojiUrl(unified: string, style: EmojiStyle) { + return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`; +}