forked from weaigc/bingo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
297 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<DialogHeader> | ||
<DialogTitle>高级设置</DialogTitle> | ||
<DialogDescription> | ||
为 New Bing 添加一些实用的功能。 | ||
</DialogDescription> | ||
</DialogHeader> | ||
|
||
<div className="flex flex-col gap-2"> | ||
突破对话次数限制 | ||
<Switch | ||
checked={enableUnlimit} | ||
className={`${enableUnlimit ? 'bg-blue-600' : 'bg-gray-200'} relative inline-flex h-6 w-11 items-center rounded-full`} | ||
onChange={(checked: boolean) => setUnlimit(checked)} | ||
> | ||
<span | ||
className={`${enableUnlimit ? 'translate-x-6' : 'translate-x-1'} inline-block h-4 w-4 transform rounded-full bg-white transition`} | ||
/> | ||
</Switch> | ||
</div> | ||
<div className="flex flex-col gap-2"> | ||
预设角色 | ||
<div className="w-full py-1"> | ||
<div className="mx-auto w-full"> | ||
<RadioGroup value={selected} onChange={handleChangePrompt}> | ||
<RadioGroup.Label className="sr-only">Server size</RadioGroup.Label> | ||
<div className="space-y-2"> | ||
{PrompsTemplates.map((prompt) => ( | ||
<RadioGroup.Option | ||
key={prompt.label} | ||
value={prompt} | ||
className={({ active, checked }) => | ||
`${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 }) => ( | ||
<> | ||
<div className="flex w-full items-center justify-between"> | ||
<div className="flex items-center"> | ||
<div className="text-sm"> | ||
<RadioGroup.Label | ||
as="p" | ||
className={`font-medium ${checked ? 'text-white' : 'text-gray-900' | ||
}`} | ||
> | ||
{prompt.label} | ||
</RadioGroup.Label> | ||
<RadioGroup.Description | ||
as="span" | ||
className={`inline ${checked ? 'text-sky-100' : 'text-gray-500'}`} | ||
> | ||
<span> | ||
{prompt.desc} | ||
</span> | ||
</RadioGroup.Description> | ||
</div> | ||
</div> | ||
{checked && ( | ||
<div className="shrink-0 text-white"> | ||
<CheckIcon className="h-6 w-6" /> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
)} | ||
</RadioGroup.Option> | ||
))} | ||
</div> | ||
</RadioGroup> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
|
||
function CheckIcon(props: React.SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg viewBox="0 0 24 24" fill="none" {...props}> | ||
<circle cx={12} cy={12} r={12} fill="#fff" opacity="0.2" /> | ||
<path | ||
d="M7 13l3 3 7-7" | ||
stroke="#fff" | ||
strokeWidth={1.5} | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useAtom } from 'jotai' | ||
import { Switch } from '@headlessui/react' | ||
|
||
import { | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle | ||
} from '@/components/ui/dialog' | ||
import { voiceAtom } from '@/state' | ||
|
||
export function VoiceSetting() { | ||
const [enableTTS, setEnableTTS] = useAtom(voiceAtom) | ||
|
||
return ( | ||
<> | ||
<DialogHeader> | ||
<DialogTitle>语音设置</DialogTitle> | ||
<DialogDescription> | ||
目前仅支持 PC 端 Edge 及 Chrome 浏览器 | ||
</DialogDescription> | ||
</DialogHeader> | ||
|
||
<div className="flex gap-2"> | ||
启用语音回答 | ||
<Switch | ||
checked={enableTTS} | ||
className={`${enableTTS ? 'bg-blue-600' : 'bg-gray-200'} relative inline-flex h-6 w-11 items-center rounded-full`} | ||
onChange={(checked: boolean) => setEnableTTS(checked)} | ||
> | ||
<span | ||
className={`${enableTTS ? 'translate-x-6' : 'translate-x-1'} inline-block h-4 w-4 transform rounded-full bg-white transition`} | ||
/> | ||
</Switch> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.