From fb327704866231748827d4b580851e18b797f49a Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Fri, 28 Apr 2023 00:34:37 +0800 Subject: [PATCH] feat: i18n refactor and style adjustment --- app/components/button.module.scss | 9 +++++ app/components/button.tsx | 7 ++-- app/components/chat-list.tsx | 6 ++- app/components/chat.tsx | 19 +++++----- app/components/error.tsx | 28 ++++++-------- app/components/home.module.scss | 2 +- app/components/new-chat.module.scss | 10 ++++- app/components/new-chat.tsx | 50 +++++++++++++++++++------ app/components/settings.tsx | 57 ++++++++++++++--------------- app/components/sidebar.tsx | 14 +++++-- app/icons/black-bot.svg | 2 +- app/icons/delete.svg | 4 +- app/icons/lightning.svg | 1 + app/locales/cn.ts | 29 ++++++++++----- app/locales/de.ts | 26 ++++++++----- app/locales/en.ts | 24 ++++++++---- app/locales/es.ts | 25 ++++++++----- app/locales/it.ts | 25 ++++++++----- app/locales/jp.ts | 23 +++++++----- app/locales/tr.ts | 25 ++++++++----- app/locales/tw.ts | 22 +++++++---- app/store/chat.ts | 11 +++--- app/store/config.ts | 3 ++ 23 files changed, 266 insertions(+), 156 deletions(-) create mode 100644 app/icons/lightning.svg diff --git a/app/components/button.module.scss b/app/components/button.module.scss index 3a3393e..5aa53dc 100644 --- a/app/components/button.module.scss +++ b/app/components/button.module.scss @@ -18,6 +18,15 @@ cursor: not-allowed; opacity: 0.5; } + + &.primary { + background-color: var(--primary); + color: white; + + path { + fill: white !important; + } + } } .shadow { diff --git a/app/components/button.tsx b/app/components/button.tsx index 3a2cb8a..f93741b 100644 --- a/app/components/button.tsx +++ b/app/components/button.tsx @@ -5,10 +5,10 @@ import styles from "./button.module.scss"; export function IconButton(props: { onClick?: () => void; icon?: JSX.Element; + type?: "primary" | "danger"; text?: string; bordered?: boolean; shadow?: boolean; - noDark?: boolean; className?: string; title?: string; disabled?: boolean; @@ -19,7 +19,7 @@ export function IconButton(props: { styles["icon-button"] + ` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${ props.className ?? "" - } clickable` + } clickable ${styles[props.type ?? ""]}` } onClick={props.onClick} title={props.title} @@ -29,7 +29,8 @@ export function IconButton(props: { {props.icon && (
{props.icon} diff --git a/app/components/chat-list.tsx b/app/components/chat-list.tsx index c4f5b95..2c7b95a 100644 --- a/app/components/chat-list.tsx +++ b/app/components/chat-list.tsx @@ -14,6 +14,8 @@ import { useChatStore } from "../store"; import Locale from "../locales"; import { Link, useNavigate } from "react-router-dom"; import { Path } from "../constant"; +import { MaskAvatar } from "./mask"; +import { Mask } from "../store/mask"; export function ChatItem(props: { onClick?: () => void; @@ -25,6 +27,7 @@ export function ChatItem(props: { id: number; index: number; narrow?: boolean; + mask: Mask; }) { return ( @@ -44,7 +47,7 @@ export function ChatItem(props: { {props.narrow ? (
- +
{props.count} @@ -129,6 +132,7 @@ export function ChatList(props: { narrow?: boolean }) { } }} narrow={props.narrow} + mask={item.mask} /> ))} {provided.placeholder} diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 0cca7d7..7929bf9 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -53,13 +53,16 @@ import { IconButton } from "./button"; import styles from "./home.module.scss"; import chatStyle from "./chat.module.scss"; -import { Input, List, ListItem, Modal, Popover, showModal } from "./ui-lib"; +import { ListItem, Modal, showModal } from "./ui-lib"; import { useNavigate } from "react-router-dom"; import { Path } from "../constant"; -import { ModelConfigList } from "./model-config"; -import { Avatar, AvatarPicker } from "./emoji"; -import { MaskConfig } from "./mask"; -import { DEFAULT_MASK_ID, useMaskStore } from "../store/mask"; +import { Avatar } from "./emoji"; +import { MaskAvatar, MaskConfig } from "./mask"; +import { + DEFAULT_MASK_AVATAR, + DEFAULT_MASK_ID, + useMaskStore, +} from "../store/mask"; const Markdown = dynamic( async () => memo((await import("./markdown")).Markdown), @@ -668,10 +671,8 @@ export function Chat() {
{message.role === "user" ? ( - ) : session.mask.id === DEFAULT_MASK_ID ? ( - ) : ( - + )}
{showTyping && ( @@ -778,7 +779,7 @@ export function Chat() { icon={} text={Locale.Chat.Send} className={styles["chat-input-send"]} - noDark + type="primary" onClick={onUserSubmit} />
diff --git a/app/components/error.tsx b/app/components/error.tsx index 1e30e6b..0e01c41 100644 --- a/app/components/error.tsx +++ b/app/components/error.tsx @@ -2,7 +2,7 @@ import React from "react"; import { IconButton } from "./button"; import GithubIcon from "../icons/github.svg"; import ResetIcon from "../icons/reload.svg"; -import { ISSUE_URL, StoreKey } from "../constant"; +import { ISSUE_URL } from "../constant"; import Locale from "../locales"; import { downloadAs } from "../utils"; @@ -24,22 +24,15 @@ export class ErrorBoundary extends React.Component { } clearAndSaveData() { - const snapshot: Record = {}; - Object.values(StoreKey).forEach((key) => { - snapshot[key] = localStorage.getItem(key); - - if (snapshot[key]) { - try { - snapshot[key] = JSON.parse(snapshot[key]); - } catch {} - } - }); - try { - downloadAs(JSON.stringify(snapshot), "chatgpt-next-web-snapshot.json"); - } catch {} - - localStorage.clear(); + downloadAs( + JSON.stringify(localStorage), + "chatgpt-next-web-snapshot.json", + ); + } finally { + localStorage.clear(); + location.reload(); + } } render() { @@ -65,7 +58,8 @@ export class ErrorBoundary extends React.Component { icon={} text="Clear All Data" onClick={() => - confirm(Locale.Store.ConfirmClearAll) && this.clearAndSaveData() + confirm(Locale.Settings.Actions.ConfirmClearAll) && + this.clearAndSaveData() } bordered /> diff --git a/app/components/home.module.scss b/app/components/home.module.scss index 7805f6a..e8d0dba 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -269,7 +269,7 @@ .chat-item-avatar { display: flex; justify-content: center; - opacity: 0.1; + opacity: 0.2; position: absolute; transform: scale(4); } diff --git a/app/components/new-chat.module.scss b/app/components/new-chat.module.scss index 708716a..36f447b 100644 --- a/app/components/new-chat.module.scss +++ b/app/components/new-chat.module.scss @@ -52,10 +52,18 @@ animation: slide-in ease 0.4s; } - .search-bar { + .actions { margin-top: 5vh; margin-bottom: 5vh; animation: slide-in ease 0.45s; + display: flex; + justify-content: center; + + .search-bar { + font-size: 12px; + margin-right: 10px; + width: 40vw; + } } .masks { diff --git a/app/components/new-chat.tsx b/app/components/new-chat.tsx index 0a08cdd..8cb4d35 100644 --- a/app/components/new-chat.tsx +++ b/app/components/new-chat.tsx @@ -3,11 +3,14 @@ import { Path, SlotID } from "../constant"; import { IconButton } from "./button"; import { EmojiAvatar } from "./emoji"; import styles from "./new-chat.module.scss"; + import LeftIcon from "../icons/left.svg"; -import { useNavigate } from "react-router-dom"; +import AddIcon from "../icons/lightning.svg"; + +import { useLocation, useNavigate } from "react-router-dom"; import { createEmptyMask, Mask, useMaskStore } from "../store/mask"; import Locale from "../locales"; -import { useChatStore } from "../store"; +import { useAppConfig, useChatStore } from "../store"; import { MaskAvatar } from "./mask"; function getIntersectionArea(aRect: DOMRect, bRect: DOMRect) { @@ -93,10 +96,14 @@ function useMaskGroup(masks: Mask[]) { export function NewChat() { const chatStore = useChatStore(); const maskStore = useMaskStore(); + const masks = maskStore.getAll(); const groups = useMaskGroup(masks); const navigate = useNavigate(); + const config = useAppConfig(); + + const { state } = useLocation(); const startChat = (mask?: Mask) => { chatStore.newSession(mask); @@ -111,10 +118,19 @@ export function NewChat() { text={Locale.NewChat.Return} onClick={() => navigate(Path.Home)} > - startChat()} - > + {!state?.fromHome && ( + { + if (confirm(Locale.NewChat.ConfirmNoShow)) { + startChat(); + config.update( + (config) => (config.dontShowMaskSplashScreen = true), + ); + } + }} + > + )}
@@ -131,12 +147,22 @@ export function NewChat() {
{Locale.NewChat.Title}
{Locale.NewChat.SubTitle}
- navigate(Path.Masks)} - /> +
+ navigate(Path.Masks)} + /> + + startChat()} + icon={} + type="primary" + shadow + /> +
{groups.map((masks, i) => ( diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 83aec5a..385fc32 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -137,10 +137,7 @@ export function Settings() { const config = useAppConfig(); const updateConfig = config.update; const resetConfig = config.reset; - const [clearAllData, clearSessions] = useChatStore((state) => [ - state.clearAllData, - state.clearSessions, - ]); + const chatStore = useChatStore(); const updateStore = useUpdateStore(); const [checkingUpdate, setCheckingUpdate] = useState(false); @@ -160,9 +157,9 @@ export function Settings() { subscription: updateStore.subscription, }; const [loadingUsage, setLoadingUsage] = useState(false); - function checkUsage() { + function checkUsage(force = false) { setLoadingUsage(true); - updateStore.updateUsage().finally(() => { + updateStore.updateUsage(force).finally(() => { setLoadingUsage(false); }); } @@ -216,11 +213,8 @@ export function Settings() { } onClick={() => { - const confirmed = window.confirm( - `${Locale.Settings.Actions.ConfirmClearAll.Confirm}`, - ); - if (confirmed) { - clearSessions(); + if (confirm(Locale.Settings.Actions.ConfirmClearAll)) { + chatStore.clearAllData(); } }} bordered @@ -231,10 +225,7 @@ export function Settings() { } onClick={() => { - const confirmed = window.confirm( - `${Locale.Settings.Actions.ConfirmResetAll.Confirm}`, - ); - if (confirmed) { + if (confirm(Locale.Settings.Actions.ConfirmResetAll)) { resetConfig(); } }} @@ -370,19 +361,10 @@ export function Settings() { > - - - updateConfig( - (config) => (config.tightBorder = e.currentTarget.checked), - ) - } - > - - - + + + + + updateConfig( + (config) => + (config.dontShowMaskSplashScreen = + !e.currentTarget.checked), + ) + } + > + @@ -448,7 +447,7 @@ export function Settings() { } text={Locale.Settings.Usage.Check} - onClick={checkUsage} + onClick={() => checkUsage(true)} /> )} diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 4ba3723..47a3117 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -87,6 +87,8 @@ export function SideBar(props: { className?: string }) { const { onDragMouseDown, shouldNarrow } = useDragSideBar(); const navigate = useNavigate(); + const config = useAppConfig(); + return (
} - text="Mask" + text={shouldNarrow ? undefined : Locale.Mask.Name} className={styles["sidebar-bar-button"]} - onClick={() => navigate(Path.Masks)} + onClick={() => navigate(Path.NewChat, { state: { fromHome: true } })} shadow /> } - text="Plugins" + text={shouldNarrow ? undefined : Locale.Plugin.Name} className={styles["sidebar-bar-button"]} onClick={() => showToast(Locale.WIP)} shadow @@ -155,7 +157,11 @@ export function SideBar(props: { className?: string }) { icon={} text={shouldNarrow ? undefined : Locale.Home.NewChat} onClick={() => { - navigate(Path.NewChat); + if (config.dontShowMaskSplashScreen) { + chatStore.newSession(); + } else { + navigate(Path.NewChat); + } }} shadow /> diff --git a/app/icons/black-bot.svg b/app/icons/black-bot.svg index 3aad2ad..5c253fb 100644 --- a/app/icons/black-bot.svg +++ b/app/icons/black-bot.svg @@ -18,7 +18,7 @@ - diff --git a/app/icons/delete.svg b/app/icons/delete.svg index 49ab97b..b28095b 100644 --- a/app/icons/delete.svg +++ b/app/icons/delete.svg @@ -7,6 +7,6 @@ fill-rule="evenodd" fill="#D8D8D8" fill-opacity="0.009999999776482582" /> + fill="#333333" fill-opacity="1" /> - \ No newline at end of file + diff --git a/app/icons/lightning.svg b/app/icons/lightning.svg new file mode 100644 index 0000000..d208ad8 --- /dev/null +++ b/app/icons/lightning.svg @@ -0,0 +1 @@ + diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 6c581f3..208752c 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -45,7 +45,7 @@ const cn = { Memory: { Title: "历史摘要", EmptyContent: "对话内容过短,无需总结", - Send: "启用总结并发送摘要", + Send: "自动压缩聊天记录并作为上下文发送", Copy: "复制摘要", Reset: "重置对话", ResetConfirm: "重置后将清空当前对话记录以及历史摘要,确认重置?", @@ -63,12 +63,8 @@ const cn = { ClearAll: "清除所有数据", ResetAll: "重置所有选项", Close: "关闭", - ConfirmResetAll: { - Confirm: "确认清除所有配置?", - }, - ConfirmClearAll: { - Confirm: "确认清除所有聊天记录?", - }, + ConfirmResetAll: "确认重置所有配置?", + ConfirmClearAll: "确认清除所有数据?", }, Lang: { Name: "Language", @@ -101,7 +97,14 @@ const cn = { SendKey: "发送键", Theme: "主题", TightBorder: "无边框模式", - SendPreviewBubble: "发送预览气泡", + SendPreviewBubble: { + Title: "预览气泡", + SubTitle: "在预览气泡中预览 Markdown 内容", + }, + Mask: { + Title: "面具启动页", + SubTitle: "新建聊天时,展示面具启动页", + }, Prompt: { Disable: { Title: "禁用提示词自动补全", @@ -130,6 +133,7 @@ const cn = { SubTitle: "使用自己的 Key 可绕过密码访问限制", Placeholder: "OpenAI API Key", }, + Usage: { Title: "余额查询", SubTitle(used: any, total: any) { @@ -170,7 +174,6 @@ const cn = { Summarize: "简要总结一下你和用户的对话,用作后续的上下文提示 prompt,控制在 200 字以内", }, - ConfirmClearAll: "确认清除所有聊天、设置数据?", }, Copy: { Success: "已写入剪切板", @@ -181,7 +184,11 @@ const cn = { Edit: "当前对话设置", Add: "新增预设对话", }, + Plugin: { + Name: "插件", + }, Mask: { + Name: "面具", Page: { Title: "预设角色面具", SubTitle: (count: number) => `${count} 个预设角色定义`, @@ -209,7 +216,9 @@ const cn = { }, NewChat: { Return: "返回", - Skip: "跳过", + Skip: "直接开始", + NotShow: "不再展示", + ConfirmNoShow: "确认禁用?禁用后可以随时在设置中重新启用。", Title: "挑选一个面具", SubTitle: "现在开始,与面具背后的灵魂思维碰撞", More: "搜索更多", diff --git a/app/locales/de.ts b/app/locales/de.ts index 6cc2a86..1981944 100644 --- a/app/locales/de.ts +++ b/app/locales/de.ts @@ -65,12 +65,9 @@ const de: LocaleType = { ClearAll: "Alle Daten löschen", ResetAll: "Alle Einstellungen zurücksetzen", Close: "Schließen", - ConfirmResetAll: { - Confirm: "Möchten Sie wirklich alle Konfigurationen zurücksetzen?", - }, - ConfirmClearAll: { - Confirm: "Möchten Sie wirklich alle Chats zurücksetzen?", - }, + ConfirmResetAll: + "Möchten Sie wirklich alle Konfigurationen zurücksetzen?", + ConfirmClearAll: "Möchten Sie wirklich alle Chats zurücksetzen?", }, Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` @@ -102,7 +99,14 @@ const de: LocaleType = { SendKey: "Senden-Taste", Theme: "Erscheinungsbild", TightBorder: "Enger Rahmen", - SendPreviewBubble: "Vorschau-Bubble senden", + SendPreviewBubble: { + Title: "Vorschau-Bubble senden", + SubTitle: "Preview markdown in bubble", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Show a mask splash screen before starting new chat", + }, Prompt: { Disable: { Title: "Autovervollständigung deaktivieren", @@ -176,8 +180,6 @@ const de: LocaleType = { Summarize: "Fassen Sie unsere Diskussion kurz in 200 Wörtern oder weniger zusammen, um sie als Pronpt für zukünftige Gespräche zu verwenden.", }, - ConfirmClearAll: - "Bestätigen Sie, um alle Chat- und Einstellungsdaten zu löschen?", }, Copy: { Success: "In die Zwischenablage kopiert", @@ -189,7 +191,11 @@ const de: LocaleType = { Edit: "Kontext- und Gedächtnis-Prompts", Add: "Hinzufügen", }, + Plugin: { + Name: "Plugin", + }, Mask: { + Name: "Mask", Page: { Title: "Prompt Template", SubTitle: (count: number) => `${count} prompt templates`, @@ -221,6 +227,8 @@ const de: LocaleType = { Title: "Pick a Mask", SubTitle: "Chat with the Soul behind the Mask", More: "Find More", + NotShow: "Not Show Again", + ConfirmNoShow: "Confirm to disable?You can enable it in settings later.", }, }; diff --git a/app/locales/en.ts b/app/locales/en.ts index 9afff00..d735773 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -65,12 +65,8 @@ const en: LocaleType = { ClearAll: "Clear All Data", ResetAll: "Reset All Settings", Close: "Close", - ConfirmResetAll: { - Confirm: "Are you sure you want to reset all configurations?", - }, - ConfirmClearAll: { - Confirm: "Are you sure you want to reset all chat?", - }, + ConfirmResetAll: "Are you sure you want to reset all configurations?", + ConfirmClearAll: "Are you sure you want to reset all data?", }, Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` @@ -102,7 +98,14 @@ const en: LocaleType = { SendKey: "Send Key", Theme: "Theme", TightBorder: "Tight Border", - SendPreviewBubble: "Send Preview Bubble", + SendPreviewBubble: { + Title: "Send Preview Bubble", + SubTitle: "Preview markdown in bubble", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Show a mask splash screen before starting new chat", + }, Prompt: { Disable: { Title: "Disable auto-completion", @@ -174,7 +177,6 @@ const en: LocaleType = { Summarize: "Summarize our discussion briefly in 200 words or less to use as a prompt for future context.", }, - ConfirmClearAll: "Confirm to clear all chat and setting data?", }, Copy: { Success: "Copied to clipboard", @@ -185,7 +187,11 @@ const en: LocaleType = { Edit: "Contextual and Memory Prompts", Add: "Add a Prompt", }, + Plugin: { + Name: "Plugin", + }, Mask: { + Name: "Mask", Page: { Title: "Prompt Template", SubTitle: (count: number) => `${count} prompt templates`, @@ -217,6 +223,8 @@ const en: LocaleType = { Title: "Pick a Mask", SubTitle: "Chat with the Soul behind the Mask", More: "Find More", + NotShow: "Not Show Again", + ConfirmNoShow: "Confirm to disable?You can enable it in settings later.", }, }; diff --git a/app/locales/es.ts b/app/locales/es.ts index b5075da..783cd6e 100644 --- a/app/locales/es.ts +++ b/app/locales/es.ts @@ -65,12 +65,8 @@ const es: LocaleType = { ClearAll: "Borrar todos los datos", ResetAll: "Restablecer todas las configuraciones", Close: "Cerrar", - ConfirmResetAll: { - Confirm: "Are you sure you want to reset all configurations?", - }, - ConfirmClearAll: { - Confirm: "Are you sure you want to reset all chat?", - }, + ConfirmResetAll: "Are you sure you want to reset all configurations?", + ConfirmClearAll: "Are you sure you want to reset all chat?", }, Lang: { Name: "Language", @@ -102,7 +98,14 @@ const es: LocaleType = { SendKey: "Tecla de envío", Theme: "Tema", TightBorder: "Borde ajustado", - SendPreviewBubble: "Enviar burbuja de vista previa", + SendPreviewBubble: { + Title: "Enviar burbuja de vista previa", + SubTitle: "Preview markdown in bubble", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Show a mask splash screen before starting new chat", + }, Prompt: { Disable: { Title: "Desactivar autocompletado", @@ -174,8 +177,6 @@ const es: LocaleType = { Summarize: "Resuma nuestra discusión brevemente en 200 caracteres o menos para usarlo como un recordatorio para futuros contextos.", }, - ConfirmClearAll: - "¿Confirmar para borrar todos los datos de chat y configuración?", }, Copy: { Success: "Copiado al portapapeles", @@ -187,7 +188,11 @@ const es: LocaleType = { Edit: "Contextual and Memory Prompts", Add: "Add One", }, + Plugin: { + Name: "Plugin", + }, Mask: { + Name: "Mask", Page: { Title: "Prompt Template", SubTitle: (count: number) => `${count} prompt templates`, @@ -219,6 +224,8 @@ const es: LocaleType = { Title: "Pick a Mask", SubTitle: "Chat with the Soul behind the Mask", More: "Find More", + NotShow: "Not Show Again", + ConfirmNoShow: "Confirm to disable?You can enable it in settings later.", }, }; diff --git a/app/locales/it.ts b/app/locales/it.ts index 447d707..3fcc80e 100644 --- a/app/locales/it.ts +++ b/app/locales/it.ts @@ -65,12 +65,8 @@ const it: LocaleType = { ClearAll: "Cancella tutti i dati", ResetAll: "Resetta tutte le impostazioni", Close: "Chiudi", - ConfirmResetAll: { - Confirm: "Sei sicuro vuoi cancellare tutte le impostazioni?", - }, - ConfirmClearAll: { - Confirm: "Sei sicuro vuoi cancellare tutte le chat?", - }, + ConfirmResetAll: "Sei sicuro vuoi cancellare tutte le impostazioni?", + ConfirmClearAll: "Sei sicuro vuoi cancellare tutte le chat?", }, Lang: { Name: "Lingue", @@ -102,7 +98,14 @@ const it: LocaleType = { SendKey: "Tasto invia", Theme: "Tema", TightBorder: "Schermo intero", - SendPreviewBubble: "Anteprima di digitazione", + SendPreviewBubble: { + Title: "Anteprima di digitazione", + SubTitle: "Preview markdown in bubble", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Show a mask splash screen before starting new chat", + }, Prompt: { Disable: { Title: "Disabilita l'auto completamento", @@ -175,8 +178,6 @@ const it: LocaleType = { Summarize: "Riassumi brevemente la nostra discussione in 200 caratteri o meno per usarla come spunto per una futura conversazione.", }, - ConfirmClearAll: - "Confermi la cancellazione di tutti i dati della chat e delle impostazioni?", }, Copy: { Success: "Copiato sugli appunti", @@ -188,7 +189,11 @@ const it: LocaleType = { Edit: "Prompt contestuali e di memoria", Add: "Aggiungi altro", }, + Plugin: { + Name: "Plugin", + }, Mask: { + Name: "Mask", Page: { Title: "Prompt Template", SubTitle: (count: number) => `${count} prompt templates`, @@ -220,6 +225,8 @@ const it: LocaleType = { Title: "Pick a Mask", SubTitle: "Chat with the Soul behind the Mask", More: "Find More", + NotShow: "Not Show Again", + ConfirmNoShow: "Confirm to disable?You can enable it in settings later.", }, }; diff --git a/app/locales/jp.ts b/app/locales/jp.ts index ca4d25a..4bbe051 100644 --- a/app/locales/jp.ts +++ b/app/locales/jp.ts @@ -65,12 +65,8 @@ const jp: LocaleType = { ClearAll: "すべてのデータをクリア", ResetAll: "すべてのオプションをリセット", Close: "閉じる", - ConfirmResetAll: { - Confirm: "すべての設定をリセットしてもよろしいですか?", - }, - ConfirmClearAll: { - Confirm: "すべてのチャットをリセットしてもよろしいですか?", - }, + ConfirmResetAll: "すべての設定をリセットしてもよろしいですか?", + ConfirmClearAll: "すべてのチャットをリセットしてもよろしいですか?", }, Lang: { Name: "Language", @@ -103,7 +99,14 @@ const jp: LocaleType = { SendKey: "送信キー", Theme: "テーマ", TightBorder: "ボーダーレスモード", - SendPreviewBubble: "プレビューバブルの送信", + SendPreviewBubble: { + Title: "プレビューバブルの送信", + SubTitle: "在预览气泡中预览 Markdown 内容", + }, + Mask: { + Title: "面具启动页", + SubTitle: "新建聊天时,展示面具启动页", + }, Prompt: { Disable: { Title: "プロンプトの自動補完を無効にする", @@ -176,8 +179,6 @@ const jp: LocaleType = { Summarize: "あなたとユーザの会話を簡潔にまとめて、後続のコンテキストプロンプトとして使ってください。200字以内に抑えてください。", }, - ConfirmClearAll: - "すべてのチャット、設定データをクリアしてもよろしいですか?", }, Copy: { Success: "クリップボードに書き込みました", @@ -188,7 +189,9 @@ const jp: LocaleType = { Edit: "前置コンテキストと履歴メモリ", Add: "新規追加", }, + Plugin: { Name: "插件" }, Mask: { + Name: "面具", Page: { Title: "预设角色面具", SubTitle: (count: number) => `${count} 个预设角色定义`, @@ -220,6 +223,8 @@ const jp: LocaleType = { Title: "挑选一个面具", SubTitle: "现在开始,与面具背后的灵魂思维碰撞", More: "搜索更多", + NotShow: "不再展示", + ConfirmNoShow: "确认禁用?禁用后可以随时在设置中重新启用。", }, }; diff --git a/app/locales/tr.ts b/app/locales/tr.ts index 4e22f1d..a658fcc 100644 --- a/app/locales/tr.ts +++ b/app/locales/tr.ts @@ -65,12 +65,8 @@ const tr: LocaleType = { ClearAll: "Tüm Verileri Temizle", ResetAll: "Tüm Ayarları Sıfırla", Close: "Kapat", - ConfirmResetAll: { - Confirm: "Tüm ayarları sıfırlamak istediğinizden emin misiniz?", - }, - ConfirmClearAll: { - Confirm: "Tüm sohbeti sıfırlamak istediğinizden emin misiniz?", - }, + ConfirmResetAll: "Tüm ayarları sıfırlamak istediğinizden emin misiniz?", + ConfirmClearAll: "Tüm sohbeti sıfırlamak istediğinizden emin misiniz?", }, Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` @@ -102,7 +98,14 @@ const tr: LocaleType = { SendKey: "Gönder Tuşu", Theme: "Tema", TightBorder: "Tam Ekran", - SendPreviewBubble: "Mesaj Önizleme Balonu", + SendPreviewBubble: { + Title: "Mesaj Önizleme Balonu", + SubTitle: "Preview markdown in bubble", + }, + Mask: { + Title: "Mask Splash Screen", + SubTitle: "Show a mask splash screen before starting new chat", + }, Prompt: { Disable: { Title: "Otomatik tamamlamayı devre dışı bırak", @@ -176,8 +179,6 @@ const tr: LocaleType = { Summarize: "Gelecekteki bağlam için bir bilgi istemi olarak kullanmak üzere tartışmamızı en fazla 200 kelimeyle özetleyin.", }, - ConfirmClearAll: - "Tüm sohbet ve ayar verilerini temizlemeyi onaylıyor musunuz?", }, Copy: { Success: "Panoya kopyalandı", @@ -188,7 +189,11 @@ const tr: LocaleType = { Edit: "Bağlamsal ve Bellek Komutları", Add: "Yeni Ekle", }, + Plugin: { + Name: "Plugin", + }, Mask: { + Name: "Mask", Page: { Title: "Prompt Template", SubTitle: (count: number) => `${count} prompt templates`, @@ -220,6 +225,8 @@ const tr: LocaleType = { Title: "Pick a Mask", SubTitle: "Chat with the Soul behind the Mask", More: "Find More", + NotShow: "Not Show Again", + ConfirmNoShow: "Confirm to disable?You can enable it in settings later.", }, }; diff --git a/app/locales/tw.ts b/app/locales/tw.ts index e37ba52..9a0e9ea 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -63,12 +63,8 @@ const tw: LocaleType = { ClearAll: "清除所有資料", ResetAll: "重設所有設定", Close: "關閉", - ConfirmResetAll: { - Confirm: "您確定要重設所有設定嗎?", - }, - ConfirmClearAll: { - Confirm: "您確定要清除所有聊天嗎?", - }, + ConfirmResetAll: "您確定要重設所有設定嗎?", + ConfirmClearAll: "您確定要清除所有数据嗎?", }, Lang: { Name: "Language", @@ -100,7 +96,14 @@ const tw: LocaleType = { SendKey: "發送鍵", Theme: "主題", TightBorder: "緊湊邊框", - SendPreviewBubble: "發送預覽氣泡", + SendPreviewBubble: { + Title: "預覽氣泡", + SubTitle: "在预览气泡中预览 Markdown 内容", + }, + Mask: { + Title: "面具启动页", + SubTitle: "新建聊天时,展示面具启动页", + }, Prompt: { Disable: { Title: "停用提示詞自動補齊", @@ -169,7 +172,6 @@ const tw: LocaleType = { Summarize: "Use the language used by the user (e.g. en-us for english conversation, zh-hant for chinese conversation, etc.) to summarise the conversation in at most 200 words. The summary will be used as prompt for you to continue the conversation in the future.", }, - ConfirmClearAll: "確認清除所有對話、設定?", }, Copy: { Success: "已複製到剪貼簿中", @@ -180,7 +182,9 @@ const tw: LocaleType = { Edit: "前置上下文和歷史記憶", Add: "新增一條", }, + Plugin: { Name: "插件" }, Mask: { + Name: "面具", Page: { Title: "预设角色面具", SubTitle: (count: number) => `${count} 个预设角色定义`, @@ -212,6 +216,8 @@ const tw: LocaleType = { Title: "挑选一个面具", SubTitle: "现在开始,与面具背后的灵魂思维碰撞", More: "搜索更多", + NotShow: "不再展示", + ConfirmNoShow: "确认禁用?禁用后可以随时在设置中重新启用。", }, }; diff --git a/app/store/chat.ts b/app/store/chat.ts index 54fd3fa..5607052 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -319,7 +319,10 @@ export const useChatStore = create()( return { role: "system", - content: Locale.Store.Prompt.History(session.memoryPrompt), + content: + session.memoryPrompt.length > 0 + ? Locale.Store.Prompt.History(session.memoryPrompt) + : "", date: "", } as Message; }, @@ -481,10 +484,8 @@ export const useChatStore = create()( }, clearAllData() { - if (confirm(Locale.Store.ConfirmClearAll)) { - localStorage.clear(); - location.reload(); - } + localStorage.clear(); + location.reload(); }, }), { diff --git a/app/store/config.ts b/app/store/config.ts index 6ffed01..4bd68b7 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -28,6 +28,8 @@ export const DEFAULT_CONFIG = { disablePromptHint: false, + dontShowMaskSplashScreen: false, // dont show splash screen when create chat + modelConfig: { model: "gpt-3.5-turbo" as ModelType, temperature: 1, @@ -138,6 +140,7 @@ export const useAppConfig = create()( state.modelConfig.sendMemory = true; state.modelConfig.historyMessageCount = 4; state.modelConfig.compressMessageLengthThreshold = 1000; + state.dontShowMaskSplashScreen = false; return state; },