fix range input number not show on firefox

This commit is contained in:
Rentoo 2023-03-30 23:50:45 +08:00
parent 9eb77207fb
commit 4056f49135
2 changed files with 53 additions and 19 deletions

View File

@ -47,6 +47,37 @@ function SettingItem(props: {
); );
} }
function InputRange({
title,
min,
max,
step,
value,
onChange,
}: {
title?: string;
min: string;
max: string;
step: string;
value: any;
onChange: (config: any) => void;
}) {
return (
<div className="input-range">
<span>{value}</span>
<input
title={title}
type="range"
value={value}
min={min}
max={max}
step={step}
onChange={onChange}
></input>
</div>
);
}
export function Settings(props: { closeSettings: () => void }) { export function Settings(props: { closeSettings: () => void }) {
const [showEmojiPicker, setShowEmojiPicker] = useState(false); const [showEmojiPicker, setShowEmojiPicker] = useState(false);
const [config, updateConfig, resetConfig, clearAllData] = useChatStore( const [config, updateConfig, resetConfig, clearAllData] = useChatStore(
@ -251,8 +282,7 @@ export function Settings(props: { closeSettings: () => void }) {
title={Locale.Settings.FontSize.Title} title={Locale.Settings.FontSize.Title}
subTitle={Locale.Settings.FontSize.SubTitle} subTitle={Locale.Settings.FontSize.SubTitle}
> >
<input <InputRange
type="range"
title={`${config.fontSize ?? 14}px`} title={`${config.fontSize ?? 14}px`}
value={config.fontSize} value={config.fontSize}
min="12" min="12"
@ -264,7 +294,7 @@ export function Settings(props: { closeSettings: () => void }) {
(config.fontSize = Number.parseInt(e.currentTarget.value)), (config.fontSize = Number.parseInt(e.currentTarget.value)),
) )
} }
></input> ></InputRange>
</SettingItem> </SettingItem>
<div className="no-mobile"> <div className="no-mobile">
@ -371,8 +401,7 @@ export function Settings(props: { closeSettings: () => void }) {
title={Locale.Settings.HistoryCount.Title} title={Locale.Settings.HistoryCount.Title}
subTitle={Locale.Settings.HistoryCount.SubTitle} subTitle={Locale.Settings.HistoryCount.SubTitle}
> >
<input <InputRange
type="range"
title={config.historyMessageCount.toString()} title={config.historyMessageCount.toString()}
value={config.historyMessageCount} value={config.historyMessageCount}
min="2" min="2"
@ -384,7 +413,7 @@ export function Settings(props: { closeSettings: () => void }) {
(config.historyMessageCount = e.target.valueAsNumber), (config.historyMessageCount = e.target.valueAsNumber),
) )
} }
></input> ></InputRange>
</SettingItem> </SettingItem>
<SettingItem <SettingItem
@ -429,8 +458,7 @@ export function Settings(props: { closeSettings: () => void }) {
title={Locale.Settings.Temperature.Title} title={Locale.Settings.Temperature.Title}
subTitle={Locale.Settings.Temperature.SubTitle} subTitle={Locale.Settings.Temperature.SubTitle}
> >
<input <InputRange
type="range"
value={config.modelConfig.temperature.toFixed(1)} value={config.modelConfig.temperature.toFixed(1)}
min="0" min="0"
max="2" max="2"
@ -442,7 +470,7 @@ export function Settings(props: { closeSettings: () => void }) {
e.currentTarget.valueAsNumber), e.currentTarget.valueAsNumber),
); );
}} }}
></input> ></InputRange>
</SettingItem> </SettingItem>
<SettingItem <SettingItem
title={Locale.Settings.MaxTokens.Title} title={Locale.Settings.MaxTokens.Title}
@ -466,12 +494,11 @@ export function Settings(props: { closeSettings: () => void }) {
title={Locale.Settings.PresencePenlty.Title} title={Locale.Settings.PresencePenlty.Title}
subTitle={Locale.Settings.PresencePenlty.SubTitle} subTitle={Locale.Settings.PresencePenlty.SubTitle}
> >
<input <InputRange
type="range"
value={config.modelConfig.presence_penalty.toFixed(1)}
min="-2" min="-2"
max="2" max="2"
step="0.5" step="0.5"
value={config.modelConfig.presence_penalty.toFixed(1)}
onChange={(e) => { onChange={(e) => {
updateConfig( updateConfig(
(config) => (config) =>
@ -479,7 +506,7 @@ export function Settings(props: { closeSettings: () => void }) {
e.currentTarget.valueAsNumber), e.currentTarget.valueAsNumber),
); );
}} }}
></input> />
</SettingItem> </SettingItem>
</List> </List>
</div> </div>

View File

@ -146,15 +146,22 @@ input[type="checkbox"]:checked::after {
input[type="range"] { input[type="range"] {
appearance: none; appearance: none;
background-color: var(--white);
color: var(--black);
}
.input-range{
border: var(--border-in-light); border: var(--border-in-light);
border-radius: 10px; border-radius: 10px;
padding: 5px 15px 5px 10px; padding: 5px 15px 5px 10px;
background-color: var(--white); display: flex;
color: var(--black); align-items: center;
&::before {
content: attr(value);
font-size: 12px; font-size: 12px;
width: 156px;
height: 27.5px;
box-sizing: border-box;
>input {
width: 110px;
} }
} }