diff --git a/package.json b/package.json index e68a546e..70ba89b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bingo", - "version": "1.0.0", + "version": "1.1.0", "private": true, "main": "./cloudflare/cli.js", "scripts": { diff --git a/src/components/advance-switcher.tsx b/src/components/advance-switcher.tsx deleted file mode 100644 index 20075553..00000000 --- a/src/components/advance-switcher.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Switch } from '@headlessui/react'; -import { useAtom } from 'jotai'; -import { sydneyAtom } from '@/state'; - -export function AdvanceSwither({ disabled }: { disabled: boolean }) { - const [enableSydney, switchSydney] = useAtom(sydneyAtom) - return ( -
-
- switchSydney(checked)} - > - - - 启用 Sydney 人格 -
-
- ) -} diff --git a/src/components/chat-list.tsx b/src/components/chat-list.tsx index 624a78ef..934e98c3 100644 --- a/src/components/chat-list.tsx +++ b/src/components/chat-list.tsx @@ -17,7 +17,7 @@ export function ChatList({ messages }: ChatList) {
{messages.map((message, index) => ( - + {index < messages.length - 1 && ( )} diff --git a/src/components/chat-message.tsx b/src/components/chat-message.tsx index 03a631dd..6db8e9f7 100644 --- a/src/components/chat-message.tsx +++ b/src/components/chat-message.tsx @@ -16,10 +16,11 @@ import { ChatFeedback } from './chat-feedback' import { ChatProgress } from './chat-progress' export interface ChatMessageProps { + index: number message: ChatMessageModel } -export function ChatMessage({ message, ...props }: ChatMessageProps) { +export function ChatMessage({ message, index, ...props }: ChatMessageProps) { useEffect(() => { if (document.body.scrollHeight - window.innerHeight - window.scrollY - 200 < 0) { window.scrollBy(0, 200) @@ -88,7 +89,7 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {
{message.author === 'bot' && } - {message.author === 'bot' && } + {message.author === 'bot' && }
: null} diff --git a/src/components/chat.tsx b/src/components/chat.tsx index da902d66..316628a5 100644 --- a/src/components/chat.tsx +++ b/src/components/chat.tsx @@ -20,7 +20,7 @@ import { ChatNotification } from './chat-notification' import { Settings } from './settings' import { ChatHistory } from './chat-history' import { PromptsManage } from './prompts' -import { AdvanceSwither } from './advance-switcher' + export type ChatProps = React.ComponentProps<'div'> & { initialMessages?: ChatMessageModel[] } @@ -67,7 +67,7 @@ export default function Chat({ className }: ChatProps) { - = 2} /> + {/* = 2} /> */} {messages.length ? ( <> diff --git a/src/components/settings/advanced.tsx b/src/components/settings/advanced.tsx new file mode 100644 index 00000000..2da65065 --- /dev/null +++ b/src/components/settings/advanced.tsx @@ -0,0 +1,118 @@ +import { useCallback, useState } from 'react' +import { useAtom } from 'jotai' +import { Switch, RadioGroup } from '@headlessui/react' + +import { + DialogDescription, + DialogHeader, + DialogTitle +} from '@/components/ui/dialog' +import { PrompsTemplates, systemPromptsAtom, unlimitAtom } from '@/state' + +export function AdvancedSetting() { + const [enableUnlimit, setUnlimit] = useAtom(unlimitAtom) + const [systemPrompt, setSystemPrompt] = useAtom(systemPromptsAtom) + const [selected, setSelected] = useState(PrompsTemplates.find((item) => item.content === (systemPrompt || ''))) + + const handleChangePrompt = useCallback((value: typeof PrompsTemplates[0]) => { + setSelected(value) + setSystemPrompt(value.content) + }, [setSelected, setSystemPrompt]) + + return ( + <> + + 高级设置 + + 为 New Bing 添加一些实用的功能。 + + + +
+ 突破对话次数限制 + setUnlimit(checked)} + > + + +
+
+ 预设角色 +
+
+ + Server size +
+ {PrompsTemplates.map((prompt) => ( + + `${active + ? 'ring-2 ring-white/60 ring-offset-2 ring-offset-sky-300' + : '' + } + ${checked ? 'bg-sky-900/75 text-white' : 'bg-white'} + relative flex cursor-pointer rounded-lg px-5 py-4 shadow-md focus:outline-none` + } + > + {({ checked }) => ( + <> +
+
+
+ + {prompt.label} + + + + {prompt.desc} + + +
+
+ {checked && ( +
+ +
+ )} +
+ + )} +
+ ))} +
+
+
+
+
+ + ) +} + + +function CheckIcon(props: React.SVGProps) { + return ( + + + + + ) +} diff --git a/src/components/settings.tsx b/src/components/settings/index.tsx similarity index 84% rename from src/components/settings.tsx rename to src/components/settings/index.tsx index 0b507460..0c052460 100644 --- a/src/components/settings.tsx +++ b/src/components/settings/index.tsx @@ -1,8 +1,8 @@ import { useCallback, useEffect, useState } from 'react' import { useAtom } from 'jotai' -import { Switch } from '@headlessui/react' import { toast } from 'react-hot-toast' -import { hashAtom, historyAtom, isImageOnly, voiceAtom } from '@/state' +import { Switch } from '@headlessui/react' +import { hashAtom, historyAtom, isImageOnly } from '@/state' import { Dialog, DialogContent, @@ -11,11 +11,13 @@ import { DialogHeader, DialogTitle } from '@/components/ui/dialog' -import { Button } from './ui/button' -import { Input } from './ui/input' +import { Button } from '../ui/button' +import { Input } from '../ui/input' import { ChunkKeys, parseCookies, extraCurlFromCookie, parseHeadersFromCurl, encodeHeadersToCookie, setCookie, resetCookies } from '@/lib/utils' -import { ExternalLink } from './external-link' +import { ExternalLink } from '../external-link' import { useCopyToClipboard } from '@/lib/hooks/use-copy-to-clipboard' +import { VoiceSetting } from './voice' +import { AdvancedSetting } from './advanced' export function Settings() { const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 }) @@ -23,7 +25,6 @@ export function Settings() { const [curlValue, setCurlValue] = useState(extraCurlFromCookie(parseCookies(document.cookie, ChunkKeys))) const [imageOnly, setImageOnly] = useState(isImageOnly) const [enabledHistory, setHistory] = useAtom(historyAtom) - const [enableTTS, setEnableTTS] = useAtom(voiceAtom) useEffect(() => { if (isCopied) { @@ -148,33 +149,14 @@ export function Settings() { ) - } else if (loc === 'voice') { + } else if (loc) { return ( setLoc('')} modal> - - 语音设置 - - 目前仅支持 PC 端 Edge 及 Chrome 浏览器 - - - -
- 启用语音回答 - setEnableTTS(checked)} - > - - -
- + { loc === 'voice' ? : }