2025-12-17 10:13:47 +00:00
|
|
|
'use client';
|
|
|
|
|
import { useChatStore } from '../store';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { Checkbox } from '@/components/ui/checkbox';
|
|
|
|
|
import { Button } from '@/components/ui/button';
|
|
|
|
|
import { cn } from '@/lib/utils';
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
type TokenOption = {
|
2025-12-17 10:13:47 +00:00
|
|
|
value: number;
|
|
|
|
|
label: string;
|
|
|
|
|
};
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
export default function MaxToken() {
|
2025-12-17 10:13:47 +00:00
|
|
|
const setSideBar = useChatStore((store) => store.setSideBar);
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
// 最大回复数选项
|
|
|
|
|
const tokenOptions: TokenOption[] = [
|
|
|
|
|
{ value: 800, label: '800' },
|
|
|
|
|
{ value: 1000, label: '1000' },
|
|
|
|
|
{ value: 1200, label: '1200' },
|
|
|
|
|
{ value: 1500, label: '1500' },
|
2025-12-17 10:13:47 +00:00
|
|
|
];
|
2025-12-09 09:13:46 +00:00
|
|
|
|
2025-12-17 10:13:47 +00:00
|
|
|
const [selectedToken, setSelectedToken] = useState(800);
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
const handleConfirm = async () => {
|
2025-12-17 10:13:47 +00:00
|
|
|
setLoading(true);
|
2025-12-09 09:13:46 +00:00
|
|
|
try {
|
|
|
|
|
// TODO: 调用实际的 API 保存最大回复数设置
|
|
|
|
|
// await updateMaxToken({ maxToken: selectedToken })
|
2025-12-17 10:13:47 +00:00
|
|
|
console.log('Selected max token:', selectedToken);
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
// 模拟延迟
|
2025-12-17 10:13:47 +00:00
|
|
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
2025-12-09 09:13:46 +00:00
|
|
|
|
2025-12-17 10:13:47 +00:00
|
|
|
setSideBar('profile');
|
2025-12-09 09:13:46 +00:00
|
|
|
} catch (error) {
|
2025-12-17 10:13:47 +00:00
|
|
|
console.error(error);
|
2025-12-09 09:13:46 +00:00
|
|
|
} finally {
|
2025-12-17 10:13:47 +00:00
|
|
|
setLoading(false);
|
2025-12-09 09:13:46 +00:00
|
|
|
}
|
2025-12-17 10:13:47 +00:00
|
|
|
};
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex h-full flex-col">
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
<div className="flex flex-col gap-3">
|
|
|
|
|
{tokenOptions.map((option) => (
|
|
|
|
|
<div
|
|
|
|
|
key={option.value}
|
|
|
|
|
className={cn(
|
|
|
|
|
'bg-surface-element-normal flex h-12 cursor-pointer items-center justify-between rounded-lg px-5 transition-colors',
|
|
|
|
|
selectedToken === option.value && 'bg-surface-element-hover'
|
|
|
|
|
)}
|
|
|
|
|
onClick={() => setSelectedToken(option.value)}
|
|
|
|
|
>
|
|
|
|
|
<div className="txt-title-s">{option.label}</div>
|
|
|
|
|
<Checkbox shape="round" checked={selectedToken === option.value} />
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-17 10:13:47 +00:00
|
|
|
);
|
2025-12-09 09:13:46 +00:00
|
|
|
}
|