Skip to content

Commit

Permalink
fix: 修复浏览器兼容性问题
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Sep 2, 2023
1 parent 2303241 commit 3e72896
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default function Chat({ className }: ChatProps) {
setExpand(true)
}

const lastMessage = messages[messages.length - 1]

return (
<div className={cn(bingStyle.toLowerCase(), { 'side-panel-expanded': expand })}>
<PromptsManage insertPrompt={setInput} />
Expand All @@ -68,8 +70,8 @@ export default function Chat({ className }: ChatProps) {
<>
<ChatList messages={messages} />
<ChatScrollAnchor trackVisibility={generating} />
<ChatNotification message={messages.at(-1)} bot={bot} />
{messages.at(-1)?.suggestedResponses && <ChatSuggestions setInput={setInput} suggestions={messages.at(-1)?.suggestedResponses} />}
<ChatNotification message={lastMessage} bot={bot} />
{lastMessage?.suggestedResponses && <ChatSuggestions setInput={setInput} suggestions={lastMessage?.suggestedResponses} />}

{generating ? (
<div className="flex h-10 items-center justify-center my-4">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bots/bing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export class BingWebBot {
return
}

const lastMessage = event.item.messages.at(-1) as ChatResponseMessage
const lastMessage = event.item.messages[event.item.messages.length - 1] as ChatResponseMessage
const specialMessage = event.item.messages.find(message => message.author === 'bot' && message.contentType === 'IMAGE')
if (specialMessage) {
this.generateContent(specialMessage)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2019",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 3e72896

Please sign in to comment.