forked from XiaoMo/ChatGPT-Next-Web
fix: 兼容不同浏览器的input range兼容
This commit is contained in:
parent
03b3f16472
commit
d92108453f
7
app/components/input-range.module.scss
Normal file
7
app/components/input-range.module.scss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.input-range {
|
||||||
|
border: var(--border-in-light);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 5px 15px 5px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
display: flex;
|
||||||
|
}
|
37
app/components/input-range.tsx
Normal file
37
app/components/input-range.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import styles from "./input-range.module.scss";
|
||||||
|
|
||||||
|
interface InputRangeProps {
|
||||||
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
||||||
|
title?: string;
|
||||||
|
value: number | string;
|
||||||
|
className?: string;
|
||||||
|
min: string;
|
||||||
|
max: string;
|
||||||
|
step: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function InputRange({
|
||||||
|
onChange,
|
||||||
|
title,
|
||||||
|
value,
|
||||||
|
className,
|
||||||
|
min,
|
||||||
|
max,
|
||||||
|
step,
|
||||||
|
}: InputRangeProps) {
|
||||||
|
return (
|
||||||
|
<div className={styles["input-range"] + ` ${className ?? ""}`}>
|
||||||
|
{title || value}
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
title={title}
|
||||||
|
value={value}
|
||||||
|
min={min}
|
||||||
|
max={max}
|
||||||
|
step={step}
|
||||||
|
onChange={onChange}
|
||||||
|
></input>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@ -32,6 +32,7 @@ import { UPDATE_URL } from "../constant";
|
|||||||
import { SearchService, usePromptStore } from "../store/prompt";
|
import { SearchService, usePromptStore } from "../store/prompt";
|
||||||
import { requestUsage } from "../requests";
|
import { requestUsage } from "../requests";
|
||||||
import { ErrorBoundary } from "./error";
|
import { ErrorBoundary } from "./error";
|
||||||
|
import { InputRange } from "./input-range";
|
||||||
|
|
||||||
function SettingItem(props: {
|
function SettingItem(props: {
|
||||||
title: string;
|
title: string;
|
||||||
@ -274,8 +275,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"
|
||||||
@ -287,7 +287,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>
|
||||||
|
|
||||||
<SettingItem title={Locale.Settings.TightBorder}>
|
<SettingItem title={Locale.Settings.TightBorder}>
|
||||||
@ -407,8 +407,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="0"
|
min="0"
|
||||||
@ -420,7 +419,7 @@ export function Settings(props: { closeSettings: () => void }) {
|
|||||||
(config.historyMessageCount = e.target.valueAsNumber),
|
(config.historyMessageCount = e.target.valueAsNumber),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
></input>
|
></InputRange>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem
|
<SettingItem
|
||||||
@ -467,8 +466,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"
|
||||||
@ -482,7 +480,7 @@ export function Settings(props: { closeSettings: () => void }) {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
></input>
|
></InputRange>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
title={Locale.Settings.MaxTokens.Title}
|
title={Locale.Settings.MaxTokens.Title}
|
||||||
@ -508,8 +506,7 @@ 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)}
|
value={config.modelConfig.presence_penalty?.toFixed(1)}
|
||||||
min="-2"
|
min="-2"
|
||||||
max="2"
|
max="2"
|
||||||
@ -523,7 +520,7 @@ export function Settings(props: { closeSettings: () => void }) {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
></input>
|
></InputRange>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</List>
|
</List>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,19 +159,11 @@ input[type="checkbox"]:checked::after {
|
|||||||
|
|
||||||
input[type="range"] {
|
input[type="range"] {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
border: var(--border-in-light);
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 5px 15px 5px 10px;
|
|
||||||
background-color: var(--white);
|
background-color: var(--white);
|
||||||
color: var(--black);
|
color: var(--black);
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: attr(value);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-webkit-slider-thumb {
|
@mixin thumb() {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
@ -180,11 +172,36 @@ input[type="range"]::-webkit-slider-thumb {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all ease 0.3s;
|
transition: all ease 0.3s;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="range"]::-webkit-slider-thumb {
|
||||||
|
@include thumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="range"]::-moz-range-thumb {
|
||||||
|
@include thumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="range"]::-ms-thumb {
|
||||||
|
@include thumb();
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin thumbHover() {
|
||||||
|
transform: scaleY(1.2);
|
||||||
|
width: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-webkit-slider-thumb:hover {
|
input[type="range"]::-webkit-slider-thumb:hover {
|
||||||
transform: scaleY(1.2);
|
@include thumbHover();
|
||||||
width: 24px;
|
}
|
||||||
|
|
||||||
|
input[type="range"]::-moz-range-thumb:hover {
|
||||||
|
@include thumbHover();
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="range"]::-ms-thumb:hover {
|
||||||
|
@include thumbHover();
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="number"],
|
input[type="number"],
|
||||||
|
Loading…
Reference in New Issue
Block a user