fix(settings): handle undefined content limit in BasicSettings component (#5252)

This commit is contained in:
Asurada 2025-04-24 02:58:36 +08:00 committed by GitHub
parent 39008f704d
commit a3faaa99fb
2 changed files with 5 additions and 3 deletions

View File

@ -60,10 +60,12 @@ const BasicSettings: FC = () => {
<Input
style={{ width: '100px' }}
placeholder="2000"
value={contentLimit}
value={contentLimit === undefined ? '' : contentLimit}
onChange={(e) => {
const value = e.target.value
if (!isNaN(Number(value)) && Number(value) > 0) {
if (value === '') {
dispatch(setContentLimit(undefined))
} else if (!isNaN(Number(value)) && Number(value) > 0) {
dispatch(setContentLimit(Number(value)))
}
}}

View File

@ -135,7 +135,7 @@ const websearchSlice = createSlice({
state.providers.push(action.payload)
}
},
setContentLimit: (state, action: PayloadAction<number>) => {
setContentLimit: (state, action: PayloadAction<number | undefined>) => {
state.contentLimit = action.payload
}
}