fix: 换一批第3次卡住问题,修正池索引计算
This commit is contained in:
@@ -555,7 +555,7 @@ export function ChatPanel({
|
||||
const handleRefreshSamples = async () => {
|
||||
// 池里还有未展示的,直接取下一批
|
||||
const nextIndex = poolIndex + BATCH_SIZE
|
||||
if (dailyPool.length > 0 && nextIndex < dailyPool.length) {
|
||||
if (nextIndex < dailyPool.length) {
|
||||
setPoolIndex(nextIndex)
|
||||
setDynamicSamples(dailyPool.slice(nextIndex, nextIndex + BATCH_SIZE))
|
||||
return
|
||||
@@ -566,10 +566,12 @@ export function ChatPanel({
|
||||
const phone = getPhone() || undefined
|
||||
const res = await api.generateSamples(scene, topic, dynamicSamples, phone)
|
||||
if (res.samples?.length > 0) {
|
||||
// AI 生成的新问题加入池并显示
|
||||
const newPool = [...dailyPool, ...res.samples]
|
||||
const newIndex = dailyPool.length
|
||||
setDailyPool(newPool)
|
||||
setPoolIndex(newIndex)
|
||||
setDynamicSamples(res.samples)
|
||||
// AI 生成的新问题加入池,重置索引
|
||||
setDailyPool(prev => [...prev, ...res.samples])
|
||||
setPoolIndex(dailyPool.length)
|
||||
}
|
||||
} catch {
|
||||
toast.error('换一批失败,请稍后重试')
|
||||
|
||||
Reference in New Issue
Block a user