From b52e237044bdc0ddf0427dfb363486da10810973 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 12 Nov 2023 19:33:19 +0800 Subject: [PATCH] fix: #3189 should correct math eq in exporter --- app/components/chat-list.tsx | 5 ++++- app/components/chat.tsx | 7 ++++++- app/components/exporter.module.scss | 3 ++- app/components/exporter.tsx | 7 +++---- app/components/markdown.tsx | 2 +- app/components/mask.tsx | 18 +++++++++++------- app/components/message-selector.tsx | 5 ++++- app/components/new-chat.tsx | 16 ++++------------ app/constant.ts | 3 +++ app/locales/cn.ts | 4 ++-- 10 files changed, 40 insertions(+), 30 deletions(-) diff --git a/app/components/chat-list.tsx b/app/components/chat-list.tsx index f76b369f1..33967717d 100644 --- a/app/components/chat-list.tsx +++ b/app/components/chat-list.tsx @@ -61,7 +61,10 @@ export function ChatItem(props: { {props.narrow ? (
- +
{props.count} diff --git a/app/components/chat.tsx b/app/components/chat.tsx index a088483e7..4d9de7259 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1176,7 +1176,12 @@ function _Chat() { {["system"].includes(message.role) ? ( ) : ( - + )} )} diff --git a/app/components/exporter.module.scss b/app/components/exporter.module.scss index c2046ffc0..d3bfc81ad 100644 --- a/app/components/exporter.module.scss +++ b/app/components/exporter.module.scss @@ -186,7 +186,8 @@ box-shadow: var(--card-shadow); border: var(--border-in-light); - *:not(li) { + code, + pre { overflow: hidden; } } diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx index 435e24953..185cbb20b 100644 --- a/app/components/exporter.tsx +++ b/app/components/exporter.tsx @@ -1,5 +1,5 @@ /* eslint-disable @next/next/no-img-element */ -import { ChatMessage, useAppConfig, useChatStore } from "../store"; +import { ChatMessage, ModelType, useAppConfig, useChatStore } from "../store"; import Locale from "../locales"; import styles from "./exporter.module.scss"; import { @@ -275,7 +275,8 @@ export function RenderExport(props: { }); props.onRender(renderMsgs); - }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return (
@@ -619,8 +620,6 @@ export function MarkdownPreviewer(props: { ); } -// modified by BackTrackZ now it's looks better - export function JsonPreviewer(props: { messages: ChatMessage[]; topic: string; diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 1a1fbf416..b4cae9a21 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -11,7 +11,7 @@ import mermaid from "mermaid"; import LoadingIcon from "../icons/three-dots.svg"; import React from "react"; -import { useDebouncedCallback, useThrottledCallback } from "use-debounce"; +import { useDebouncedCallback } from "use-debounce"; import { showImageModal } from "./ui-lib"; export function Mermaid(props: { code: string }) { diff --git a/app/components/mask.tsx b/app/components/mask.tsx index 9fe1d485a..3f616c3ac 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -18,6 +18,7 @@ import { ChatMessage, createMessage, ModelConfig, + ModelType, useAppConfig, useChatStore, } from "../store"; @@ -58,11 +59,11 @@ function reorder(list: T[], startIndex: number, endIndex: number): T[] { return result; } -export function MaskAvatar(props: { mask: Mask }) { - return props.mask.avatar !== DEFAULT_MASK_AVATAR ? ( - +export function MaskAvatar(props: { avatar: string; model?: ModelType }) { + return props.avatar !== DEFAULT_MASK_AVATAR ? ( + ) : ( - + ); } @@ -123,7 +124,10 @@ export function MaskConfig(props: { onClick={() => setShowPicker(true)} style={{ cursor: "pointer" }} > - +
@@ -398,7 +402,7 @@ export function MaskPage() { setSearchText(text); if (text.length > 0) { const result = allMasks.filter((m) => - m.name.toLowerCase().includes(text.toLowerCase()) + m.name.toLowerCase().includes(text.toLowerCase()), ); setSearchMasks(result); } else { @@ -523,7 +527,7 @@ export function MaskPage() {
- +
{m.name}
diff --git a/app/components/message-selector.tsx b/app/components/message-selector.tsx index 3d2321d09..c20153401 100644 --- a/app/components/message-selector.tsx +++ b/app/components/message-selector.tsx @@ -208,7 +208,10 @@ export function MessageSelector(props: { {m.role === "user" ? ( ) : ( - + )}
diff --git a/app/components/new-chat.tsx b/app/components/new-chat.tsx index 76cbbeeb1..54c646f23 100644 --- a/app/components/new-chat.tsx +++ b/app/components/new-chat.tsx @@ -17,21 +17,13 @@ import { useCommand } from "../command"; import { showConfirm } from "./ui-lib"; import { BUILTIN_MASK_STORE } from "../masks"; -function getIntersectionArea(aRect: DOMRect, bRect: DOMRect) { - const xmin = Math.max(aRect.x, bRect.x); - const xmax = Math.min(aRect.x + aRect.width, bRect.x + bRect.width); - const ymin = Math.max(aRect.y, bRect.y); - const ymax = Math.min(aRect.y + aRect.height, bRect.y + bRect.height); - const width = xmax - xmin; - const height = ymax - ymin; - const intersectionArea = width < 0 || height < 0 ? 0 : width * height; - return intersectionArea; -} - function MaskItem(props: { mask: Mask; onClick?: () => void }) { return (
- +
{props.mask.name}
); diff --git a/app/constant.ts b/app/constant.ts index 561899769..779c6f7e7 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -84,6 +84,9 @@ You are ChatGPT, a large language model trained by OpenAI. Knowledge cutoff: {{cutoff}} Current model: {{model}} Current time: {{time}} + +Latex inline: $x^2$ +Latex block: $$e=mc^2$$ `; export const SUMMARIZE_MODEL = "gpt-3.5-turbo"; diff --git a/app/locales/cn.ts b/app/locales/cn.ts index e721adef7..f5b65559f 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -85,8 +85,8 @@ const cn = { Copy: "全部复制", Download: "下载文件", Share: "分享到 ShareGPT", - MessageFromYou: "来自你的消息", - MessageFromChatGPT: "来自 ChatGPT 的消息", + MessageFromYou: "用户", + MessageFromChatGPT: "ChatGPT", Format: { Title: "导出格式", SubTitle: "可以导出 Markdown 文本或者 PNG 图片",