mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix(Selector): Fix the issue with the Selector component being selected. (#7600)
* fix(Selector): update value comparison logic to use 'some' for selected values * feat(ModelSettings): add ChevronDown icon as suffix for Select components
This commit is contained in:
parent
46de46965f
commit
093d04c386
@ -70,7 +70,7 @@ const Selector = <V extends string | number>({
|
|||||||
const findLabels = (opts: SelectorOption<V>[]): (string | ReactNode)[] => {
|
const findLabels = (opts: SelectorOption<V>[]): (string | ReactNode)[] => {
|
||||||
const labels: (string | ReactNode)[] = []
|
const labels: (string | ReactNode)[] = []
|
||||||
for (const opt of opts) {
|
for (const opt of opts) {
|
||||||
if (selectedValues.includes(opt.value)) {
|
if (selectedValues.some((v) => v == opt.value)) {
|
||||||
labels.push(opt.label)
|
labels.push(opt.label)
|
||||||
}
|
}
|
||||||
if (opt.options) {
|
if (opt.options) {
|
||||||
@ -91,7 +91,7 @@ const Selector = <V extends string | number>({
|
|||||||
const mapOption = (option: SelectorOption<V>) => ({
|
const mapOption = (option: SelectorOption<V>) => ({
|
||||||
key: option.value,
|
key: option.value,
|
||||||
label: option.label,
|
label: option.label,
|
||||||
extra: <CheckIcon>{selectedValues.includes(option.value) && <Check size={14} />}</CheckIcon>,
|
extra: <CheckIcon>{selectedValues.some((v) => v == option.value) && <Check size={14} />}</CheckIcon>,
|
||||||
disabled: option.disabled,
|
disabled: option.disabled,
|
||||||
type: option.type || (option.options ? 'group' : undefined),
|
type: option.type || (option.options ? 'group' : undefined),
|
||||||
children: option.options?.map(mapOption)
|
children: option.options?.map(mapOption)
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { setTranslateModelPrompt } from '@renderer/store/settings'
|
|||||||
import { Model } from '@renderer/types'
|
import { Model } from '@renderer/types'
|
||||||
import { Button, Select, Tooltip } from 'antd'
|
import { Button, Select, Tooltip } from 'antd'
|
||||||
import { find, sortBy } from 'lodash'
|
import { find, sortBy } from 'lodash'
|
||||||
import { CircleHelp, FolderPen, Languages, MessageSquareMore, Rocket, Settings2 } from 'lucide-react'
|
import { ChevronDown, CircleHelp, FolderPen, Languages, MessageSquareMore, Rocket, Settings2 } from 'lucide-react'
|
||||||
import { FC, useMemo } from 'react'
|
import { FC, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
@ -104,6 +104,7 @@ const ModelSettings: FC = () => {
|
|||||||
options={selectOptions}
|
options={selectOptions}
|
||||||
showSearch
|
showSearch
|
||||||
placeholder={t('settings.models.empty')}
|
placeholder={t('settings.models.empty')}
|
||||||
|
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
|
||||||
/>
|
/>
|
||||||
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={DefaultAssistantSettings.show} />
|
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={DefaultAssistantSettings.show} />
|
||||||
</HStack>
|
</HStack>
|
||||||
@ -125,6 +126,7 @@ const ModelSettings: FC = () => {
|
|||||||
options={selectOptions}
|
options={selectOptions}
|
||||||
showSearch
|
showSearch
|
||||||
placeholder={t('settings.models.empty')}
|
placeholder={t('settings.models.empty')}
|
||||||
|
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
|
||||||
/>
|
/>
|
||||||
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={TopicNamingModalPopup.show} />
|
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={TopicNamingModalPopup.show} />
|
||||||
</HStack>
|
</HStack>
|
||||||
@ -146,6 +148,7 @@ const ModelSettings: FC = () => {
|
|||||||
options={selectOptions}
|
options={selectOptions}
|
||||||
showSearch
|
showSearch
|
||||||
placeholder={t('settings.models.empty')}
|
placeholder={t('settings.models.empty')}
|
||||||
|
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}
|
||||||
/>
|
/>
|
||||||
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={onUpdateTranslateModel} />
|
<Button icon={<Settings2 size={16} />} style={{ marginLeft: 8 }} onClick={onUpdateTranslateModel} />
|
||||||
{translateModelPrompt !== TRANSLATE_PROMPT && (
|
{translateModelPrompt !== TRANSLATE_PROMPT && (
|
||||||
@ -191,7 +194,8 @@ const ModelSettings: FC = () => {
|
|||||||
value={quickAssistantId || defaultAssistant.id}
|
value={quickAssistantId || defaultAssistant.id}
|
||||||
style={{ width: 360 }}
|
style={{ width: 360 }}
|
||||||
onChange={(value) => dispatch(setQuickAssistantId(value))}
|
onChange={(value) => dispatch(setQuickAssistantId(value))}
|
||||||
placeholder={t('settings.models.quick_assistant_selection')}>
|
placeholder={t('settings.models.quick_assistant_selection')}
|
||||||
|
suffixIcon={<ChevronDown size={16} color="var(--color-border)" />}>
|
||||||
<Select.Option key={defaultAssistant.id} value={defaultAssistant.id}>
|
<Select.Option key={defaultAssistant.id} value={defaultAssistant.id}>
|
||||||
<AssistantItem>
|
<AssistantItem>
|
||||||
<ModelAvatar model={defaultAssistant.model || defaultModel} size={18} />
|
<ModelAvatar model={defaultAssistant.model || defaultModel} size={18} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user