Add autoFocus to search input and improve code formatting

This commit is contained in:
2024-05-15 18:22:52 +08:00
parent 09f6e5b490
commit 4162866fd6

View File

@@ -44,6 +44,7 @@ export default function Search(props: {
<hr /> <hr />
<div> <div>
<input <input
autoFocus
className="m-1 p-1 w-full border" className="m-1 p-1 w-full border"
type="text" type="text"
onInput={async (event: any) => { onInput={async (event: any) => {
@@ -81,7 +82,9 @@ export default function Search(props: {
if (now !== searchingNow) setSearchingNow(now); if (now !== searchingNow) setSearchingNow(now);
const value: ChatStore = await db.get("chatgpt-api-web", key); const value: ChatStore = await db.get("chatgpt-api-web", key);
const content = value.contents_for_index.join(" ").toLowerCase(); const content = value.contents_for_index
.join(" ")
.toLowerCase();
if (content.includes(query)) { if (content.includes(query)) {
const beginIndex: number = content.indexOf(query); const beginIndex: number = content.indexOf(query);
const preview = content.slice( const preview = content.slice(