Skip to content

Commit

Permalink
fix: 滚动不能到底的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 25, 2023
1 parent be69511 commit c6477f6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/chat-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function ChatSuggestions({ setInput, suggestions = [] }: ChatSuggestionsP

useEffect(() => {
setSuggestions(suggestions)
window.scrollBy(0, 800)
setTimeout(() => {
window.scrollBy(0, 800)
}, 200)
}, [])

return currentSuggestions?.length ? (
Expand Down
5 changes: 4 additions & 1 deletion src/lib/hooks/chat-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ export function useChatHistory() {
uri.searchParams.append('source', 'cib')
const data = await fetchProxy({
url: uri.toString(),
headers: {
'Content-Type': 'application/json',
},
method: 'GET',
})
console.log('data', data)
updateStorage(data)
updateStorage({ clientId: chatHistory?.clientId || '', conversationId, history: [{ id: '0', text: 'hello', author: 'user' }] })
}, [chatHistory])

const refreshChats = useCallback(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
})
const text = await response.text()
res.writeHead(200, {
'Content-Type': 'application/text',
'Content-Type': 'application/text; charset=UTF-8',
'x-url': response.url,
'x-status': response.status,
})
Expand Down
6 changes: 4 additions & 2 deletions src/state/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BingWebBot } from '@/lib/bots/bing'
import { BingConversationStyle, ChatMessageModel, BotId } from '@/lib/bots/bing/types'
import { nanoid } from '@/lib/utils'
import { atom } from 'jotai'
import { atom, useAtom } from 'jotai'
import { atomWithImmer } from 'jotai-immer'
import { atomWithStorage, createJSONStorage } from 'jotai/utils'
import { atomFamily } from 'jotai/utils'
Expand Down Expand Up @@ -38,10 +38,12 @@ const createBotInstance = () => {

export const chatHistoryAtom = atomWithStorage<{
clientId: string;
conversationId: string;
history?: ChatMessageModel[],
}>('chatHistory', {
clientId: '',
history: [],
conversationId: '',
history: initialMessages,
}, createJSONStorage(storage))

export const chatFamily = atomFamily(
Expand Down

0 comments on commit c6477f6

Please sign in to comment.