From 174c745279f7f27b2283318695060184468641ab Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 9 Apr 2023 23:35:45 +0800 Subject: [PATCH 1/6] fix: #648 password input style --- app/components/settings.module.scss | 7 ++++++- app/components/settings.tsx | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/components/settings.module.scss b/app/components/settings.module.scss index 7d40d83b..830e1bae 100644 --- a/app/components/settings.module.scss +++ b/app/components/settings.module.scss @@ -19,11 +19,16 @@ cursor: pointer; } -.password-input { +.password-input-container { + max-width: 50%; display: flex; justify-content: flex-end; .password-eye { margin-right: 4px; } + + .password-input { + min-width: 80%; + } } diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 0d1c1d05..15fe5839 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -60,13 +60,17 @@ function PasswordInput(props: HTMLProps) { } return ( -
+
: } onClick={changeVisibility} className={styles["password-eye"]} /> - +
); } From 4a492264a164fb9f771025fde466a389d1e0e624 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 9 Apr 2023 23:41:16 +0800 Subject: [PATCH 2/6] fix: #641 delete wrong chat list --- app/components/chat-list.tsx | 2 +- app/components/ui-lib.module.scss | 2 ++ app/components/ui-lib.tsx | 2 +- app/store/app.ts | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/components/chat-list.tsx b/app/components/chat-list.tsx index ab5d849f..cab8812c 100644 --- a/app/components/chat-list.tsx +++ b/app/components/chat-list.tsx @@ -96,7 +96,7 @@ export function ChatList() { index={i} selected={i === selectedIndex} onClick={() => selectSession(i)} - onDelete={chatStore.deleteSession} + onDelete={() => chatStore.deleteSession(i)} /> ))} {provided.placeholder} diff --git a/app/components/ui-lib.module.scss b/app/components/ui-lib.module.scss index 67d13d3e..457c5504 100644 --- a/app/components/ui-lib.module.scss +++ b/app/components/ui-lib.module.scss @@ -127,6 +127,7 @@ width: 100vw; display: flex; justify-content: center; + pointer-events: none; .toast-content { max-width: 80vw; @@ -141,6 +142,7 @@ margin-bottom: 20px; display: flex; align-items: center; + pointer-events: all; .toast-action { padding-left: 20px; diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index a72aa868..3179b213 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -156,7 +156,7 @@ export function showToast( }; setTimeout(() => { - close(); + // close(); }, delay); root.render(); diff --git a/app/store/app.ts b/app/store/app.ts index 02fb4b32..7c68547f 100644 --- a/app/store/app.ts +++ b/app/store/app.ts @@ -205,7 +205,7 @@ interface ChatStore { moveSession: (from: number, to: number) => void; selectSession: (index: number) => void; newSession: () => void; - deleteSession: () => void; + deleteSession: (index?: number) => void; currentSession: () => ChatSession; onNewMessage: (message: Message) => void; onUserInput: (content: string) => Promise; @@ -326,13 +326,13 @@ export const useChatStore = create()( })); }, - deleteSession() { + deleteSession(i?: number) { const deletedSession = get().currentSession(); - const index = get().currentSessionIndex; + const index = i ?? get().currentSessionIndex; const isLastSession = get().sessions.length === 1; if (!isMobileScreen() || confirm(Locale.Home.DeleteChat)) { get().removeSession(index); - + showToast(Locale.Home.DeleteToast, { text: Locale.Home.Revert, onClick() { From 0e05733bbb9ebe3ee40f23edf41531ea6d4f8d70 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 9 Apr 2023 23:51:12 +0800 Subject: [PATCH 3/6] fix: #589 improve unauthorized tips --- app/components/chat.tsx | 9 ++++- app/components/settings.tsx | 65 +++++++++++++++++++------------------ app/components/ui-lib.tsx | 2 +- app/locales/cn.ts | 4 +-- app/store/access.ts | 8 +++-- app/store/app.ts | 26 +++++++++------ 6 files changed, 66 insertions(+), 48 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index c5c257e5..fbac9f2c 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -19,6 +19,7 @@ import { BOT_HELLO, ROLES, createMessage, + useAccessStore, } from "../store"; import { @@ -485,11 +486,17 @@ export function Chat(props: { const context: RenderMessage[] = session.context.slice(); + const accessStore = useAccessStore(); + if ( context.length === 0 && session.messages.at(0)?.content !== BOT_HELLO.content ) { - context.push(BOT_HELLO); + const copiedHello = Object.assign({}, BOT_HELLO); + if (!accessStore.isAuthorized()) { + copiedHello.content = Locale.Error.Unauthorized; + } + context.push(copiedHello); } // preview messages diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 15fe5839..bbb28b46 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -124,8 +124,7 @@ export function Settings(props: { closeSettings: () => void }) { const builtinCount = SearchService.count.builtin; const customCount = promptStore.prompts.size ?? 0; - const showUsage = !!accessStore.token || !!accessStore.accessCode; - + const showUsage = accessStore.isAuthorized(); useEffect(() => { checkUpdate(); showUsage && checkUsage(); @@ -346,37 +345,7 @@ export function Settings(props: { closeSettings: () => void }) { > - - - - updateConfig( - (config) => - (config.disablePromptHint = e.currentTarget.checked), - ) - } - > - - - } - text={Locale.Settings.Prompt.Edit} - onClick={() => showToast(Locale.WIP)} - /> - - {enabledAccessControl ? ( void }) { + + + + updateConfig( + (config) => + (config.disablePromptHint = e.currentTarget.checked), + ) + } + > + + + + } + text={Locale.Settings.Prompt.Edit} + onClick={() => showToast(Locale.WIP)} + /> + + +