Merge branch 'Yidadaa:main' into main

This commit is contained in:
latorc 2023-04-03 11:34:29 +08:00 committed by GitHub
commit 61ce579071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 18 deletions

View File

@ -461,8 +461,9 @@ export function Chat(props: {
// Auto focus // Auto focus
useEffect(() => { useEffect(() => {
if (props.sideBarShowing) return;
inputRef.current?.focus(); inputRef.current?.focus();
}, []); }, [props.sideBarShowing]);
return ( return (
<div className={styles.chat} key={session.id}> <div className={styles.chat} key={session.id}>
@ -530,7 +531,6 @@ export function Chat(props: {
className={styles["chat-body"]} className={styles["chat-body"]}
ref={scrollRef} ref={scrollRef}
onScroll={(e) => onChatBodyScroll(e.currentTarget)} onScroll={(e) => onChatBodyScroll(e.currentTarget)}
onMouseOver={() => inputRef.current?.blur()}
onTouchStart={() => inputRef.current?.blur()} onTouchStart={() => inputRef.current?.blur()}
> >
{messages.map((message, i) => { {messages.map((message, i) => {
@ -592,6 +592,7 @@ export function Chat(props: {
if (!isMobileScreen()) return; if (!isMobileScreen()) return;
setUserInput(message.content); setUserInput(message.content);
}} }}
onMouseOver={() => inputRef.current?.blur()}
> >
<Markdown content={message.content} /> <Markdown content={message.content} />
</div> </div>
@ -626,6 +627,9 @@ export function Chat(props: {
setAutoScroll(false); setAutoScroll(false);
setTimeout(() => setPromptHints([]), 500); setTimeout(() => setPromptHints([]), 500);
}} }}
onMouseOver={() => {
inputRef.current?.focus();
}}
autoFocus={!props?.sideBarShowing} autoFocus={!props?.sideBarShowing}
/> />
<IconButton <IconButton

View File

@ -8,16 +8,22 @@
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
} }
pre code.hljs { pre code {
display: block; display: block;
overflow-x: auto; overflow-x: auto;
padding: 1em; padding: 1em;
} }
code.hljs { code {
padding: 3px 5px; padding: 3px 5px;
} }
.hljs,
pre {
background: #1a1b26;
color: #cbd2ea;
}
/*! /*!
Theme: Tokyo-night-Dark Theme: Tokyo-night-Dark
origin: https://github.com/enkia/tokyo-night-vscode-theme origin: https://github.com/enkia/tokyo-night-vscode-theme
@ -99,11 +105,6 @@
color: #c0caf5; color: #c0caf5;
} }
.hljs {
background: #1a1b26;
color: #9aa5ce;
}
.hljs-emphasis { .hljs-emphasis {
font-style: italic; font-style: italic;
} }

View File

@ -5,15 +5,19 @@ export function trimTopic(topic: string) {
return topic.replace(/[,。!?、,.!?]*$/, ""); return topic.replace(/[,。!?、,.!?]*$/, "");
} }
export function copyToClipboard(text: string) { export async function copyToClipboard(text: string) {
navigator.clipboard try {
.writeText(text) await navigator.clipboard.writeText(text);
.then((res) => { } catch (error) {
const textarea = document.createElement("textarea");
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
} finally {
showToast(Locale.Copy.Success); showToast(Locale.Copy.Success);
}) }
.catch((err) => {
showToast(Locale.Copy.Failed);
});
} }
export function downloadAs(text: string, filename: string) { export function downloadAs(text: string, filename: string) {